summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorStiver <stiver.mail@gmail.com>2014-08-13 22:17:21 +0200
committerStiver <stiver.mail@gmail.com>2014-08-13 22:17:21 +0200
commit887c093afdb49b9bd2a2a4930c0a6a331662399d (patch)
tree8d0901288d901a82397c4471aa568d79ab66dbe3 /test/unit
parent04b5c9abb177ced644caa520c252f783327a0cbf (diff)
downloadfernflower-887c093afdb49b9bd2a2a4930c0a6a331662399d.tar
fernflower-887c093afdb49b9bd2a2a4930c0a6a331662399d.tar.gz
fernflower-887c093afdb49b9bd2a2a4930c0a6a331662399d.tar.lz
fernflower-887c093afdb49b9bd2a2a4930c0a6a331662399d.tar.xz
fernflower-887c093afdb49b9bd2a2a4930c0a6a331662399d.zip
Unit tests updated
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/TestSingleClasses.java12
-rw-r--r--test/unit/classes/TestClassLoop.java36
-rw-r--r--test/unit/classes/TestClassSwitch.java16
-rw-r--r--test/unit/classes/TestClassTypes.java21
-rw-r--r--test/unit/results/TestClassLoop.dec6
-rw-r--r--test/unit/results/TestClassSwitch.dec16
-rw-r--r--test/unit/results/TestClassTypes.dec20
7 files changed, 120 insertions, 7 deletions
diff --git a/test/unit/TestSingleClasses.java b/test/unit/TestSingleClasses.java
index 2758316..754fcec 100644
--- a/test/unit/TestSingleClasses.java
+++ b/test/unit/TestSingleClasses.java
@@ -63,18 +63,24 @@ public class TestSingleClasses {
String file_java_name = file_name+".java";
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());
// decompile it
decompiler.decompileContext(temp_dir);
// 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.
- String decompiled_content = new String(Files.readAllBytes(new File(temp_dir, file_java_name).toPath()), "UTF-8");
+ // NOTE: reference files are saved with Windows-style line endings. Convert them if you are decompiling to Unix.
+ 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");
// clean up
- //temp_dir.delete();
+ decompiled_file.delete();
+ temp_dir.delete();
// compare file content with the reference
assertEquals(decompiled_content, reference_content);
diff --git a/test/unit/classes/TestClassLoop.java b/test/unit/classes/TestClassLoop.java
index 4275153..5288cf6 100644
--- a/test/unit/classes/TestClassLoop.java
+++ b/test/unit/classes/TestClassLoop.java
@@ -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() {
- boolean a = true;
+ while(true) {
+ System.out.println();
+ }
+
+ }
+
+ public static void testFinally() {
+
+ boolean a = (Math.random() > 0);
+
while(true) {
try {
if(!a) {
@@ -16,5 +25,24 @@ 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");
+ }
+
+ }
}
diff --git a/test/unit/classes/TestClassSwitch.java b/test/unit/classes/TestClassSwitch.java
new file mode 100644
index 0000000..3e29d5e
--- /dev/null
+++ b/test/unit/classes/TestClassSwitch.java
@@ -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);
+ }
+ }
+
+}
diff --git a/test/unit/classes/TestClassTypes.java b/test/unit/classes/TestClassTypes.java
new file mode 100644
index 0000000..0d0cba1
--- /dev/null
+++ b/test/unit/classes/TestClassTypes.java
@@ -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();
+ }
+ }
+
+}
diff --git a/test/unit/results/TestClassLoop.dec b/test/unit/results/TestClassLoop.dec
index 3870f83..a931148 100644
--- a/test/unit/results/TestClassLoop.dec
+++ b/test/unit/results/TestClassLoop.dec
@@ -3,6 +3,12 @@ package unit.classes;
public class TestClassLoop {
+ public static void testSimpleInfinite() {
+ while(true) {
+ System.out.println();
+ }
+ }
+
public static void testFinally() {
boolean var0 = Math.random() > 0.0D;
diff --git a/test/unit/results/TestClassSwitch.dec b/test/unit/results/TestClassSwitch.dec
new file mode 100644
index 0000000..386a341
--- /dev/null
+++ b/test/unit/results/TestClassSwitch.dec
@@ -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);
+ }
+ }
+}
diff --git a/test/unit/results/TestClassTypes.dec b/test/unit/results/TestClassTypes.dec
new file mode 100644
index 0000000..f4c6885
--- /dev/null
+++ b/test/unit/results/TestClassTypes.dec
@@ -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();
+ }
+
+ }
+}