add additional tests for static initializers
authorAlexandru-Constantin Bledea <contact@apixandru.com>
Thu, 17 Mar 2016 21:15:54 +0000 (23:15 +0200)
committerAlexandru-Constantin Bledea <contact@apixandru.com>
Thu, 17 Mar 2016 21:15:54 +0000 (23:15 +0200)
14 files changed:
plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java
plugins/java-decompiler/engine/testData/classes/pkg/TestClassFields.class
plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithObject.class [deleted file]
plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithObjectField.class [new file with mode: 0644]
plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithPrimitiveField.class [new file with mode: 0644]
plugins/java-decompiler/engine/testData/classes/pkg/TestMutableStaticOtherClass.class [new file with mode: 0644]
plugins/java-decompiler/engine/testData/results/TestClassFields.dec
plugins/java-decompiler/engine/testData/results/TestInterfaceWithObjectField.dec [moved from plugins/java-decompiler/engine/testData/results/TestInterfaceWithObject.dec with 68% similarity]
plugins/java-decompiler/engine/testData/results/TestInterfaceWithPrimitiveField.dec [new file with mode: 0644]
plugins/java-decompiler/engine/testData/results/TestMutableStaticOtherClass.dec [new file with mode: 0644]
plugins/java-decompiler/engine/testData/src/pkg/TestClassFields.java
plugins/java-decompiler/engine/testData/src/pkg/TestInterfaceWithObjectField.java [moved from plugins/java-decompiler/engine/testData/src/pkg/TestInterfaceWithObject.java with 78% similarity]
plugins/java-decompiler/engine/testData/src/pkg/TestInterfaceWithPrimitiveField.java [new file with mode: 0644]
plugins/java-decompiler/engine/testData/src/pkg/TestMutableStaticOtherClass.java [new file with mode: 0644]

index 180428dbec9324eec62ce8cebc3cd83d3410ebee..cbbbc2d606a2b56e6a18c746043bca9cf1bac798 100644 (file)
@@ -83,7 +83,9 @@ public class SingleClassesTest {
   @Test public void testMethodReferenceLetterClass() { doTest("pkg/TestMethodReferenceLetterClass"); }
   @Test public void testMemberAnnotations() { doTest("pkg/TestMemberAnnotations"); }
   @Test public void testStaticNameClash() { doTest("pkg/TestStaticNameClash"); }
-  @Test public void testInterfaceWithObject() { doTest("pkg/TestInterfaceWithObject"); }
+  @Test public void testInterfaceWithPrimitiveField() { doTest("pkg/TestInterfaceWithPrimitiveField"); }
+  @Test public void testInterfaceWithObjectField() { doTest("pkg/TestInterfaceWithObjectField"); }
+  @Test public void testTestMutableStaticOtherClass() { doTest("pkg/TestMutableStaticOtherClass"); }
 
   protected void doTest(String testFile, String... companionFiles) {
     ConsoleDecompiler decompiler = fixture.getDecompiler();
index 603bab20676cb402340cf83eb6720ffaac0b2a17..a25091d6a5f2925bb6daf82bf43f81a91b474d8b 100644 (file)
Binary files a/plugins/java-decompiler/engine/testData/classes/pkg/TestClassFields.class and b/plugins/java-decompiler/engine/testData/classes/pkg/TestClassFields.class differ
diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithObject.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithObject.class
deleted file mode 100644 (file)
index 614da5e..0000000
Binary files a/plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithObject.class and /dev/null differ
diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithObjectField.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithObjectField.class
new file mode 100644 (file)
index 0000000..bf7ec68
Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithObjectField.class differ
diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithPrimitiveField.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithPrimitiveField.class
new file mode 100644 (file)
index 0000000..b079f95
Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestInterfaceWithPrimitiveField.class differ
diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestMutableStaticOtherClass.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestMutableStaticOtherClass.class
new file mode 100644 (file)
index 0000000..14b1efd
Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestMutableStaticOtherClass.class differ
index 75ece1eee7f733e8bd6a9b2048c3cf615d8be498..d139051670bec29808ce165f237c76f17bf101dd 100644 (file)
@@ -1,25 +1,26 @@
 package pkg;
 
 public class TestClassFields {
+   static int staticMutable;
    private static int[] sizes;
    private static String[] names = new String[]{"name1", "name2"};
 
    static {
-      sizes = new int[names.length];// 26
-   }// 27
+      sizes = new int[names.length];// 27
+   }// 28
 }
 
 class 'pkg/TestClassFields' {
    method '<clinit> ()V' {
-      11      7
-      14      7
-      17      7
-      1a      8
+      11      8
+      14      8
+      17      8
+      1a      9
    }
 }
 
 Lines mapping:
-26 <-> 8
 27 <-> 9
+28 <-> 10
 Not mapped:
-25
+26
similarity index 68%
rename from plugins/java-decompiler/engine/testData/results/TestInterfaceWithObject.dec
rename to plugins/java-decompiler/engine/testData/results/TestInterfaceWithObjectField.dec
index 5afeed6c9a24de35dcf72179d633caef98fcdd09..c9418d8bc71f0c7880a832ede0aed4b3f3abcbfe 100644 (file)
@@ -2,7 +2,7 @@ package pkg;
 
 import java.math.BigDecimal;
 
-public interface TestInterfaceWithObject {
+public interface TestInterfaceWithObjectField {
    BigDecimal BUGS_IN_THE_DECOMPILER = BigDecimal.ZERO;
 }
 
diff --git a/plugins/java-decompiler/engine/testData/results/TestInterfaceWithPrimitiveField.dec b/plugins/java-decompiler/engine/testData/results/TestInterfaceWithPrimitiveField.dec
new file mode 100644 (file)
index 0000000..542e858
--- /dev/null
@@ -0,0 +1,6 @@
+package pkg;
+
+public interface TestInterfaceWithPrimitiveField {
+   int MAX_BYTE_VALUE = 127;
+}
+
diff --git a/plugins/java-decompiler/engine/testData/results/TestMutableStaticOtherClass.dec b/plugins/java-decompiler/engine/testData/results/TestMutableStaticOtherClass.dec
new file mode 100644 (file)
index 0000000..6e7ed33
--- /dev/null
@@ -0,0 +1,27 @@
+package pkg;
+
+import pkg.TestClassFields;
+
+public class TestMutableStaticOtherClass {
+   private static final int SIZE;
+
+   static {
+      TestClassFields.staticMutable = 3;// 12
+      SIZE = TestClassFields.staticMutable;// 13
+   }// 14
+}
+
+class 'pkg/TestMutableStaticOtherClass' {
+   method '<clinit> ()V' {
+      0      8
+      1      8
+      4      9
+      7      9
+      a      10
+   }
+}
+
+Lines mapping:
+12 <-> 9
+13 <-> 10
+14 <-> 11
index a1f2facaf41cea767935456a042a32c1b3e99166..2341ff7b5674d6289279ca619c1b3963e1c33072 100644 (file)
@@ -17,6 +17,7 @@ package pkg;
 
 public class TestClassFields {
 
+  static int staticMutable;
   private static int[] sizes;
   private static String[] names;
 
similarity index 78%
rename from plugins/java-decompiler/engine/testData/src/pkg/TestInterfaceWithObject.java
rename to plugins/java-decompiler/engine/testData/src/pkg/TestInterfaceWithObjectField.java
index 4653d70ec00b759e39be3249bf9c0860c01222e1..ac0bd64dbb31ef7f16329917878f3aa07389188d 100644 (file)
@@ -6,7 +6,7 @@ import java.math.BigDecimal;
  * @author Alexandru-Constantin Bledea
  * @since March 06, 2016
  */
-public interface TestInterfaceWithObject {
+public interface TestInterfaceWithObjectField {
 
     BigDecimal BUGS_IN_THE_DECOMPILER = BigDecimal.ZERO;
 
diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestInterfaceWithPrimitiveField.java b/plugins/java-decompiler/engine/testData/src/pkg/TestInterfaceWithPrimitiveField.java
new file mode 100644 (file)
index 0000000..89d1b7a
--- /dev/null
@@ -0,0 +1,13 @@
+package pkg;
+
+import java.math.BigDecimal;
+
+/**
+ * @author Alexandru-Constantin Bledea
+ * @since March 06, 2016
+ */
+public interface TestInterfaceWithPrimitiveField {
+
+    int MAX_BYTE_VALUE = Byte.MAX_VALUE;
+
+}
diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestMutableStaticOtherClass.java b/plugins/java-decompiler/engine/testData/src/pkg/TestMutableStaticOtherClass.java
new file mode 100644 (file)
index 0000000..4015c83
--- /dev/null
@@ -0,0 +1,15 @@
+package pkg;
+
+/**
+ * @author Alexandru-Constantin Bledea
+ * @since March 17, 2016
+ */
+public class TestMutableStaticOtherClass {
+
+    private static final int SIZE;
+
+    static {
+        TestClassFields.staticMutable = 3;
+        SIZE = TestClassFields.staticMutable;
+    }
+}