From 93a39b7b50beaec7b96adbb75141fe5ba3d39c47 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 18 Mar 2016 18:02:33 +0100 Subject: [PATCH] [java-decompiler] test data cleanup; warnings --- .../decompiler/DecompilerTestFixture.java | 10 ++++--- .../java/decompiler/SingleClassesTest.java | 8 ++---- .../classes/pkg/TestClassFields$Inner.class | Bin 0 -> 441 bytes testData/classes/pkg/TestClassFields.class | Bin 513 -> 592 bytes .../classes/pkg/TestInterfaceFields.class | Bin 0 -> 385 bytes .../pkg/TestInterfaceWithObjectField.class | Bin 339 -> 0 bytes .../pkg/TestInterfaceWithPrimitiveField.class | Bin 225 -> 0 bytes .../pkg/TestMutableStaticOtherClass.class | Bin 462 -> 0 bytes testData/results/TestClassFields.dec | 25 +++++++++++----- testData/results/TestInterfaceFields.dec | 9 ++++++ .../results/TestInterfaceWithObjectField.dec | 8 ------ .../TestInterfaceWithPrimitiveField.dec | 6 ---- .../results/TestMutableStaticOtherClass.dec | 27 ------------------ testData/src/pkg/TestClassFields.java | 27 ++++++------------ testData/src/pkg/TestInterfaceFields.java | 8 ++++++ .../src/pkg/TestInterfaceWithObjectField.java | 13 --------- .../pkg/TestInterfaceWithPrimitiveField.java | 13 --------- .../src/pkg/TestMutableStaticOtherClass.java | 15 ---------- 18 files changed, 53 insertions(+), 116 deletions(-) create mode 100644 testData/classes/pkg/TestClassFields$Inner.class create mode 100644 testData/classes/pkg/TestInterfaceFields.class delete mode 100644 testData/classes/pkg/TestInterfaceWithObjectField.class delete mode 100644 testData/classes/pkg/TestInterfaceWithPrimitiveField.class delete mode 100644 testData/classes/pkg/TestMutableStaticOtherClass.class create mode 100644 testData/results/TestInterfaceFields.dec delete mode 100644 testData/results/TestInterfaceWithObjectField.dec delete mode 100644 testData/results/TestInterfaceWithPrimitiveField.dec delete mode 100644 testData/results/TestMutableStaticOtherClass.dec create mode 100644 testData/src/pkg/TestInterfaceFields.java delete mode 100644 testData/src/pkg/TestInterfaceWithObjectField.java delete mode 100644 testData/src/pkg/TestInterfaceWithPrimitiveField.java delete mode 100644 testData/src/pkg/TestMutableStaticOtherClass.java diff --git a/test/org/jetbrains/java/decompiler/DecompilerTestFixture.java b/test/org/jetbrains/java/decompiler/DecompilerTestFixture.java index b3385e2..58f6db0 100644 --- a/test/org/jetbrains/java/decompiler/DecompilerTestFixture.java +++ b/test/org/jetbrains/java/decompiler/DecompilerTestFixture.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; @@ -104,13 +105,14 @@ public class DecompilerTestFixture { public static void assertFilesEqual(File expected, File actual) { if (expected.isDirectory()) { - assertThat(actual.list(), Matchers.arrayContainingInAnyOrder(expected.list())); - for (String name : expected.list()) { + String[] children = Objects.requireNonNull(expected.list()); + assertThat(actual.list(), Matchers.arrayContainingInAnyOrder(children)); + for (String name : children) { assertFilesEqual(new File(expected, name), new File(actual, name)); } } else { - assertThat(getContent(actual), Matchers.equalTo(getContent(expected))); + assertEquals(getContent(expected), getContent(actual)); } } diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/test/org/jetbrains/java/decompiler/SingleClassesTest.java index cbbbc2d..e905fb3 100644 --- a/test/org/jetbrains/java/decompiler/SingleClassesTest.java +++ b/test/org/jetbrains/java/decompiler/SingleClassesTest.java @@ -46,6 +46,7 @@ public class SingleClassesTest { } @Test public void testClassFields() { doTest("pkg/TestClassFields"); } + @Test public void testInterfaceFields() { doTest("pkg/TestInterfaceFields"); } @Test public void testClassLambda() { doTest("pkg/TestClassLambda"); } @Test public void testClassLoop() { doTest("pkg/TestClassLoop"); } @Test public void testClassSwitch() { doTest("pkg/TestClassSwitch"); } @@ -83,9 +84,6 @@ 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 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(); @@ -110,7 +108,7 @@ public class SingleClassesTest { File decompiledFile = new File(fixture.getTargetDir(), testName + ".java"); assertTrue(decompiledFile.isFile()); File referenceFile = new File(fixture.getTestDataDir(), "results/" + testName + ".dec"); - assertTrue("Expecting " + referenceFile.getAbsolutePath() + " to be a file", referenceFile.isFile()); + assertTrue(referenceFile.isFile()); assertFilesEqual(referenceFile, decompiledFile); } @@ -132,4 +130,4 @@ public class SingleClassesTest { return files; } -} +} \ No newline at end of file diff --git a/testData/classes/pkg/TestClassFields$Inner.class b/testData/classes/pkg/TestClassFields$Inner.class new file mode 100644 index 0000000000000000000000000000000000000000..1c16a7e3b3a72a2d00987cd024702775f328a0ae GIT binary patch literal 441 zcmZvYOH0E*6ot<;uQsMO+WM%dxagvFVS>06H-$pL$HF4GoTNiZO;gDv{wg=>LU7>^ z@JESvVnC3r&dizboIBjF?~hLaXXv+}VZ(-wO$$8>I}B}^^E{5OikyduU|<1*c^;>6 ze!-v(M|TYRcr~M!&Sjj6>tY#-Z2HUEJc@*r1K&R-Y8Z?t`{(&(URk%RB8$W%R{g!H zkoh>_Qchx#%;d>}KXC^JOa~U47Iqo>j}LS2A2$fnRAdZBrB113k&q0os__z@&b^y( zA)=h2ThoFgT7XWwpkJw(bkfjJgUM;p?SPb#8prQwyi_0vRHp7Wu?D9?4=JczbMO8Q h?74<*W4&VcOOhI1Ye?$pP`UvZ+oU$J8oJnm{R2F=OsoI^ literal 0 HcmV?d00001 diff --git a/testData/classes/pkg/TestClassFields.class b/testData/classes/pkg/TestClassFields.class index a25091d6a5f2925bb6daf82bf43f81a91b474d8b..e8788e044b56381c8df5b82c7da5c6fa33ec8ee3 100644 GIT binary patch literal 592 zcmZva%TB^T6o&tyl$Kfr!5iKXMFcg1#+}9u(WD8%MU4hol{z8SQVgvwd@E%kG3o>O zP{uP2kx1N}f6isjd}n69zTZ9p9Aa0)1eO)7s905zjYGqlFgXo6)`i&+ZeGErf`WoA z2HEgD-eb^1t-6-)bDzS#^CUFVG|2I+j&Rb=+O73ym0ingm(8H(c=RS>Vb}Fq;w>Z)KNr9$2N9!q%lL__jm2`Snod_&s(?L4j3~3 z6y}FFq*=DjeLr8R9MEV*qeKIbVwG@c139|i33?2Plu&4;2`bzV9&H*SRfkxdsi@h9`~vy&UF#zj8$h`lKNN+Mc1;mRf*_`mC7exyiI697mMAAM=@XEhg!Tg~K5Qre delta 313 zcmX|5%}T>S7@SQ~vyExh)%w#^YY{;ODT=px69l0igd%ucYtUdoao4kW^ceae;z|7NK3Q+=1YU@%StdzBf1M*sHuvO7qPJ;=2&hgq6mm|pR` z<4<9__+FPa)MHE{9<{~h13Ek?`HoMlB4QP}uw-_UJqU1=I78JX3vy-a72>6g6>*|8 z6=qq-;|9#3K_xN&Kioq=2S_UK@XmbYkA8$&b6W)5mO9@6nmm*cTXYwwJuLnKU$ZPj diff --git a/testData/classes/pkg/TestInterfaceFields.class b/testData/classes/pkg/TestInterfaceFields.class new file mode 100644 index 0000000000000000000000000000000000000000..4f39e335d3d806c1938a24d5ac0a36a3deb8ea8e GIT binary patch literal 385 zcmZusyH3ME5S&Xw&VeKZ2zk)ZLW3JR5K>TET;~@KtM8!7&9R(l2 zM1K+Q#T#L&DL+)k`J*PeKT(T&Z(9EQel5vN+j+7nSG%XH$6)Q*El#Y&$rl=t>M zhRSd;l?>}670b(P?#sj#eniab^&(3Gd8YEA=gL$&v6jh$$T=BJ(}Ua$-7Y*uA`VUK zRZEUu9ewaRs^ARW=cmwIvdqx>-y8cg8EA&~vUp@MPhX{u6$()zb&@93hk+W%X~C`$ hGEhf@dXt!4>iOdzD1D;*PLN_!trj17ZP8T1#vecpQhWda literal 0 HcmV?d00001 diff --git a/testData/classes/pkg/TestInterfaceWithObjectField.class b/testData/classes/pkg/TestInterfaceWithObjectField.class deleted file mode 100644 index bf7ec687a2f7be273dd0d02d72e5c8dff7d985ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 339 zcmaJ-Jx{|x41L#>e9%A(R7gy~1`Ao(iWu6a5GgdM4Ir^Zm-I-lBq<74{ui(@@B{c! z2q&xv5B7VuY(M+!`{NV9DY_OmuxUX<+d#*_7Q=4;=3*Lo<0!mzqoF$puC6`bolwDF z@E7jnT+N-nOot+oInR0w=2?=-LaK8H?dbTHp*dL21Vh`Gg&42$Sd<};Gs>(_m#Z=n zBUzEdP&_NIP@;U`iMW$$9>fcgsF4)e?4;UdVB5wHbQ^2X84jKvQ|G@XhE6Rp<3;NH z4rA#4rJ6L}yOV&1YG~3Y81||iH8Nqqq>M#upJHXk8`wJv9Pq`pFU7vtnMg{?dHvgoo)Z`L2Mg}GZkUJO| WBpFy3Sb;PfkjKQp4i@78vpE6pB04$% diff --git a/testData/classes/pkg/TestMutableStaticOtherClass.class b/testData/classes/pkg/TestMutableStaticOtherClass.class deleted file mode 100644 index 14b1efdd89c333e2f89f96ac09e3d32c47ea60c7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 462 zcmah_O;5r=5PefhTS@^1Ke;G3KN5TKChm&Z|3cMe7?N{xJ2DY9@PSB*eSrqu8Tbv`vkk+xxXP$hu}2TLg{Nl?&NgH zOlvuogi2Q}jl;tIWvM_MwF4u#5N0kM*IiH7Ph|t|K(qA diff --git a/testData/results/TestClassFields.dec b/testData/results/TestClassFields.dec index d139051..6917171 100644 --- a/testData/results/TestClassFields.dec +++ b/testData/results/TestClassFields.dec @@ -1,26 +1,37 @@ package pkg; public class TestClassFields { - static int staticMutable; private static int[] sizes; private static String[] names = new String[]{"name1", "name2"}; + private static final int SIZE; static { - sizes = new int[names.length];// 27 - }// 28 + sizes = new int[names.length];// 15 + TestClassFields.Inner.staticMutable = 3;// 17 + SIZE = TestClassFields.Inner.staticMutable;// 14 18 + }// 19 + + private static class Inner { + private static int staticMutable; + } } class 'pkg/TestClassFields' { method ' ()V' { + 0 10 + 2 9 11 8 14 8 17 8 1a 9 + 22 10 + 25 11 } } Lines mapping: -27 <-> 9 -28 <-> 10 -Not mapped: -26 +14 <-> 11 +15 <-> 9 +17 <-> 10 +18 <-> 11 +19 <-> 12 diff --git a/testData/results/TestInterfaceFields.dec b/testData/results/TestInterfaceFields.dec new file mode 100644 index 0000000..d08e2fe --- /dev/null +++ b/testData/results/TestInterfaceFields.dec @@ -0,0 +1,9 @@ +package pkg; + +import java.math.BigDecimal; + +public interface TestInterfaceFields { + BigDecimal BIG_ZERO = BigDecimal.ZERO; + int MAX_BYTE_VALUE = 127; +} + diff --git a/testData/results/TestInterfaceWithObjectField.dec b/testData/results/TestInterfaceWithObjectField.dec deleted file mode 100644 index c9418d8..0000000 --- a/testData/results/TestInterfaceWithObjectField.dec +++ /dev/null @@ -1,8 +0,0 @@ -package pkg; - -import java.math.BigDecimal; - -public interface TestInterfaceWithObjectField { - BigDecimal BUGS_IN_THE_DECOMPILER = BigDecimal.ZERO; -} - diff --git a/testData/results/TestInterfaceWithPrimitiveField.dec b/testData/results/TestInterfaceWithPrimitiveField.dec deleted file mode 100644 index 542e858..0000000 --- a/testData/results/TestInterfaceWithPrimitiveField.dec +++ /dev/null @@ -1,6 +0,0 @@ -package pkg; - -public interface TestInterfaceWithPrimitiveField { - int MAX_BYTE_VALUE = 127; -} - diff --git a/testData/results/TestMutableStaticOtherClass.dec b/testData/results/TestMutableStaticOtherClass.dec deleted file mode 100644 index 6e7ed33..0000000 --- a/testData/results/TestMutableStaticOtherClass.dec +++ /dev/null @@ -1,27 +0,0 @@ -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 ' ()V' { - 0 8 - 1 8 - 4 9 - 7 9 - a 10 - } -} - -Lines mapping: -12 <-> 9 -13 <-> 10 -14 <-> 11 diff --git a/testData/src/pkg/TestClassFields.java b/testData/src/pkg/TestClassFields.java index 2341ff7..8a77fe0 100644 --- a/testData/src/pkg/TestClassFields.java +++ b/testData/src/pkg/TestClassFields.java @@ -1,29 +1,20 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package pkg; public class TestClassFields { + private static class Inner { + private static int staticMutable; + } - static int staticMutable; private static int[] sizes; private static String[] names; - static { + private static final int SIZE; + static { names = new String[]{"name1", "name2"}; sizes = new int[names.length]; + + Inner.staticMutable = 3; + SIZE = Inner.staticMutable; } -} +} \ No newline at end of file diff --git a/testData/src/pkg/TestInterfaceFields.java b/testData/src/pkg/TestInterfaceFields.java new file mode 100644 index 0000000..e117258 --- /dev/null +++ b/testData/src/pkg/TestInterfaceFields.java @@ -0,0 +1,8 @@ +package pkg; + +import java.math.BigDecimal; + +public interface TestInterfaceFields { + BigDecimal BIG_ZERO = BigDecimal.ZERO; + int MAX_BYTE_VALUE = Byte.MAX_VALUE; +} \ No newline at end of file diff --git a/testData/src/pkg/TestInterfaceWithObjectField.java b/testData/src/pkg/TestInterfaceWithObjectField.java deleted file mode 100644 index ac0bd64..0000000 --- a/testData/src/pkg/TestInterfaceWithObjectField.java +++ /dev/null @@ -1,13 +0,0 @@ -package pkg; - -import java.math.BigDecimal; - -/** - * @author Alexandru-Constantin Bledea - * @since March 06, 2016 - */ -public interface TestInterfaceWithObjectField { - - BigDecimal BUGS_IN_THE_DECOMPILER = BigDecimal.ZERO; - -} diff --git a/testData/src/pkg/TestInterfaceWithPrimitiveField.java b/testData/src/pkg/TestInterfaceWithPrimitiveField.java deleted file mode 100644 index 89d1b7a..0000000 --- a/testData/src/pkg/TestInterfaceWithPrimitiveField.java +++ /dev/null @@ -1,13 +0,0 @@ -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/testData/src/pkg/TestMutableStaticOtherClass.java b/testData/src/pkg/TestMutableStaticOtherClass.java deleted file mode 100644 index 4015c83..0000000 --- a/testData/src/pkg/TestMutableStaticOtherClass.java +++ /dev/null @@ -1,15 +0,0 @@ -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; - } -}