Unit tests updated

master
Stiver 11 years ago
parent 04b5c9abb1
commit 887c093afd
  1. 10
      test/unit/TestSingleClasses.java
  2. 36
      test/unit/classes/TestClassLoop.java
  3. 16
      test/unit/classes/TestClassSwitch.java
  4. 21
      test/unit/classes/TestClassTypes.java
  5. 6
      test/unit/results/TestClassLoop.dec
  6. 16
      test/unit/results/TestClassSwitch.dec
  7. 20
      test/unit/results/TestClassTypes.dec

@ -63,6 +63,10 @@ public class TestSingleClasses {
String file_java_name = file_name+".java"; String file_java_name = file_name+".java";
File reference_file = new File(current_path + "/test/unit/results/" + file_name + ".dec"); File reference_file = new File(current_path + "/test/unit/results/" + file_name + ".dec");
if(!reference_file.exists()) {
return; // no reference file for some reason, not yet created
}
File temp_dir = new File(Files.createTempDirectory("tempdec_"+file_name).toString()); File temp_dir = new File(Files.createTempDirectory("tempdec_"+file_name).toString());
// decompile it // decompile it
@ -70,11 +74,13 @@ public class TestSingleClasses {
// get both the decompiled file content and the reference // get both the decompiled file content and the reference
// NOTE: reference files are saved with Windows-style line endings. Convert them if you are decompiling to Unix. // NOTE: reference files are saved with Windows-style line endings. Convert them if you are decompiling to Unix.
String decompiled_content = new String(Files.readAllBytes(new File(temp_dir, file_java_name).toPath()), "UTF-8"); File decompiled_file = new File(temp_dir, file_java_name);
String decompiled_content = new String(Files.readAllBytes(decompiled_file.toPath()), "UTF-8");
String reference_content = new String(Files.readAllBytes(reference_file.toPath()), "UTF-8"); String reference_content = new String(Files.readAllBytes(reference_file.toPath()), "UTF-8");
// clean up // clean up
//temp_dir.delete(); decompiled_file.delete();
temp_dir.delete();
// compare file content with the reference // compare file content with the reference
assertEquals(decompiled_content, reference_content); assertEquals(decompiled_content, reference_content);

@ -1,10 +1,19 @@
package test.input; package unit.classes;
public class TestLoop { public class TestClassLoop {
public static void main(String[] args) { public static void testSimpleInfinite() {
while(true) {
System.out.println();
}
}
public static void testFinally() {
boolean a = (Math.random() > 0);
boolean a = true;
while(true) { while(true) {
try { try {
if(!a) { if(!a) {
@ -17,4 +26,23 @@ public class TestLoop {
} }
public static void testFinallyContinue() {
boolean a = (Math.random() > 0);
for(;;) {
try {
System.out.println("1");
} finally {
if(a) {
System.out.println("3");
continue;
}
}
System.out.println("4");
}
}
} }

@ -0,0 +1,16 @@
package unit.classes;
public class TestClassSwitch {
public void testCaseOrder(int a) {
switch(a) {
case 13:
System.out.println(13);
return;
case 5:
System.out.println(5);
}
}
}

@ -0,0 +1,21 @@
package unit.classes;
public class TestClassTypes {
public void testBoolean() {
byte var7 = 0;
long time = System.currentTimeMillis();
if(time % 2 > 0) {
var7 = 1;
} else if(time % 3 > 0) {
var7 = 2;
}
if(var7 == 1) {
System.out.println();
}
}
}

@ -3,6 +3,12 @@ package unit.classes;
public class TestClassLoop { public class TestClassLoop {
public static void testSimpleInfinite() {
while(true) {
System.out.println();
}
}
public static void testFinally() { public static void testFinally() {
boolean var0 = Math.random() > 0.0D; boolean var0 = Math.random() > 0.0D;

@ -0,0 +1,16 @@
package unit.classes;
public class TestClassSwitch {
public void testCaseOrder(int var1) {
switch(var1) {
case 5:
System.out.println(5);
default:
return;
case 13:
System.out.println(13);
}
}
}

@ -0,0 +1,20 @@
package unit.classes;
public class TestClassTypes {
public void testBoolean() {
byte var1 = 0;
long var2 = System.currentTimeMillis();
if(var2 % 2L > 0L) {
var1 = 1;
} else if(var2 % 3L > 0L) {
var1 = 2;
}
if(var1 == 1) {
System.out.println();
}
}
}
Loading…
Cancel
Save