<commit_before>package at.yawk.javap

import at.yawk.javap.model.ProcessingInput
import at.yawk.javap.model.ProcessingOutput
import org.testng.Assert.assertEquals
import org.testng.annotations.Test

/**
 * @author yawkat
 */

class LocalProcessorTest {
    val localProcessor = LocalProcessor(SystemSdkProvider)

    @Test
    fun `empty file`() {
        assertEquals(
                localProcessor.process(ProcessingInput("", SystemSdkProvider.JDK)),
                ProcessingOutput("", NO_CLASSES_GENERATED, "")
        )
    }

    @Test
    fun `compile error`() {
        assertEquals(
                localProcessor.process(ProcessingInput("abc", SystemSdkProvider.JDK)),
                ProcessingOutput("""Main.java:1: error: reached end of file while parsing
abc
^
1 error
""", null, null)
        )
    }

    @Test
    fun `simple program`() {
        assertEquals(
                localProcessor.process(ProcessingInput("class A { void a() { int i = 0; i++; } }", SystemSdkProvider.JDK)),
                ProcessingOutput("", """Compiled from "Main.java"
class A
  minor version: 0
  major version: 52
  flags: ACC_SUPER
{
  A();
    descriptor: ()V
    flags:
    Code:
      stack=1, locals=1, args_size=1
        start local 0 // A this
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
        end local 0 // A this
      LineNumberTable:
        line 1: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   LA;

  void a();
    descriptor: ()V
    flags:
    Code:
      stack=1, locals=2, args_size=1
        start local 0 // A this
         0: iconst_0
         1: istore_1
        start local 1 // int i
         2: iinc          1, 1
         5: return
        end local 1 // int i
        end local 0 // A this
      LineNumberTable:
        line 1: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   LA;
            2       4     1     i   I
}
SourceFile: "Main.java"
""", """class A {
    A() {
        super();
    }

    void a() {<commit_msg>Stop uncommiting my changes intellij<commit_after>package at.yawk.javap

import at.yawk.javap.model.ProcessingInput
import at.yawk.javap.model.ProcessingOutput
import org.testng.Assert.assertEquals
import org.testng.annotations.Test

/**
 * @author yawkat
 */

class LocalProcessorTest {
    val localProcessor = LocalProcessor(SystemSdkProvider)

    @Test
    fun `empty file`() {
        assertEquals(
                localProcessor.process(ProcessingInput("", SystemSdkProvider.JDK)),
                ProcessingOutput("", NO_CLASSES_GENERATED, "")
        )
    }

    @Test
    fun `compile error`() {
        assertEquals(
                localProcessor.process(ProcessingInput("abc", SystemSdkProvider.JDK)),
                ProcessingOutput("""Main.java:1: error: reached end of file while parsing
abc
^
1 error
""", null, null)
        )
    }

    @Test
    fun `simple program`() {
        assertEquals(
                localProcessor.process(ProcessingInput("class A { void a() { int i = 0; i++; } }", SystemSdkProvider.JDK)),
                ProcessingOutput("", """Compiled from "Main.java"
class A
  minor version: 0
  major version: 52
  flags: ACC_SUPER
{
  A();
    descriptor: ()V
    flags:
    Code:
      stack=1, locals=1, args_size=1
        start local 0 // A this
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
        end local 0 // A this
      LineNumberTable:
        line 1: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   LA;

  void a();
    descriptor: ()V
    flags:
    Code:
      stack=1, locals=2, args_size=1
        start local 0 // A this
         0: iconst_0
         1: istore_1
        start local 1 // int i
         2: iinc          1, 1
         5: return
        end local 1 // int i
        end local 0 // A this
      LineNumberTable:
        line 1: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   LA;
            2       4     1     i   I
}
SourceFile: "Main.java"
""", """class A {
    A() {
        super();
    }
    """ + """
    void a() {
{'fraction_non_alphanumeric': 0.10385144429160935, 'fraction_numerical': 0.020174232003668042, 'mean_word_length': 1.7457520453115167, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2008060', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1287, 'n_words': 370}