java-decompiler: tests moved

This commit is contained in:
Roman Shevchenko 2014-09-01 18:54:33 +04:00
parent d5fe121d1d
commit e629738a46
28 changed files with 467 additions and 10 deletions

View File

@ -37,15 +37,11 @@ public class SingleClassesTest {
assertTrue(tempDir.delete());
assertTrue(tempDir.mkdirs());
decompiler = new ConsoleDecompiler(new HashMap<String, Object>() {{
boolean win = System.getProperty("os.name", "").startsWith("Windows");
put(IFernflowerPreferences.LOG_LEVEL, "warn");
put(IFernflowerPreferences.RENAME_ENTITIES, "1");
put(IFernflowerPreferences.HIDE_DEFAULT_CONSTRUCTOR, "1");
put(IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "0");
put(IFernflowerPreferences.IDEA_NOT_NULL_ANNOTATION, "1");
put(IFernflowerPreferences.LAMBDA_TO_ANONYMOUS_CLASS, "0");
put(IFernflowerPreferences.USE_DEBUG_VAR_NAMES, "0");
put(IFernflowerPreferences.NEW_LINE_SEPARATOR, (win ? "0" : "1"));
put(IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "1");
put(IFernflowerPreferences.REMOVE_SYNTHETIC, "1");
put(IFernflowerPreferences.REMOVE_BRIDGE, "1");
put(IFernflowerPreferences.LITERALS_AS_IS, "1");
}});
}
@ -62,8 +58,14 @@ public class SingleClassesTest {
@Test public void testClassSwitch() { doTest("TestClassSwitch"); }
@Test public void testClassTypes() { doTest("TestClassTypes"); }
@Test public void testClassVar() { doTest("TestClassVar"); }
@Test public void testDeprecations() { doTest("TestDeprecations"); }
@Test public void testExtendsList() { doTest("TestExtendsList"); }
@Test public void testMethodParameters() { doTest("TestMethodParameters"); }
@Test public void testCodeConstructs() { doTest("TestCodeConstructs"); }
@Test public void testConstants() { doTest("TestConstants"); }
//@Test public void testEnum() { doTest("TestEnum"); }
private void doTest(String testName) {
private void doTest(final String testName) {
try {
File testDataDir = new File("testData");
if (!isTestDataDir(testDataDir)) testDataDir = new File("community/plugins/java-decompiler/engine/testData");
@ -73,6 +75,16 @@ public class SingleClassesTest {
File classFile = new File(testDataDir, "/classes/pkg/" + testName + ".class");
assertTrue(classFile.isFile());
decompiler.addSpace(classFile, true);
File[] innerClasses = classFile.getParentFile().listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.matches(testName + "\\$.+\\.class");
}
});
for (File inner : innerClasses) {
decompiler.addSpace(inner, true);
}
decompiler.decompileContext(tempDir);
File decompiledFile = new File(tempDir, testName + ".java");

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -65,7 +65,7 @@ public class TestClassLambda {
return null;
}
public static String function(Supplier var0) {
public static String function(Supplier<String> var0) {
return (String)var0.get();
}

View File

@ -0,0 +1,17 @@
package pkg;
class TestCodeConstructs {
private int count = 0;
void expressions() {
(new String()).hashCode();
}
String fieldIncrement() {
int var1 = this.count++;
return "id:" + var1;
}
}

View File

@ -0,0 +1,76 @@
package pkg;
import java.util.Date;
public class TestConstants {
static final boolean T = true;
static final boolean F = false;
static final char C0 = '\n';
static final char C1 = 'a';
static final char C2 = 'Ȁ';
static final byte BMin = -128;
static final byte BMax = 127;
static final short SMin = -32768;
static final short SMax = 32767;
static final int IMin = -2147483648;
static final int IMax = 2147483647;
static final long LMin = -9223372036854775808L;
static final long LMax = 9223372036854775807L;
static final float FNan = 0.0F / 0.0;
static final float FNeg = -1.0F / 0.0;
static final float FPos = 1.0F / 0.0;
static final float FMin = 1.4E-45F;
static final float FMax = 3.4028235E38F;
static final double DNan = 0.0D / 0.0;
static final double DNeg = -1.0D / 0.0;
static final double DPos = 1.0D / 0.0;
static final double DMin = 4.9E-324D;
static final double DMax = 1.7976931348623157E308D;
@TestConstants.A(byte.class)
void m1() {
}
@TestConstants.A(char.class)
void m2() {
}
@TestConstants.A(double.class)
void m3() {
}
@TestConstants.A(float.class)
void m4() {
}
@TestConstants.A(int.class)
void m5() {
}
@TestConstants.A(long.class)
void m6() {
}
@TestConstants.A(short.class)
void m7() {
}
@TestConstants.A(boolean.class)
void m8() {
}
@TestConstants.A(void.class)
void m9() {
}
@TestConstants.A(Date.class)
void m10() {
}
@interface A {
Class<?> value();
}
}

View File

@ -0,0 +1,32 @@
package pkg;
public class TestDeprecations {
/** @deprecated */
public int byComment;
/** @deprecated */
@Deprecated
public int byAnno;
/** @deprecated */
public void byComment() {
}
/** @deprecated */
@Deprecated
public void byAnno() {
}
/** @deprecated */
@Deprecated
public static class ByAnno {
}
/** @deprecated */
public static class ByComment {
}
}

View File

@ -0,0 +1,30 @@
package pkg;
public enum TestEnum {
E1,
E2 {
public void m() {
}
},
E3("-"),
E4("+") {
public void m() {
}
};
private String s;
public void m() {
}
private TestEnum() {
this((String)"?");
}
private TestEnum(@Deprecated String var3) {
this.s = var3;
}
}

View File

@ -0,0 +1,13 @@
package pkg;
public class TestExtendsList {
static <T extends Comparable<? super T>> T m1(T var0) {
return null;
}
static <T extends Object & Comparable<? super T>> T m2(T var0) {
return null;
}
}

View File

@ -0,0 +1,47 @@
package pkg;
public class TestMethodParameters {
TestMethodParameters(@Deprecated int var1) {
}
void m1(@Deprecated int var1) {
}
static void m2(@Deprecated int var0) {
}
void local() {
class Local {
Local(@Deprecated int var2) {
}
void m(@Deprecated int var1) {
}
}
}
static class C2 {
C2(@Deprecated int var1) {
}
void m1(@Deprecated int var1) {
}
static void m2(@Deprecated int var0) {
}
}
class C1 {
C1(@Deprecated int var2) {
}
void m(@Deprecated int var1) {
}
}
}

View File

@ -0,0 +1,28 @@
/*
* 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;
class TestCodeConstructs {
void expressions() {
new String().hashCode();
}
private int count = 0;
String fieldIncrement() {
int id = count++;
return "id:" + id;
}
}

View File

@ -0,0 +1,64 @@
/*
* 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 TestConstants {
static final boolean T = true;
static final boolean F = false;
static final char C0 = '\n';
static final char C1 = 'a';
static final char C2 = 512;
static final byte BMin = Byte.MIN_VALUE;
static final byte BMax = Byte.MAX_VALUE;
static final short SMin = Short.MIN_VALUE;
static final short SMax = Short.MAX_VALUE;
static final int IMin = Integer.MIN_VALUE;
static final int IMax = Integer.MAX_VALUE;
static final long LMin = Long.MIN_VALUE;
static final long LMax = Long.MAX_VALUE;
static final float FNan = Float.NaN;
static final float FNeg = Float.NEGATIVE_INFINITY;
static final float FPos = Float.POSITIVE_INFINITY;
static final float FMin = Float.MIN_VALUE;
static final float FMax = Float.MAX_VALUE;
static final double DNan = Double.NaN;
static final double DNeg = Double.NEGATIVE_INFINITY;
static final double DPos = Double.POSITIVE_INFINITY;
static final double DMin = Double.MIN_VALUE;
static final double DMax = Double.MAX_VALUE;
static @interface A {
Class<?> value();
}
@A(byte.class) void m1() { }
@A(char.class) void m2() { }
@A(double.class) void m3() { }
@A(float.class) void m4() { }
@A(int.class) void m5() { }
@A(long.class) void m6() { }
@A(short.class) void m7() { }
@A(boolean.class) void m8() { }
@A(void.class) void m9() { }
@A(java.util.Date.class) void m10() { }
}

View File

@ -0,0 +1,36 @@
/*
* 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 TestDeprecations {
/** @deprecated */
public int byComment;
@Deprecated
public int byAnno;
/** @deprecated */
public void byComment() { }
@Deprecated
public void byAnno() { }
/** @deprecated */
public static class ByComment { }
@Deprecated
public static class ByAnno { }
}

View File

@ -0,0 +1,36 @@
/*
* 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 enum TestEnum {
E1,
E2() {
@Override
public void m() { }
},
E3("-"),
E4("+") {
@Override
public void m() { }
};
public void m() { }
private String s;
private TestEnum() { this("?"); }
private TestEnum(@Deprecated String s) { this.s = s; }
}

View File

@ -0,0 +1,26 @@
/*
* 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 TestExtendsList {
static <T extends Comparable<? super T>> T m1(T t) {
return null;
}
static <T extends Object & Comparable<? super T>> T m2(T t) {
return null;
}
}

View File

@ -0,0 +1,40 @@
/*
* 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 TestMethodParameters {
TestMethodParameters(@Deprecated int p01) { }
void m1(@Deprecated int p02) { }
static void m2(@Deprecated int p03) { }
class C1 {
C1(@Deprecated int p11) { }
void m(@Deprecated int p12) { }
}
static class C2 {
C2(@Deprecated int p21) { }
void m1(@Deprecated int p22) { }
static void m2(@Deprecated int p23) { }
}
void local() {
class Local {
Local(@Deprecated int p31) { }
void m(@Deprecated int p32) { }
}
}
}