summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java53
-rw-r--r--src/test/java/cuchaz/enigma/TestDeobfed.java100
-rw-r--r--src/test/java/cuchaz/enigma/TestDeobfuscator.java41
-rw-r--r--src/test/java/cuchaz/enigma/TestEntryFactory.java49
-rw-r--r--src/test/java/cuchaz/enigma/TestInnerClasses.java85
-rw-r--r--src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java124
-rw-r--r--src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java227
-rw-r--r--src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java157
-rw-r--r--src/test/java/cuchaz/enigma/TestMethodDescriptor.java247
-rw-r--r--src/test/java/cuchaz/enigma/TestSourceIndex.java74
-rw-r--r--src/test/java/cuchaz/enigma/TestTokensConstructors.java137
-rw-r--r--src/test/java/cuchaz/enigma/TestTranslator.java155
-rw-r--r--src/test/java/cuchaz/enigma/TestTypeDescriptor.java243
-rw-r--r--src/test/java/cuchaz/enigma/TokenChecker.java65
-rw-r--r--src/test/java/cuchaz/enigma/command/CheckMappingsCommandTest.java20
-rw-r--r--src/test/java/cuchaz/enigma/inputs/Keep.java18
-rw-r--r--src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java26
-rw-r--r--src/test/java/cuchaz/enigma/inputs/constructors/Caller.java58
-rw-r--r--src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java16
-rw-r--r--src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java39
-rw-r--r--src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java22
-rw-r--r--src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java32
-rw-r--r--src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java22
-rw-r--r--src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java41
-rw-r--r--src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java35
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java25
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java24
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java31
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java19
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java32
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java30
-rw-r--r--src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java25
-rw-r--r--src/test/java/cuchaz/enigma/inputs/packageAccess/Base.java7
-rw-r--r--src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java12
-rw-r--r--src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java14
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java33
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java26
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java28
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java29
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java32
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java31
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java36
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java40
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java35
-rw-r--r--src/test/java/cuchaz/enigma/mapping/TestComments.java40
-rw-r--r--src/test/java/cuchaz/enigma/mapping/TestTinyV2InnerClasses.java41
-rw-r--r--src/test/java/cuchaz/enigma/mapping/TestV2Main.java24
-rw-r--r--src/test/java/cuchaz/enigma/resources/translation.mappings41
-rw-r--r--src/test/resources/comments/test.mapping18
-rw-r--r--src/test/resources/packageAccess/correctMappings/base/Base.mapping1
-rw-r--r--src/test/resources/packageAccess/correctMappings/base/One.mapping1
-rw-r--r--src/test/resources/packageAccess/correctMappings/two/Two.mapping1
-rw-r--r--src/test/resources/packageAccess/wrongMappings/base/Base.mapping1
-rw-r--r--src/test/resources/packageAccess/wrongMappings/one/One.mapping1
-rw-r--r--src/test/resources/packageAccess/wrongMappings/two/Two.mapping1
-rw-r--r--src/test/resources/proguard-build.conf6
-rw-r--r--src/test/resources/proguard-test.conf8
-rw-r--r--src/test/resources/tinyV2InnerClasses/c.mapping2
-rw-r--r--src/test/resources/tinyV2InnerClasses/cuchaz/enigma/Dad.mapping5
59 files changed, 0 insertions, 2786 deletions
diff --git a/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java b/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java
deleted file mode 100644
index 1dc9748..0000000
--- a/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.analysis.ClassCache;
15import cuchaz.enigma.analysis.index.JarIndex;
16import cuchaz.enigma.analysis.index.PackageVisibilityIndex;
17import cuchaz.enigma.translation.representation.entry.ClassEntry;
18import org.junit.Test;
19
20import java.nio.file.Paths;
21
22import static cuchaz.enigma.TestEntryFactory.newClass;
23import static org.hamcrest.MatcherAssert.assertThat;
24import static org.hamcrest.Matchers.contains;
25import static org.hamcrest.Matchers.containsInAnyOrder;
26
27public class PackageVisibilityIndexTest {
28
29 private static final ClassEntry KEEP = newClass("cuchaz/enigma/inputs/Keep");
30 private static final ClassEntry BASE = newClass("a");
31 private static final ClassEntry SAME_PACKAGE_CHILD = newClass("b");
32 private static final ClassEntry SAME_PACKAGE_CHILD_INNER = newClass("b$a");
33 private static final ClassEntry OTHER_PACKAGE_CHILD = newClass("c");
34 private static final ClassEntry OTHER_PACKAGE_CHILD_INNER = newClass("c$a");
35 private final JarIndex jarIndex;
36
37 public PackageVisibilityIndexTest() throws Exception {
38 ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/packageAccess.jar"));
39 jarIndex = classCache.index(ProgressListener.none());
40 }
41
42 @Test
43 public void test() {
44 PackageVisibilityIndex visibilityIndex = jarIndex.getPackageVisibilityIndex();
45 assertThat(visibilityIndex.getPartition(BASE), containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER));
46 System.out.println(visibilityIndex.getPartitions());
47 assertThat(visibilityIndex.getPartitions(), containsInAnyOrder(
48 containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER),
49 containsInAnyOrder(OTHER_PACKAGE_CHILD, OTHER_PACKAGE_CHILD_INNER),
50 contains(KEEP)
51 ));
52 }
53}
diff --git a/src/test/java/cuchaz/enigma/TestDeobfed.java b/src/test/java/cuchaz/enigma/TestDeobfed.java
deleted file mode 100644
index d64a745..0000000
--- a/src/test/java/cuchaz/enigma/TestDeobfed.java
+++ /dev/null
@@ -1,100 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.analysis.ClassCache;
15import cuchaz.enigma.analysis.index.JarIndex;
16import cuchaz.enigma.network.EnigmaServer;
17import cuchaz.enigma.source.Decompiler;
18import cuchaz.enigma.source.Decompilers;
19import cuchaz.enigma.source.SourceSettings;
20import org.junit.BeforeClass;
21import org.junit.Test;
22
23import java.nio.file.Paths;
24
25import static cuchaz.enigma.TestEntryFactory.newClass;
26import static org.hamcrest.MatcherAssert.assertThat;
27import static org.hamcrest.Matchers.containsInAnyOrder;
28
29public class TestDeobfed {
30
31 private static Enigma enigma;
32 private static ClassCache classCache;
33 private static JarIndex index;
34
35 @BeforeClass
36 public static void beforeClass() throws Exception {
37 enigma = Enigma.create();
38
39 classCache = ClassCache.of(Paths.get("build/test-deobf/translation.jar"));
40 index = classCache.index(ProgressListener.none());
41 }
42
43 @Test
44 public void obfEntries() {
45 assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(
46 newClass("cuchaz/enigma/inputs/Keep"),
47 newClass("a"),
48 newClass("b"),
49 newClass("c"),
50 newClass("d"),
51 newClass("d$1"),
52 newClass("e"),
53 newClass("f"),
54 newClass("g"),
55 newClass("g$a"),
56 newClass("g$a$a"),
57 newClass("g$b"),
58 newClass("g$b$a"),
59 newClass("h"),
60 newClass("h$a"),
61 newClass("h$a$a"),
62 newClass("h$b"),
63 newClass("h$b$a"),
64 newClass("h$b$a$a"),
65 newClass("h$b$a$b"),
66 newClass("i"),
67 newClass("i$a"),
68 newClass("i$b")
69 ));
70 }
71
72 @Test
73 public void decompile() {
74 EnigmaProject project = new EnigmaProject(enigma, classCache, index, new byte[EnigmaServer.CHECKSUM_SIZE]);
75 Decompiler decompiler = Decompilers.PROCYON.create(project.getClassCache(), new SourceSettings(false, false));
76
77 decompiler.getSource("a");
78 decompiler.getSource("b");
79 decompiler.getSource("c");
80 decompiler.getSource("d");
81 decompiler.getSource("d$1");
82 decompiler.getSource("e");
83 decompiler.getSource("f");
84 decompiler.getSource("g");
85 decompiler.getSource("g$a");
86 decompiler.getSource("g$a$a");
87 decompiler.getSource("g$b");
88 decompiler.getSource("g$b$a");
89 decompiler.getSource("h");
90 decompiler.getSource("h$a");
91 decompiler.getSource("h$a$a");
92 decompiler.getSource("h$b");
93 decompiler.getSource("h$b$a");
94 decompiler.getSource("h$b$a$a");
95 decompiler.getSource("h$b$a$b");
96 decompiler.getSource("i");
97 decompiler.getSource("i$a");
98 decompiler.getSource("i$b");
99 }
100}
diff --git a/src/test/java/cuchaz/enigma/TestDeobfuscator.java b/src/test/java/cuchaz/enigma/TestDeobfuscator.java
deleted file mode 100644
index 6619d26..0000000
--- a/src/test/java/cuchaz/enigma/TestDeobfuscator.java
+++ /dev/null
@@ -1,41 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.source.Decompiler;
15import cuchaz.enigma.source.Decompilers;
16import cuchaz.enigma.source.SourceSettings;
17import org.junit.Test;
18
19import java.io.IOException;
20import java.nio.file.Paths;
21
22public class TestDeobfuscator {
23 private EnigmaProject openProject() throws IOException {
24 Enigma enigma = Enigma.create();
25 return enigma.openJar(Paths.get("build/test-obf/loneClass.jar"), ProgressListener.none());
26 }
27
28 @Test
29 public void loadJar()
30 throws Exception {
31 openProject();
32 }
33
34 @Test
35 public void decompileClass() throws Exception {
36 EnigmaProject project = openProject();
37 Decompiler decompiler = Decompilers.PROCYON.create(project.getClassCache(), new SourceSettings(false, false));
38
39 decompiler.getSource("a").asString();
40 }
41}
diff --git a/src/test/java/cuchaz/enigma/TestEntryFactory.java b/src/test/java/cuchaz/enigma/TestEntryFactory.java
deleted file mode 100644
index 9e1425a..0000000
--- a/src/test/java/cuchaz/enigma/TestEntryFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.analysis.EntryReference;
15import cuchaz.enigma.translation.representation.*;
16import cuchaz.enigma.translation.representation.entry.ClassEntry;
17import cuchaz.enigma.translation.representation.entry.FieldEntry;
18import cuchaz.enigma.translation.representation.entry.MethodEntry;
19
20public class TestEntryFactory {
21
22 public static ClassEntry newClass(String name) {
23 return new ClassEntry(name);
24 }
25
26 public static FieldEntry newField(String className, String fieldName, String fieldType) {
27 return newField(newClass(className), fieldName, fieldType);
28 }
29
30 public static FieldEntry newField(ClassEntry classEntry, String fieldName, String fieldType) {
31 return new FieldEntry(classEntry, fieldName, new TypeDescriptor(fieldType));
32 }
33
34 public static MethodEntry newMethod(String className, String methodName, String methodSignature) {
35 return newMethod(newClass(className), methodName, methodSignature);
36 }
37
38 public static MethodEntry newMethod(ClassEntry classEntry, String methodName, String methodSignature) {
39 return new MethodEntry(classEntry, methodName, new MethodDescriptor(methodSignature));
40 }
41
42 public static EntryReference<FieldEntry, MethodEntry> newFieldReferenceByMethod(FieldEntry fieldEntry, String callerClassName, String callerName, String callerSignature) {
43 return new EntryReference<>(fieldEntry, "", newMethod(callerClassName, callerName, callerSignature));
44 }
45
46 public static EntryReference<MethodEntry, MethodEntry> newBehaviorReferenceByMethod(MethodEntry methodEntry, String callerClassName, String callerName, String callerSignature) {
47 return new EntryReference<>(methodEntry, "", newMethod(callerClassName, callerName, callerSignature));
48 }
49}
diff --git a/src/test/java/cuchaz/enigma/TestInnerClasses.java b/src/test/java/cuchaz/enigma/TestInnerClasses.java
deleted file mode 100644
index 85c72f8..0000000
--- a/src/test/java/cuchaz/enigma/TestInnerClasses.java
+++ /dev/null
@@ -1,85 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.analysis.ClassCache;
15import cuchaz.enigma.analysis.index.JarIndex;
16import cuchaz.enigma.source.Decompiler;
17import cuchaz.enigma.source.Decompilers;
18import cuchaz.enigma.source.SourceSettings;
19import cuchaz.enigma.translation.representation.entry.ClassEntry;
20import org.junit.Test;
21
22import java.nio.file.Paths;
23
24import static cuchaz.enigma.TestEntryFactory.newClass;
25import static org.hamcrest.MatcherAssert.assertThat;
26import static org.hamcrest.Matchers.is;
27
28public class TestInnerClasses {
29
30 private static final ClassEntry SimpleOuter = newClass("d");
31 private static final ClassEntry SimpleInner = newClass("d$a");
32 private static final ClassEntry ConstructorArgsOuter = newClass("c");
33 private static final ClassEntry ConstructorArgsInner = newClass("c$a");
34 private static final ClassEntry ClassTreeRoot = newClass("f");
35 private static final ClassEntry ClassTreeLevel1 = newClass("f$a");
36 private static final ClassEntry ClassTreeLevel2 = newClass("f$a$a");
37 private static final ClassEntry ClassTreeLevel3 = newClass("f$a$a$a");
38 private final JarIndex index;
39 private final Decompiler decompiler;
40
41 public TestInnerClasses() throws Exception {
42 ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/innerClasses.jar"));
43 index = classCache.index(ProgressListener.none());
44 decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false));
45 }
46
47 @Test
48 public void simple() {
49 decompile(SimpleOuter);
50 }
51
52 @Test
53 public void constructorArgs() {
54 decompile(ConstructorArgsOuter);
55 }
56
57 @Test
58 public void classTree() {
59
60 // root level
61 assertThat(index.getEntryIndex().hasClass(ClassTreeRoot), is(true));
62
63 // level 1
64 ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName()
65 + "$" + ClassTreeLevel1.getSimpleName());
66 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true));
67
68 // level 2
69 fullClassEntry = new ClassEntry(ClassTreeRoot.getName()
70 + "$" + ClassTreeLevel1.getSimpleName()
71 + "$" + ClassTreeLevel2.getSimpleName());
72 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true));
73
74 // level 3
75 fullClassEntry = new ClassEntry(ClassTreeRoot.getName()
76 + "$" + ClassTreeLevel1.getSimpleName()
77 + "$" + ClassTreeLevel2.getSimpleName()
78 + "$" + ClassTreeLevel3.getSimpleName());
79 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true));
80 }
81
82 private void decompile(ClassEntry classEntry) {
83 decompiler.getSource(classEntry.getName());
84 }
85}
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java
deleted file mode 100644
index 48975c8..0000000
--- a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java
+++ /dev/null
@@ -1,124 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.analysis.ClassCache;
15import cuchaz.enigma.analysis.EntryReference;
16import cuchaz.enigma.analysis.index.JarIndex;
17import cuchaz.enigma.translation.representation.entry.ClassEntry;
18import cuchaz.enigma.translation.representation.entry.MethodDefEntry;
19import cuchaz.enigma.translation.representation.entry.MethodEntry;
20import org.junit.Test;
21
22import java.nio.file.Paths;
23import java.util.Collection;
24
25import static cuchaz.enigma.TestEntryFactory.*;
26import static org.hamcrest.MatcherAssert.assertThat;
27import static org.hamcrest.Matchers.*;
28
29public class TestJarIndexConstructorReferences {
30
31 private JarIndex index;
32
33 private ClassEntry baseClass = newClass("a");
34 private ClassEntry subClass = newClass("d");
35 private ClassEntry subsubClass = newClass("e");
36 private ClassEntry defaultClass = newClass("c");
37 private ClassEntry callerClass = newClass("b");
38
39 public TestJarIndexConstructorReferences() throws Exception {
40 ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/constructors.jar"));
41 index = classCache.index(ProgressListener.none());
42 }
43
44 @Test
45 public void obfEntries() {
46 assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass,
47 subClass, subsubClass, defaultClass, callerClass));
48 }
49
50 @Test
51 @SuppressWarnings("unchecked")
52 public void baseDefault() {
53 MethodEntry source = newMethod(baseClass, "<init>", "()V");
54 Collection<EntryReference<MethodEntry, MethodDefEntry>> references = index.getReferenceIndex().getReferencesToMethod(source);
55 assertThat(references, containsInAnyOrder(
56 newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"),
57 newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "()V"),
58 newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(III)V")
59 ));
60 }
61
62 @Test
63 @SuppressWarnings("unchecked")
64 public void baseInt() {
65 MethodEntry source = newMethod(baseClass, "<init>", "(I)V");
66 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(
67 newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V")
68 ));
69 }
70
71 @Test
72 @SuppressWarnings("unchecked")
73 public void subDefault() {
74 MethodEntry source = newMethod(subClass, "<init>", "()V");
75 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(
76 newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"),
77 newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(I)V")
78 ));
79 }
80
81 @Test
82 @SuppressWarnings("unchecked")
83 public void subInt() {
84 MethodEntry source = newMethod(subClass, "<init>", "(I)V");
85 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(
86 newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"),
87 newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(II)V"),
88 newBehaviorReferenceByMethod(source, subsubClass.getName(), "<init>", "(I)V")
89 ));
90 }
91
92 @Test
93 @SuppressWarnings("unchecked")
94 public void subIntInt() {
95 MethodEntry source = newMethod(subClass, "<init>", "(II)V");
96 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(
97 newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V")
98 ));
99 }
100
101 @Test
102 public void subIntIntInt() {
103 MethodEntry source = newMethod(subClass, "<init>", "(III)V");
104 assertThat(index.getReferenceIndex().getReferencesToMethod(source), is(empty()));
105 }
106
107 @Test
108 @SuppressWarnings("unchecked")
109 public void subsubInt() {
110 MethodEntry source = newMethod(subsubClass, "<init>", "(I)V");
111 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(
112 newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V")
113 ));
114 }
115
116 @Test
117 @SuppressWarnings("unchecked")
118 public void defaultConstructable() {
119 MethodEntry source = newMethod(defaultClass, "<init>", "()V");
120 assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(
121 newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V")
122 ));
123 }
124}
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java b/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java
deleted file mode 100644
index 76e379c..0000000
--- a/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java
+++ /dev/null
@@ -1,227 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.analysis.ClassCache;
15import cuchaz.enigma.analysis.EntryReference;
16import cuchaz.enigma.analysis.index.EntryIndex;
17import cuchaz.enigma.analysis.index.InheritanceIndex;
18import cuchaz.enigma.analysis.index.JarIndex;
19import cuchaz.enigma.translation.mapping.EntryResolver;
20import cuchaz.enigma.translation.mapping.IndexEntryResolver;
21import cuchaz.enigma.translation.representation.AccessFlags;
22import cuchaz.enigma.translation.representation.entry.ClassEntry;
23import cuchaz.enigma.translation.representation.entry.FieldEntry;
24import cuchaz.enigma.translation.representation.entry.MethodDefEntry;
25import cuchaz.enigma.translation.representation.entry.MethodEntry;
26import org.junit.Test;
27import org.objectweb.asm.Opcodes;
28
29import java.nio.file.Paths;
30import java.util.Collection;
31
32import static cuchaz.enigma.TestEntryFactory.*;
33import static org.hamcrest.MatcherAssert.assertThat;
34import static org.hamcrest.Matchers.*;
35
36public class TestJarIndexInheritanceTree {
37
38 private JarIndex index;
39
40 private ClassEntry baseClass = newClass("a");
41 private ClassEntry subClassA = newClass("b");
42 private ClassEntry subClassAA = newClass("d");
43 private ClassEntry subClassB = newClass("c");
44 private FieldEntry nameField = newField(baseClass, "a", "Ljava/lang/String;");
45 private FieldEntry numThingsField = newField(subClassB, "a", "I");
46
47 public TestJarIndexInheritanceTree()
48 throws Exception {
49 ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/inheritanceTree.jar"));
50 index = classCache.index(ProgressListener.none());
51 }
52
53 @Test
54 public void obfEntries() {
55 assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(
56 newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB
57 ));
58 }
59
60 @Test
61 public void translationIndex() {
62
63 InheritanceIndex index = this.index.getInheritanceIndex();
64
65 // base class
66 assertThat(index.getParents(baseClass), is(empty()));
67 assertThat(index.getAncestors(baseClass), is(empty()));
68 assertThat(index.getChildren(baseClass), containsInAnyOrder(subClassA, subClassB
69 ));
70
71 // subclass a
72 assertThat(index.getParents(subClassA), contains(baseClass));
73 assertThat(index.getAncestors(subClassA), containsInAnyOrder(baseClass));
74 assertThat(index.getChildren(subClassA), contains(subClassAA));
75
76 // subclass aa
77 assertThat(index.getParents(subClassAA), contains(subClassA));
78 assertThat(index.getAncestors(subClassAA), containsInAnyOrder(subClassA, baseClass));
79 assertThat(index.getChildren(subClassAA), is(empty()));
80
81 // subclass b
82 assertThat(index.getParents(subClassB), contains(baseClass));
83 assertThat(index.getAncestors(subClassB), containsInAnyOrder(baseClass));
84 assertThat(index.getChildren(subClassB), is(empty()));
85 }
86
87 @Test
88 public void access() {
89 assertThat(index.getEntryIndex().getFieldAccess(nameField), is(new AccessFlags(Opcodes.ACC_PRIVATE)));
90 assertThat(index.getEntryIndex().getFieldAccess(numThingsField), is(new AccessFlags(Opcodes.ACC_PRIVATE)));
91 }
92
93 @Test
94 public void relatedMethodImplementations() {
95
96 Collection<MethodEntry> entries;
97
98 EntryResolver resolver = new IndexEntryResolver(index);
99 // getName()
100 entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()Ljava/lang/String;"));
101 assertThat(entries, containsInAnyOrder(
102 newMethod(baseClass, "a", "()Ljava/lang/String;"),
103 newMethod(subClassAA, "a", "()Ljava/lang/String;")
104 ));
105 entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()Ljava/lang/String;"));
106 assertThat(entries, containsInAnyOrder(
107 newMethod(baseClass, "a", "()Ljava/lang/String;"),
108 newMethod(subClassAA, "a", "()Ljava/lang/String;")
109 ));
110
111 // doBaseThings()
112 entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()V"));
113 assertThat(entries, containsInAnyOrder(
114 newMethod(baseClass, "a", "()V"),
115 newMethod(subClassAA, "a", "()V"),
116 newMethod(subClassB, "a", "()V")
117 ));
118 entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()V"));
119 assertThat(entries, containsInAnyOrder(
120 newMethod(baseClass, "a", "()V"),
121 newMethod(subClassAA, "a", "()V"),
122 newMethod(subClassB, "a", "()V")
123 ));
124 entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "a", "()V"));
125 assertThat(entries, containsInAnyOrder(
126 newMethod(baseClass, "a", "()V"),
127 newMethod(subClassAA, "a", "()V"),
128 newMethod(subClassB, "a", "()V")
129 ));
130
131 // doBThings
132 entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "b", "()V"));
133 assertThat(entries, containsInAnyOrder(newMethod(subClassB, "b", "()V")));
134 }
135
136 @Test
137 @SuppressWarnings("unchecked")
138 public void fieldReferences() {
139 Collection<EntryReference<FieldEntry, MethodDefEntry>> references;
140
141 // name
142 references = index.getReferenceIndex().getReferencesToField(nameField);
143 assertThat(references, containsInAnyOrder(
144 newFieldReferenceByMethod(nameField, baseClass.getName(), "<init>", "(Ljava/lang/String;)V"),
145 newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;")
146 ));
147
148 // numThings
149 references = index.getReferenceIndex().getReferencesToField(numThingsField);
150 assertThat(references, containsInAnyOrder(
151 newFieldReferenceByMethod(numThingsField, subClassB.getName(), "<init>", "()V"),
152 newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V")
153 ));
154 }
155
156 @Test
157 @SuppressWarnings("unchecked")
158 public void behaviorReferences() {
159
160 MethodEntry source;
161 Collection<EntryReference<MethodEntry, MethodDefEntry>> references;
162
163 // baseClass constructor
164 source = newMethod(baseClass, "<init>", "(Ljava/lang/String;)V");
165 references = index.getReferenceIndex().getReferencesToMethod(source);
166 assertThat(references, containsInAnyOrder(
167 newBehaviorReferenceByMethod(source, subClassA.getName(), "<init>", "(Ljava/lang/String;)V"),
168 newBehaviorReferenceByMethod(source, subClassB.getName(), "<init>", "()V")
169 ));
170
171 // subClassA constructor
172 source = newMethod(subClassA, "<init>", "(Ljava/lang/String;)V");
173 references = index.getReferenceIndex().getReferencesToMethod(source);
174 assertThat(references, containsInAnyOrder(
175 newBehaviorReferenceByMethod(source, subClassAA.getName(), "<init>", "()V")
176 ));
177
178 // baseClass.getName()
179 source = newMethod(baseClass, "a", "()Ljava/lang/String;");
180 references = index.getReferenceIndex().getReferencesToMethod(source);
181 assertThat(references, containsInAnyOrder(
182 newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()Ljava/lang/String;"),
183 newBehaviorReferenceByMethod(source, subClassB.getName(), "a", "()V")
184 ));
185
186 // subclassAA.getName()
187 source = newMethod(subClassAA, "a", "()Ljava/lang/String;");
188 references = index.getReferenceIndex().getReferencesToMethod(source);
189 assertThat(references, containsInAnyOrder(
190 newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V")
191 ));
192 }
193
194 @Test
195 public void containsEntries() {
196 EntryIndex entryIndex = index.getEntryIndex();
197 // classes
198 assertThat(entryIndex.hasClass(baseClass), is(true));
199 assertThat(entryIndex.hasClass(subClassA), is(true));
200 assertThat(entryIndex.hasClass(subClassAA), is(true));
201 assertThat(entryIndex.hasClass(subClassB), is(true));
202
203 // fields
204 assertThat(entryIndex.hasField(nameField), is(true));
205 assertThat(entryIndex.hasField(numThingsField), is(true));
206
207 // methods
208 // getName()
209 assertThat(entryIndex.hasMethod(newMethod(baseClass, "a", "()Ljava/lang/String;")), is(true));
210 assertThat(entryIndex.hasMethod(newMethod(subClassA, "a", "()Ljava/lang/String;")), is(false));
211 assertThat(entryIndex.hasMethod(newMethod(subClassAA, "a", "()Ljava/lang/String;")), is(true));
212 assertThat(entryIndex.hasMethod(newMethod(subClassB, "a", "()Ljava/lang/String;")), is(false));
213
214 // doBaseThings()
215 assertThat(entryIndex.hasMethod(newMethod(baseClass, "a", "()V")), is(true));
216 assertThat(entryIndex.hasMethod(newMethod(subClassA, "a", "()V")), is(false));
217 assertThat(entryIndex.hasMethod(newMethod(subClassAA, "a", "()V")), is(true));
218 assertThat(entryIndex.hasMethod(newMethod(subClassB, "a", "()V")), is(true));
219
220 // doBThings()
221 assertThat(entryIndex.hasMethod(newMethod(baseClass, "b", "()V")), is(false));
222 assertThat(entryIndex.hasMethod(newMethod(subClassA, "b", "()V")), is(false));
223 assertThat(entryIndex.hasMethod(newMethod(subClassAA, "b", "()V")), is(false));
224 assertThat(entryIndex.hasMethod(newMethod(subClassB, "b", "()V")), is(true));
225
226 }
227}
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java b/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java
deleted file mode 100644
index 103c366..0000000
--- a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java
+++ /dev/null
@@ -1,157 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.analysis.*;
15import cuchaz.enigma.analysis.index.EntryIndex;
16import cuchaz.enigma.analysis.index.InheritanceIndex;
17import cuchaz.enigma.analysis.index.JarIndex;
18import cuchaz.enigma.translation.VoidTranslator;
19import cuchaz.enigma.translation.representation.AccessFlags;
20import cuchaz.enigma.translation.representation.entry.ClassEntry;
21import cuchaz.enigma.translation.representation.entry.FieldEntry;
22import cuchaz.enigma.translation.representation.entry.MethodDefEntry;
23import cuchaz.enigma.translation.representation.entry.MethodEntry;
24import org.junit.Test;
25
26import java.nio.file.Paths;
27import java.util.Collection;
28import java.util.List;
29
30import static cuchaz.enigma.TestEntryFactory.*;
31import static org.hamcrest.MatcherAssert.assertThat;
32import static org.hamcrest.Matchers.*;
33
34public class TestJarIndexLoneClass {
35
36 private JarIndex index;
37
38 public TestJarIndexLoneClass() throws Exception {
39 ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/loneClass.jar"));
40 index = classCache.index(ProgressListener.none());
41 }
42
43 @Test
44 public void obfEntries() {
45 assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(
46 newClass("cuchaz/enigma/inputs/Keep"),
47 newClass("a")
48 ));
49 }
50
51 @Test
52 public void translationIndex() {
53 InheritanceIndex inheritanceIndex = index.getInheritanceIndex();
54 assertThat(inheritanceIndex.getParents(new ClassEntry("a")), is(empty()));
55 assertThat(inheritanceIndex.getParents(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty()));
56 assertThat(inheritanceIndex.getAncestors(new ClassEntry("a")), is(empty()));
57 assertThat(inheritanceIndex.getAncestors(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty()));
58 assertThat(inheritanceIndex.getChildren(new ClassEntry("a")), is(empty()));
59 assertThat(inheritanceIndex.getChildren(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty()));
60 }
61
62 @Test
63 public void access() {
64 EntryIndex entryIndex = index.getEntryIndex();
65 assertThat(entryIndex.getFieldAccess(newField("a", "a", "Ljava/lang/String;")), is(AccessFlags.PRIVATE));
66 assertThat(entryIndex.getMethodAccess(newMethod("a", "a", "()Ljava/lang/String;")), is(AccessFlags.PUBLIC));
67 assertThat(entryIndex.getFieldAccess(newField("a", "b", "Ljava/lang/String;")), is(nullValue()));
68 assertThat(entryIndex.getFieldAccess(newField("a", "a", "LFoo;")), is(nullValue()));
69 }
70
71 @Test
72 public void classInheritance() {
73 IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index);
74 ClassInheritanceTreeNode node = treeBuilder.buildClassInheritance(VoidTranslator.INSTANCE, newClass("a"));
75 assertThat(node, is(not(nullValue())));
76 assertThat(node.getObfClassName(), is("a"));
77 assertThat(node.getChildCount(), is(0));
78 }
79
80 @Test
81 public void methodInheritance() {
82 IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index);
83 MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;");
84 MethodInheritanceTreeNode node = treeBuilder.buildMethodInheritance(VoidTranslator.INSTANCE, source);
85 assertThat(node, is(not(nullValue())));
86 assertThat(node.getMethodEntry(), is(source));
87 assertThat(node.getChildCount(), is(0));
88 }
89
90 @Test
91 public void classImplementations() {
92 IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index);
93 ClassImplementationsTreeNode node = treeBuilder.buildClassImplementations(VoidTranslator.INSTANCE, newClass("a"));
94 assertThat(node, is(nullValue()));
95 }
96
97 @Test
98 public void methodImplementations() {
99 IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index);
100 MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;");
101
102 List<MethodImplementationsTreeNode> nodes = treeBuilder.buildMethodImplementations(VoidTranslator.INSTANCE, source);
103 assertThat(nodes, hasSize(1));
104 assertThat(nodes.get(0).getMethodEntry(), is(source));
105 }
106
107 @Test
108 public void relatedMethodImplementations() {
109 Collection<MethodEntry> entries = index.getEntryResolver().resolveEquivalentMethods(newMethod("a", "a", "()Ljava/lang/String;"));
110 assertThat(entries, containsInAnyOrder(
111 newMethod("a", "a", "()Ljava/lang/String;")
112 ));
113 }
114
115 @Test
116 @SuppressWarnings("unchecked")
117 public void fieldReferences() {
118 FieldEntry source = newField("a", "a", "Ljava/lang/String;");
119 Collection<EntryReference<FieldEntry, MethodDefEntry>> references = index.getReferenceIndex().getReferencesToField(source);
120 assertThat(references, containsInAnyOrder(
121 newFieldReferenceByMethod(source, "a", "<init>", "(Ljava/lang/String;)V"),
122 newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;")
123 ));
124 }
125
126 @Test
127 public void behaviorReferences() {
128 assertThat(index.getReferenceIndex().getReferencesToMethod(newMethod("a", "a", "()Ljava/lang/String;")), is(empty()));
129 }
130
131 @Test
132 public void interfaces() {
133 assertThat(index.getInheritanceIndex().getParents(new ClassEntry("a")), is(empty()));
134 }
135
136 @Test
137 public void implementingClasses() {
138 assertThat(index.getInheritanceIndex().getChildren(new ClassEntry("a")), is(empty()));
139 }
140
141 @Test
142 public void isInterface() {
143 assertThat(index.getInheritanceIndex().isParent(new ClassEntry("a")), is(false));
144 }
145
146 @Test
147 public void testContains() {
148 EntryIndex entryIndex = index.getEntryIndex();
149 assertThat(entryIndex.hasClass(newClass("a")), is(true));
150 assertThat(entryIndex.hasClass(newClass("b")), is(false));
151 assertThat(entryIndex.hasField(newField("a", "a", "Ljava/lang/String;")), is(true));
152 assertThat(entryIndex.hasField(newField("a", "b", "Ljava/lang/String;")), is(false));
153 assertThat(entryIndex.hasField(newField("a", "a", "LFoo;")), is(false));
154 assertThat(entryIndex.hasMethod(newMethod("a", "a", "()Ljava/lang/String;")), is(true));
155 assertThat(entryIndex.hasMethod(newMethod("a", "b", "()Ljava/lang/String;")), is(false));
156 }
157}
diff --git a/src/test/java/cuchaz/enigma/TestMethodDescriptor.java b/src/test/java/cuchaz/enigma/TestMethodDescriptor.java
deleted file mode 100644
index a73880d..0000000
--- a/src/test/java/cuchaz/enigma/TestMethodDescriptor.java
+++ /dev/null
@@ -1,247 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.translation.representation.MethodDescriptor;
15import cuchaz.enigma.translation.representation.TypeDescriptor;
16import org.junit.Test;
17
18import static org.hamcrest.MatcherAssert.assertThat;
19import static org.hamcrest.Matchers.*;
20
21public class TestMethodDescriptor {
22
23 @Test
24 public void easiest() {
25 final MethodDescriptor sig = new MethodDescriptor("()V");
26 assertThat(sig.getArgumentDescs(), is(empty()));
27 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
28 }
29
30 @Test
31 public void primitives() {
32 {
33 final MethodDescriptor sig = new MethodDescriptor("(I)V");
34 assertThat(sig.getArgumentDescs(), contains(
35 new TypeDescriptor("I")
36 ));
37 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
38 }
39 {
40 final MethodDescriptor sig = new MethodDescriptor("(I)I");
41 assertThat(sig.getArgumentDescs(), contains(
42 new TypeDescriptor("I")
43 ));
44 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("I")));
45 }
46 {
47 final MethodDescriptor sig = new MethodDescriptor("(IBCJ)Z");
48 assertThat(sig.getArgumentDescs(), contains(
49 new TypeDescriptor("I"),
50 new TypeDescriptor("B"),
51 new TypeDescriptor("C"),
52 new TypeDescriptor("J")
53 ));
54 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z")));
55 }
56 }
57
58 @Test
59 public void classes() {
60 {
61 final MethodDescriptor sig = new MethodDescriptor("([LFoo;)V");
62 assertThat(sig.getArgumentDescs().size(), is(1));
63 assertThat(sig.getArgumentDescs().get(0), is(new TypeDescriptor("[LFoo;")));
64 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
65 }
66 {
67 final MethodDescriptor sig = new MethodDescriptor("(LFoo;)LBar;");
68 assertThat(sig.getArgumentDescs(), contains(
69 new TypeDescriptor("LFoo;")
70 ));
71 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;")));
72 }
73 {
74 final MethodDescriptor sig = new MethodDescriptor("(LFoo;LMoo;LZoo;)LBar;");
75 assertThat(sig.getArgumentDescs(), contains(
76 new TypeDescriptor("LFoo;"),
77 new TypeDescriptor("LMoo;"),
78 new TypeDescriptor("LZoo;")
79 ));
80 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;")));
81 }
82 }
83
84 @Test
85 public void arrays() {
86 {
87 final MethodDescriptor sig = new MethodDescriptor("([I)V");
88 assertThat(sig.getArgumentDescs(), contains(
89 new TypeDescriptor("[I")
90 ));
91 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
92 }
93 {
94 final MethodDescriptor sig = new MethodDescriptor("([I)[J");
95 assertThat(sig.getArgumentDescs(), contains(
96 new TypeDescriptor("[I")
97 ));
98 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[J")));
99 }
100 {
101 final MethodDescriptor sig = new MethodDescriptor("([I[Z[F)[D");
102 assertThat(sig.getArgumentDescs(), contains(
103 new TypeDescriptor("[I"),
104 new TypeDescriptor("[Z"),
105 new TypeDescriptor("[F")
106 ));
107 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[D")));
108 }
109 }
110
111 @Test
112 public void mixed() {
113 {
114 final MethodDescriptor sig = new MethodDescriptor("(I[JLFoo;)Z");
115 assertThat(sig.getArgumentDescs(), contains(
116 new TypeDescriptor("I"),
117 new TypeDescriptor("[J"),
118 new TypeDescriptor("LFoo;")
119 ));
120 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z")));
121 }
122 {
123 final MethodDescriptor sig = new MethodDescriptor("(III)[LFoo;");
124 assertThat(sig.getArgumentDescs(), contains(
125 new TypeDescriptor("I"),
126 new TypeDescriptor("I"),
127 new TypeDescriptor("I")
128 ));
129 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[LFoo;")));
130 }
131 }
132
133 @Test
134 public void replaceClasses() {
135 {
136 final MethodDescriptor oldSig = new MethodDescriptor("()V");
137 final MethodDescriptor sig = oldSig.remap(s -> null);
138 assertThat(sig.getArgumentDescs(), is(empty()));
139 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
140 }
141 {
142 final MethodDescriptor oldSig = new MethodDescriptor("(IJLFoo;)V");
143 final MethodDescriptor sig = oldSig.remap(s -> null);
144 assertThat(sig.getArgumentDescs(), contains(
145 new TypeDescriptor("I"),
146 new TypeDescriptor("J"),
147 new TypeDescriptor("LFoo;")
148 ));
149 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V")));
150 }
151 {
152 final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;");
153 final MethodDescriptor sig = oldSig.remap(s -> {
154 if (s.equals("Foo")) {
155 return "Bar";
156 }
157 return null;
158 });
159 assertThat(sig.getArgumentDescs(), contains(
160 new TypeDescriptor("LBar;"),
161 new TypeDescriptor("LBar;")
162 ));
163 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LMoo;")));
164 }
165 {
166 final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;");
167 final MethodDescriptor sig = oldSig.remap(s -> {
168 if (s.equals("Moo")) {
169 return "Cow";
170 }
171 return null;
172 });
173 assertThat(sig.getArgumentDescs(), contains(
174 new TypeDescriptor("LFoo;"),
175 new TypeDescriptor("LBar;")
176 ));
177 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LCow;")));
178 }
179 }
180
181 @Test
182 public void replaceArrayClasses() {
183 {
184 final MethodDescriptor oldSig = new MethodDescriptor("([LFoo;)[[[LBar;");
185 final MethodDescriptor sig = oldSig.remap(s -> {
186 if (s.equals("Foo")) {
187 return "Food";
188 } else if (s.equals("Bar")) {
189 return "Beer";
190 }
191 return null;
192 });
193 assertThat(sig.getArgumentDescs(), contains(
194 new TypeDescriptor("[LFood;")
195 ));
196 assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[[[LBeer;")));
197 }
198 }
199
200 @Test
201 public void equals() {
202
203 // base
204 assertThat(new MethodDescriptor("()V"), is(new MethodDescriptor("()V")));
205
206 // arguments
207 assertThat(new MethodDescriptor("(I)V"), is(new MethodDescriptor("(I)V")));
208 assertThat(new MethodDescriptor("(ZIZ)V"), is(new MethodDescriptor("(ZIZ)V")));
209 assertThat(new MethodDescriptor("(LFoo;)V"), is(new MethodDescriptor("(LFoo;)V")));
210 assertThat(new MethodDescriptor("(LFoo;LBar;)V"), is(new MethodDescriptor("(LFoo;LBar;)V")));
211 assertThat(new MethodDescriptor("([I)V"), is(new MethodDescriptor("([I)V")));
212 assertThat(new MethodDescriptor("([[D[[[J)V"), is(new MethodDescriptor("([[D[[[J)V")));
213
214 assertThat(new MethodDescriptor("()V"), is(not(new MethodDescriptor("(I)V"))));
215 assertThat(new MethodDescriptor("(I)V"), is(not(new MethodDescriptor("()V"))));
216 assertThat(new MethodDescriptor("(IJ)V"), is(not(new MethodDescriptor("(JI)V"))));
217 assertThat(new MethodDescriptor("([[Z)V"), is(not(new MethodDescriptor("([[LFoo;)V"))));
218 assertThat(new MethodDescriptor("(LFoo;LBar;)V"), is(not(new MethodDescriptor("(LFoo;LCow;)V"))));
219 assertThat(new MethodDescriptor("([LFoo;LBar;)V"), is(not(new MethodDescriptor("(LFoo;LCow;)V"))));
220
221 // return desc
222 assertThat(new MethodDescriptor("()I"), is(new MethodDescriptor("()I")));
223 assertThat(new MethodDescriptor("()Z"), is(new MethodDescriptor("()Z")));
224 assertThat(new MethodDescriptor("()[D"), is(new MethodDescriptor("()[D")));
225 assertThat(new MethodDescriptor("()[[[Z"), is(new MethodDescriptor("()[[[Z")));
226 assertThat(new MethodDescriptor("()LFoo;"), is(new MethodDescriptor("()LFoo;")));
227 assertThat(new MethodDescriptor("()[LFoo;"), is(new MethodDescriptor("()[LFoo;")));
228
229 assertThat(new MethodDescriptor("()I"), is(not(new MethodDescriptor("()Z"))));
230 assertThat(new MethodDescriptor("()Z"), is(not(new MethodDescriptor("()I"))));
231 assertThat(new MethodDescriptor("()[D"), is(not(new MethodDescriptor("()[J"))));
232 assertThat(new MethodDescriptor("()[[[Z"), is(not(new MethodDescriptor("()[[Z"))));
233 assertThat(new MethodDescriptor("()LFoo;"), is(not(new MethodDescriptor("()LBar;"))));
234 assertThat(new MethodDescriptor("()[LFoo;"), is(not(new MethodDescriptor("()[LBar;"))));
235 }
236
237 @Test
238 public void testToString() {
239 assertThat(new MethodDescriptor("()V").toString(), is("()V"));
240 assertThat(new MethodDescriptor("(I)V").toString(), is("(I)V"));
241 assertThat(new MethodDescriptor("(ZIZ)V").toString(), is("(ZIZ)V"));
242 assertThat(new MethodDescriptor("(LFoo;)V").toString(), is("(LFoo;)V"));
243 assertThat(new MethodDescriptor("(LFoo;LBar;)V").toString(), is("(LFoo;LBar;)V"));
244 assertThat(new MethodDescriptor("([I)V").toString(), is("([I)V"));
245 assertThat(new MethodDescriptor("([[D[[[J)V").toString(), is("([[D[[[J)V"));
246 }
247}
diff --git a/src/test/java/cuchaz/enigma/TestSourceIndex.java b/src/test/java/cuchaz/enigma/TestSourceIndex.java
deleted file mode 100644
index b201608..0000000
--- a/src/test/java/cuchaz/enigma/TestSourceIndex.java
+++ /dev/null
@@ -1,74 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import com.google.common.collect.Sets;
15import cuchaz.enigma.analysis.ClassCache;
16import cuchaz.enigma.source.*;
17import cuchaz.enigma.analysis.index.JarIndex;
18import cuchaz.enigma.translation.representation.entry.ClassEntry;
19import org.junit.Test;
20
21import java.nio.file.Path;
22import java.nio.file.Paths;
23import java.util.Set;
24
25public class TestSourceIndex {
26 @Test
27 public void indexEverything()
28 throws Exception {
29 // Figure out where Minecraft is...
30 final String mcDir = System.getProperty("enigma.test.minecraftdir");
31 Path mcJar = null;
32 if (mcDir == null) {
33 String osname = System.getProperty("os.name").toLowerCase();
34 if (osname.contains("nix") || osname.contains("nux") || osname.contains("solaris")) {
35 mcJar = Paths.get(System.getProperty("user.home"), ".minecraft/versions/1.8.3/1.8.3.jar");
36 } else if (osname.contains("mac") || osname.contains("darwin")) {
37 mcJar = Paths.get(System.getProperty("user.home"), "Library/Application Support/minecraft/versions/1.8.3/1.8.3.jar");
38 } else if (osname.contains("win")) {
39 mcJar = Paths.get(System.getenv("AppData"), ".minecraft/versions/1.8.3/1.8.3.jar");
40 }
41 } else {
42 mcJar = Paths.get(mcDir, "versions/1.8.3/1.8.3.jar");
43 }
44
45 if (mcJar == null) {
46 throw new NullPointerException("Couldn't find jar");
47 }
48
49 Enigma enigma = Enigma.create();
50 EnigmaProject project = enigma.openJar(mcJar, ProgressListener.none());
51
52 ClassCache classCache = project.getClassCache();
53 JarIndex index = project.getJarIndex();
54
55 Decompiler decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false));
56
57 // get all classes that aren't inner classes
58 Set<ClassEntry> classEntries = Sets.newHashSet();
59 for (ClassEntry obfClassEntry : index.getEntryIndex().getClasses()) {
60 if (!obfClassEntry.isInnerClass()) {
61 classEntries.add(obfClassEntry);
62 }
63 }
64
65 for (ClassEntry obfClassEntry : classEntries) {
66 try {
67 Source source = decompiler.getSource(obfClassEntry.getName());
68 source.index();
69 } catch (Throwable t) {
70 throw new Error("Unable to index " + obfClassEntry, t);
71 }
72 }
73 }
74}
diff --git a/src/test/java/cuchaz/enigma/TestTokensConstructors.java b/src/test/java/cuchaz/enigma/TestTokensConstructors.java
deleted file mode 100644
index 0398de4..0000000
--- a/src/test/java/cuchaz/enigma/TestTokensConstructors.java
+++ /dev/null
@@ -1,137 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.translation.representation.entry.MethodEntry;
15import org.junit.Test;
16
17import java.nio.file.Paths;
18
19import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
20import static cuchaz.enigma.TestEntryFactory.newMethod;
21import static org.hamcrest.MatcherAssert.assertThat;
22import static org.hamcrest.Matchers.*;
23
24public class TestTokensConstructors extends TokenChecker {
25
26 public TestTokensConstructors()
27 throws Exception {
28 super(Paths.get("build/test-obf/constructors.jar"));
29 }
30
31 @Test
32 public void baseDeclarations() {
33 assertThat(getDeclarationToken(newMethod("a", "<init>", "()V")), is("a"));
34 assertThat(getDeclarationToken(newMethod("a", "<init>", "(I)V")), is("a"));
35 }
36
37 @Test
38 public void subDeclarations() {
39 assertThat(getDeclarationToken(newMethod("d", "<init>", "()V")), is("d"));
40 assertThat(getDeclarationToken(newMethod("d", "<init>", "(I)V")), is("d"));
41 assertThat(getDeclarationToken(newMethod("d", "<init>", "(II)V")), is("d"));
42 assertThat(getDeclarationToken(newMethod("d", "<init>", "(III)V")), is("d"));
43 }
44
45 @Test
46 public void subsubDeclarations() {
47 assertThat(getDeclarationToken(newMethod("e", "<init>", "(I)V")), is("e"));
48 }
49
50 @Test
51 public void defaultDeclarations() {
52 assertThat(getDeclarationToken(newMethod("c", "<init>", "()V")), nullValue());
53 }
54
55 @Test
56 public void baseDefaultReferences() {
57 MethodEntry source = newMethod("a", "<init>", "()V");
58 assertThat(
59 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "a", "()V")),
60 containsInAnyOrder("a")
61 );
62 assertThat(
63 getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "()V")),
64 is(empty()) // implicit call, not decompiled to token
65 );
66 assertThat(
67 getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(III)V")),
68 is(empty()) // implicit call, not decompiled to token
69 );
70 }
71
72 @Test
73 public void baseIntReferences() {
74 MethodEntry source = newMethod("a", "<init>", "(I)V");
75 assertThat(
76 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "b", "()V")),
77 containsInAnyOrder("a")
78 );
79 }
80
81 @Test
82 public void subDefaultReferences() {
83 MethodEntry source = newMethod("d", "<init>", "()V");
84 assertThat(
85 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "c", "()V")),
86 containsInAnyOrder("d")
87 );
88 assertThat(
89 getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(I)V")),
90 containsInAnyOrder("this")
91 );
92 }
93
94 @Test
95 public void subIntReferences() {
96 MethodEntry source = newMethod("d", "<init>", "(I)V");
97 assertThat(getReferenceTokens(
98 newBehaviorReferenceByMethod(source, "b", "d", "()V")),
99 containsInAnyOrder("d")
100 );
101 assertThat(getReferenceTokens(
102 newBehaviorReferenceByMethod(source, "d", "<init>", "(II)V")),
103 containsInAnyOrder("this")
104 );
105 assertThat(getReferenceTokens(
106 newBehaviorReferenceByMethod(source, "e", "<init>", "(I)V")),
107 containsInAnyOrder("super")
108 );
109 }
110
111 @Test
112 public void subIntIntReferences() {
113 MethodEntry source = newMethod("d", "<init>", "(II)V");
114 assertThat(
115 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "e", "()V")),
116 containsInAnyOrder("d")
117 );
118 }
119
120 @Test
121 public void subsubIntReferences() {
122 MethodEntry source = newMethod("e", "<init>", "(I)V");
123 assertThat(
124 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "f", "()V")),
125 containsInAnyOrder("e")
126 );
127 }
128
129 @Test
130 public void defaultConstructableReferences() {
131 MethodEntry source = newMethod("c", "<init>", "()V");
132 assertThat(
133 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "g", "()V")),
134 containsInAnyOrder("c")
135 );
136 }
137}
diff --git a/src/test/java/cuchaz/enigma/TestTranslator.java b/src/test/java/cuchaz/enigma/TestTranslator.java
deleted file mode 100644
index a420afe..0000000
--- a/src/test/java/cuchaz/enigma/TestTranslator.java
+++ /dev/null
@@ -1,155 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.translation.representation.entry.Entry;
15import org.junit.BeforeClass;
16import org.junit.Test;
17
18import static cuchaz.enigma.TestEntryFactory.*;
19
20public class TestTranslator {
21
22 @BeforeClass
23 public static void beforeClass()
24 throws Exception {
25 //TODO FIx
26 //deobfuscator = new Enigma(new JarFile("build/test-obf/translation.jar"));
27 //try (InputStream in = TestTranslator.class.getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) {
28 // mappings = new MappingsJsonReader().read(new InputStreamReader(in));
29 // deobfuscator.setMappings(mappings);
30 // deobfTranslator = deobfuscator.getTranslator(TranslationDirection.Deobfuscating);
31 // obfTranslator = deobfuscator.getTranslator(TranslationDirection.Obfuscating);
32 //}
33 }
34
35 @Test
36 public void basicClasses() {
37 assertMapping(newClass("a"), newClass("deobf/A_Basic"));
38 assertMapping(newClass("b"), newClass("deobf/B_BaseClass"));
39 assertMapping(newClass("c"), newClass("deobf/C_SubClass"));
40 }
41
42 @Test
43 public void basicFields() {
44 assertMapping(newField("a", "a", "I"), newField("deobf/A_Basic", "f1", "I"));
45 assertMapping(newField("a", "a", "F"), newField("deobf/A_Basic", "f2", "F"));
46 assertMapping(newField("a", "a", "Ljava/lang/String;"), newField("deobf/A_Basic", "f3", "Ljava/lang/String;"));
47 }
48
49 @Test
50 public void basicMethods() {
51 assertMapping(newMethod("a", "a", "()V"), newMethod("deobf/A_Basic", "m1", "()V"));
52 assertMapping(newMethod("a", "a", "()I"), newMethod("deobf/A_Basic", "m2", "()I"));
53 assertMapping(newMethod("a", "a", "(I)V"), newMethod("deobf/A_Basic", "m3", "(I)V"));
54 assertMapping(newMethod("a", "a", "(I)I"), newMethod("deobf/A_Basic", "m4", "(I)I"));
55 }
56
57 // TODO: basic constructors
58
59 @Test
60 public void inheritanceFields() {
61 assertMapping(newField("b", "a", "I"), newField("deobf/B_BaseClass", "f1", "I"));
62 assertMapping(newField("b", "a", "C"), newField("deobf/B_BaseClass", "f2", "C"));
63 assertMapping(newField("c", "b", "I"), newField("deobf/C_SubClass", "f3", "I"));
64 assertMapping(newField("c", "c", "I"), newField("deobf/C_SubClass", "f4", "I"));
65 }
66
67 @Test
68 public void inheritanceFieldsShadowing() {
69 assertMapping(newField("c", "b", "C"), newField("deobf/C_SubClass", "f2", "C"));
70 }
71
72 @Test
73 public void inheritanceFieldsBySubClass() {
74 assertMapping(newField("c", "a", "I"), newField("deobf/C_SubClass", "f1", "I"));
75 // NOTE: can't reference b.C by subclass since it's shadowed
76 }
77
78 @Test
79 public void inheritanceMethods() {
80 assertMapping(newMethod("b", "a", "()I"), newMethod("deobf/B_BaseClass", "m1", "()I"));
81 assertMapping(newMethod("b", "b", "()I"), newMethod("deobf/B_BaseClass", "m2", "()I"));
82 assertMapping(newMethod("c", "c", "()I"), newMethod("deobf/C_SubClass", "m3", "()I"));
83 }
84
85 @Test
86 public void inheritanceMethodsOverrides() {
87 assertMapping(newMethod("c", "a", "()I"), newMethod("deobf/C_SubClass", "m1", "()I"));
88 }
89
90 @Test
91 public void inheritanceMethodsBySubClass() {
92 assertMapping(newMethod("c", "b", "()I"), newMethod("deobf/C_SubClass", "m2", "()I"));
93 }
94
95 @Test
96 public void innerClasses() {
97
98 // classes
99 assertMapping(newClass("g"), newClass("deobf/G_OuterClass"));
100 assertMapping(newClass("g$a"), newClass("deobf/G_OuterClass$A_InnerClass"));
101 assertMapping(newClass("g$a$a"), newClass("deobf/G_OuterClass$A_InnerClass$A_InnerInnerClass"));
102 assertMapping(newClass("g$b"), newClass("deobf/G_OuterClass$b"));
103 assertMapping(newClass("g$b$a"), newClass("deobf/G_OuterClass$b$A_NamedInnerClass"));
104
105 // fields
106 assertMapping(newField("g$a", "a", "I"), newField("deobf/G_OuterClass$A_InnerClass", "f1", "I"));
107 assertMapping(newField("g$a", "a", "Ljava/lang/String;"), newField("deobf/G_OuterClass$A_InnerClass", "f2", "Ljava/lang/String;"));
108 assertMapping(newField("g$a$a", "a", "I"), newField("deobf/G_OuterClass$A_InnerClass$A_InnerInnerClass", "f3", "I"));
109 assertMapping(newField("g$b$a", "a", "I"), newField("deobf/G_OuterClass$b$A_NamedInnerClass", "f4", "I"));
110
111 // methods
112 assertMapping(newMethod("g$a", "a", "()V"), newMethod("deobf/G_OuterClass$A_InnerClass", "m1", "()V"));
113 assertMapping(newMethod("g$a$a", "a", "()V"), newMethod("deobf/G_OuterClass$A_InnerClass$A_InnerInnerClass", "m2", "()V"));
114 }
115
116 @Test
117 public void namelessClass() {
118 assertMapping(newClass("h"), newClass("h"));
119 }
120
121 @Test
122 public void testGenerics() {
123
124 // classes
125 assertMapping(newClass("i"), newClass("deobf/I_Generics"));
126 assertMapping(newClass("i$a"), newClass("deobf/I_Generics$A_Type"));
127 assertMapping(newClass("i$b"), newClass("deobf/I_Generics$B_Generic"));
128
129 // fields
130 assertMapping(newField("i", "a", "Ljava/util/List;"), newField("deobf/I_Generics", "f1", "Ljava/util/List;"));
131 assertMapping(newField("i", "b", "Ljava/util/List;"), newField("deobf/I_Generics", "f2", "Ljava/util/List;"));
132 assertMapping(newField("i", "a", "Ljava/util/Map;"), newField("deobf/I_Generics", "f3", "Ljava/util/Map;"));
133 assertMapping(newField("i$b", "a", "Ljava/lang/Object;"), newField("deobf/I_Generics$B_Generic", "f4", "Ljava/lang/Object;"));
134 assertMapping(newField("i", "a", "Li$b;"), newField("deobf/I_Generics", "f5", "Ldeobf/I_Generics$B_Generic;"));
135 assertMapping(newField("i", "b", "Li$b;"), newField("deobf/I_Generics", "f6", "Ldeobf/I_Generics$B_Generic;"));
136
137 // methods
138 assertMapping(newMethod("i$b", "a", "()Ljava/lang/Object;"), newMethod("deobf/I_Generics$B_Generic", "m1", "()Ljava/lang/Object;"));
139 }
140
141 private void assertMapping(Entry<?> obf, Entry<?> deobf) {
142 //assertThat(deobfTranslator.translateEntry(obf), is(deobf));
143 //assertThat(obfTranslator.translateEntry(deobf), is(obf));
144
145 //String deobfName = deobfTranslator.translate(obf);
146 //if (deobfName != null) {
147 // assertThat(deobfName, is(deobf.getName()));
148 //}
149
150 //String obfName = obfTranslator.translate(deobf);
151 //if (obfName != null) {
152 // assertThat(obfName, is(obf.getName()));
153 //}
154 }
155}
diff --git a/src/test/java/cuchaz/enigma/TestTypeDescriptor.java b/src/test/java/cuchaz/enigma/TestTypeDescriptor.java
deleted file mode 100644
index b9ebe55..0000000
--- a/src/test/java/cuchaz/enigma/TestTypeDescriptor.java
+++ /dev/null
@@ -1,243 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.translation.representation.TypeDescriptor;
15import org.junit.Test;
16
17import static cuchaz.enigma.TestEntryFactory.newClass;
18import static org.hamcrest.MatcherAssert.assertThat;
19import static org.hamcrest.Matchers.is;
20import static org.hamcrest.Matchers.not;
21
22public class TestTypeDescriptor {
23
24 @Test
25 public void isVoid() {
26 assertThat(new TypeDescriptor("V").isVoid(), is(true));
27 assertThat(new TypeDescriptor("Z").isVoid(), is(false));
28 assertThat(new TypeDescriptor("B").isVoid(), is(false));
29 assertThat(new TypeDescriptor("C").isVoid(), is(false));
30 assertThat(new TypeDescriptor("I").isVoid(), is(false));
31 assertThat(new TypeDescriptor("J").isVoid(), is(false));
32 assertThat(new TypeDescriptor("F").isVoid(), is(false));
33 assertThat(new TypeDescriptor("D").isVoid(), is(false));
34 assertThat(new TypeDescriptor("LFoo;").isVoid(), is(false));
35 assertThat(new TypeDescriptor("[I").isVoid(), is(false));
36 }
37
38 @Test
39 public void isPrimitive() {
40 assertThat(new TypeDescriptor("V").isPrimitive(), is(false));
41 assertThat(new TypeDescriptor("Z").isPrimitive(), is(true));
42 assertThat(new TypeDescriptor("B").isPrimitive(), is(true));
43 assertThat(new TypeDescriptor("C").isPrimitive(), is(true));
44 assertThat(new TypeDescriptor("I").isPrimitive(), is(true));
45 assertThat(new TypeDescriptor("J").isPrimitive(), is(true));
46 assertThat(new TypeDescriptor("F").isPrimitive(), is(true));
47 assertThat(new TypeDescriptor("D").isPrimitive(), is(true));
48 assertThat(new TypeDescriptor("LFoo;").isPrimitive(), is(false));
49 assertThat(new TypeDescriptor("[I").isPrimitive(), is(false));
50 }
51
52 @Test
53 public void getPrimitive() {
54 assertThat(new TypeDescriptor("Z").getPrimitive(), is(TypeDescriptor.Primitive.BOOLEAN));
55 assertThat(new TypeDescriptor("B").getPrimitive(), is(TypeDescriptor.Primitive.BYTE));
56 assertThat(new TypeDescriptor("C").getPrimitive(), is(TypeDescriptor.Primitive.CHARACTER));
57 assertThat(new TypeDescriptor("I").getPrimitive(), is(TypeDescriptor.Primitive.INTEGER));
58 assertThat(new TypeDescriptor("J").getPrimitive(), is(TypeDescriptor.Primitive.LONG));
59 assertThat(new TypeDescriptor("F").getPrimitive(), is(TypeDescriptor.Primitive.FLOAT));
60 assertThat(new TypeDescriptor("D").getPrimitive(), is(TypeDescriptor.Primitive.DOUBLE));
61 }
62
63 @Test
64 public void isClass() {
65 assertThat(new TypeDescriptor("V").isType(), is(false));
66 assertThat(new TypeDescriptor("Z").isType(), is(false));
67 assertThat(new TypeDescriptor("B").isType(), is(false));
68 assertThat(new TypeDescriptor("C").isType(), is(false));
69 assertThat(new TypeDescriptor("I").isType(), is(false));
70 assertThat(new TypeDescriptor("J").isType(), is(false));
71 assertThat(new TypeDescriptor("F").isType(), is(false));
72 assertThat(new TypeDescriptor("D").isType(), is(false));
73 assertThat(new TypeDescriptor("LFoo;").isType(), is(true));
74 assertThat(new TypeDescriptor("[I").isType(), is(false));
75 }
76
77 @Test
78 public void getClassEntry() {
79 assertThat(new TypeDescriptor("LFoo;").getTypeEntry(), is(newClass("Foo")));
80 assertThat(new TypeDescriptor("Ljava/lang/String;").getTypeEntry(), is(newClass("java/lang/String")));
81 }
82
83 @Test
84 public void getArrayClassEntry() {
85 assertThat(new TypeDescriptor("[LFoo;").getTypeEntry(), is(newClass("Foo")));
86 assertThat(new TypeDescriptor("[[[Ljava/lang/String;").getTypeEntry(), is(newClass("java/lang/String")));
87 }
88
89 @Test
90 public void isArray() {
91 assertThat(new TypeDescriptor("V").isArray(), is(false));
92 assertThat(new TypeDescriptor("Z").isArray(), is(false));
93 assertThat(new TypeDescriptor("B").isArray(), is(false));
94 assertThat(new TypeDescriptor("C").isArray(), is(false));
95 assertThat(new TypeDescriptor("I").isArray(), is(false));
96 assertThat(new TypeDescriptor("J").isArray(), is(false));
97 assertThat(new TypeDescriptor("F").isArray(), is(false));
98 assertThat(new TypeDescriptor("D").isArray(), is(false));
99 assertThat(new TypeDescriptor("LFoo;").isArray(), is(false));
100 assertThat(new TypeDescriptor("[I").isArray(), is(true));
101 }
102
103 @Test
104 public void getArrayDimension() {
105 assertThat(new TypeDescriptor("[I").getArrayDimension(), is(1));
106 assertThat(new TypeDescriptor("[[I").getArrayDimension(), is(2));
107 assertThat(new TypeDescriptor("[[[I").getArrayDimension(), is(3));
108 }
109
110 @Test
111 public void getArrayType() {
112 assertThat(new TypeDescriptor("[I").getArrayType(), is(new TypeDescriptor("I")));
113 assertThat(new TypeDescriptor("[[I").getArrayType(), is(new TypeDescriptor("I")));
114 assertThat(new TypeDescriptor("[[[I").getArrayType(), is(new TypeDescriptor("I")));
115 assertThat(new TypeDescriptor("[Ljava/lang/String;").getArrayType(), is(new TypeDescriptor("Ljava/lang/String;")));
116 }
117
118 @Test
119 public void hasClass() {
120 assertThat(new TypeDescriptor("LFoo;").containsType(), is(true));
121 assertThat(new TypeDescriptor("Ljava/lang/String;").containsType(), is(true));
122 assertThat(new TypeDescriptor("[LBar;").containsType(), is(true));
123 assertThat(new TypeDescriptor("[[[LCat;").containsType(), is(true));
124
125 assertThat(new TypeDescriptor("V").containsType(), is(false));
126 assertThat(new TypeDescriptor("[I").containsType(), is(false));
127 assertThat(new TypeDescriptor("[[[I").containsType(), is(false));
128 assertThat(new TypeDescriptor("Z").containsType(), is(false));
129 }
130
131 @Test
132 public void parseVoid() {
133 final String answer = "V";
134 assertThat(TypeDescriptor.parseFirst("V"), is(answer));
135 assertThat(TypeDescriptor.parseFirst("VVV"), is(answer));
136 assertThat(TypeDescriptor.parseFirst("VIJ"), is(answer));
137 assertThat(TypeDescriptor.parseFirst("V[I"), is(answer));
138 assertThat(TypeDescriptor.parseFirst("VLFoo;"), is(answer));
139 assertThat(TypeDescriptor.parseFirst("V[LFoo;"), is(answer));
140 }
141
142 @Test
143 public void parsePrimitive() {
144 final String answer = "I";
145 assertThat(TypeDescriptor.parseFirst("I"), is(answer));
146 assertThat(TypeDescriptor.parseFirst("III"), is(answer));
147 assertThat(TypeDescriptor.parseFirst("IJZ"), is(answer));
148 assertThat(TypeDescriptor.parseFirst("I[I"), is(answer));
149 assertThat(TypeDescriptor.parseFirst("ILFoo;"), is(answer));
150 assertThat(TypeDescriptor.parseFirst("I[LFoo;"), is(answer));
151 }
152
153 @Test
154 public void parseClass() {
155 {
156 final String answer = "LFoo;";
157 assertThat(TypeDescriptor.parseFirst("LFoo;"), is(answer));
158 assertThat(TypeDescriptor.parseFirst("LFoo;I"), is(answer));
159 assertThat(TypeDescriptor.parseFirst("LFoo;JZ"), is(answer));
160 assertThat(TypeDescriptor.parseFirst("LFoo;[I"), is(answer));
161 assertThat(TypeDescriptor.parseFirst("LFoo;LFoo;"), is(answer));
162 assertThat(TypeDescriptor.parseFirst("LFoo;[LFoo;"), is(answer));
163 }
164 {
165 final String answer = "Ljava/lang/String;";
166 assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;"), is(answer));
167 assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;I"), is(answer));
168 assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;JZ"), is(answer));
169 assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;[I"), is(answer));
170 assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;LFoo;"), is(answer));
171 assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;[LFoo;"), is(answer));
172 }
173 }
174
175 @Test
176 public void parseArray() {
177 {
178 final String answer = "[I";
179 assertThat(TypeDescriptor.parseFirst("[I"), is(answer));
180 assertThat(TypeDescriptor.parseFirst("[III"), is(answer));
181 assertThat(TypeDescriptor.parseFirst("[IJZ"), is(answer));
182 assertThat(TypeDescriptor.parseFirst("[I[I"), is(answer));
183 assertThat(TypeDescriptor.parseFirst("[ILFoo;"), is(answer));
184 }
185 {
186 final String answer = "[[I";
187 assertThat(TypeDescriptor.parseFirst("[[I"), is(answer));
188 assertThat(TypeDescriptor.parseFirst("[[III"), is(answer));
189 assertThat(TypeDescriptor.parseFirst("[[IJZ"), is(answer));
190 assertThat(TypeDescriptor.parseFirst("[[I[I"), is(answer));
191 assertThat(TypeDescriptor.parseFirst("[[ILFoo;"), is(answer));
192 }
193 {
194 final String answer = "[LFoo;";
195 assertThat(TypeDescriptor.parseFirst("[LFoo;"), is(answer));
196 assertThat(TypeDescriptor.parseFirst("[LFoo;II"), is(answer));
197 assertThat(TypeDescriptor.parseFirst("[LFoo;JZ"), is(answer));
198 assertThat(TypeDescriptor.parseFirst("[LFoo;[I"), is(answer));
199 assertThat(TypeDescriptor.parseFirst("[LFoo;LFoo;"), is(answer));
200 }
201 }
202
203 @Test
204 public void equals() {
205 assertThat(new TypeDescriptor("V"), is(new TypeDescriptor("V")));
206 assertThat(new TypeDescriptor("Z"), is(new TypeDescriptor("Z")));
207 assertThat(new TypeDescriptor("B"), is(new TypeDescriptor("B")));
208 assertThat(new TypeDescriptor("C"), is(new TypeDescriptor("C")));
209 assertThat(new TypeDescriptor("I"), is(new TypeDescriptor("I")));
210 assertThat(new TypeDescriptor("J"), is(new TypeDescriptor("J")));
211 assertThat(new TypeDescriptor("F"), is(new TypeDescriptor("F")));
212 assertThat(new TypeDescriptor("D"), is(new TypeDescriptor("D")));
213 assertThat(new TypeDescriptor("LFoo;"), is(new TypeDescriptor("LFoo;")));
214 assertThat(new TypeDescriptor("[I"), is(new TypeDescriptor("[I")));
215 assertThat(new TypeDescriptor("[[[I"), is(new TypeDescriptor("[[[I")));
216 assertThat(new TypeDescriptor("[LFoo;"), is(new TypeDescriptor("[LFoo;")));
217
218 assertThat(new TypeDescriptor("V"), is(not(new TypeDescriptor("I"))));
219 assertThat(new TypeDescriptor("I"), is(not(new TypeDescriptor("J"))));
220 assertThat(new TypeDescriptor("I"), is(not(new TypeDescriptor("LBar;"))));
221 assertThat(new TypeDescriptor("I"), is(not(new TypeDescriptor("[I"))));
222 assertThat(new TypeDescriptor("LFoo;"), is(not(new TypeDescriptor("LBar;"))));
223 assertThat(new TypeDescriptor("[I"), is(not(new TypeDescriptor("[Z"))));
224 assertThat(new TypeDescriptor("[[[I"), is(not(new TypeDescriptor("[I"))));
225 assertThat(new TypeDescriptor("[LFoo;"), is(not(new TypeDescriptor("[LBar;"))));
226 }
227
228 @Test
229 public void testToString() {
230 assertThat(new TypeDescriptor("V").toString(), is("V"));
231 assertThat(new TypeDescriptor("Z").toString(), is("Z"));
232 assertThat(new TypeDescriptor("B").toString(), is("B"));
233 assertThat(new TypeDescriptor("C").toString(), is("C"));
234 assertThat(new TypeDescriptor("I").toString(), is("I"));
235 assertThat(new TypeDescriptor("J").toString(), is("J"));
236 assertThat(new TypeDescriptor("F").toString(), is("F"));
237 assertThat(new TypeDescriptor("D").toString(), is("D"));
238 assertThat(new TypeDescriptor("LFoo;").toString(), is("LFoo;"));
239 assertThat(new TypeDescriptor("[I").toString(), is("[I"));
240 assertThat(new TypeDescriptor("[[[I").toString(), is("[[[I"));
241 assertThat(new TypeDescriptor("[LFoo;").toString(), is("[LFoo;"));
242 }
243}
diff --git a/src/test/java/cuchaz/enigma/TokenChecker.java b/src/test/java/cuchaz/enigma/TokenChecker.java
deleted file mode 100644
index 48d0c83..0000000
--- a/src/test/java/cuchaz/enigma/TokenChecker.java
+++ /dev/null
@@ -1,65 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import com.google.common.collect.Lists;
15import cuchaz.enigma.analysis.ClassCache;
16import cuchaz.enigma.analysis.EntryReference;
17import cuchaz.enigma.source.SourceIndex;
18import cuchaz.enigma.source.*;
19import cuchaz.enigma.analysis.Token;
20import cuchaz.enigma.translation.representation.entry.Entry;
21
22import java.io.IOException;
23import java.nio.file.Path;
24import java.util.Collection;
25import java.util.List;
26
27public class TokenChecker {
28 private final Decompiler decompiler;
29
30 protected TokenChecker(Path path) throws IOException {
31 ClassCache classCache = ClassCache.of(path);
32 decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false));
33 }
34
35 protected String getDeclarationToken(Entry<?> entry) {
36 // decompile the class
37 Source source = decompiler.getSource(entry.getContainingClass().getFullName());
38 // DEBUG
39 // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null );
40 String string = source.asString();
41 SourceIndex index = source.index();
42
43 // get the token value
44 Token token = index.getDeclarationToken(entry);
45 if (token == null) {
46 return null;
47 }
48 return string.substring(token.start, token.end);
49 }
50
51 @SuppressWarnings("unchecked")
52 protected Collection<String> getReferenceTokens(EntryReference<? extends Entry<?>, ? extends Entry<?>> reference) {
53 // decompile the class
54 Source source = decompiler.getSource(reference.context.getContainingClass().getFullName());
55 String string = source.asString();
56 SourceIndex index = source.index();
57
58 // get the token values
59 List<String> values = Lists.newArrayList();
60 for (Token token : index.getReferenceTokens((EntryReference<Entry<?>, Entry<?>>) reference)) {
61 values.add(string.substring(token.start, token.end));
62 }
63 return values;
64 }
65}
diff --git a/src/test/java/cuchaz/enigma/command/CheckMappingsCommandTest.java b/src/test/java/cuchaz/enigma/command/CheckMappingsCommandTest.java
deleted file mode 100644
index f3b9f85..0000000
--- a/src/test/java/cuchaz/enigma/command/CheckMappingsCommandTest.java
+++ /dev/null
@@ -1,20 +0,0 @@
1package cuchaz.enigma.command;
2
3import org.junit.Test;
4
5import java.io.File;
6
7public class CheckMappingsCommandTest {
8
9 @Test(expected = IllegalStateException.class)
10 public void testWrong() throws Exception {
11 new CheckMappingsCommand().run(new File("build/test-obf/packageAccess.jar").getAbsolutePath(), new File("src/test/resources" +
12 "/packageAccess/wrongMappings").getAbsolutePath());
13 }
14
15 @Test
16 public void testRight() throws Exception {
17 new CheckMappingsCommand().run(new File("build/test-obf/packageAccess.jar").getAbsolutePath(), new File("src/test/resources" +
18 "/packageAccess/correctMappings").getAbsolutePath());
19 }
20}
diff --git a/src/test/java/cuchaz/enigma/inputs/Keep.java b/src/test/java/cuchaz/enigma/inputs/Keep.java
deleted file mode 100644
index 4dbe8e2..0000000
--- a/src/test/java/cuchaz/enigma/inputs/Keep.java
+++ /dev/null
@@ -1,18 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs;
13
14public class Keep {
15 public static void main(String[] args) {
16 System.out.println("Keep me!");
17 }
18}
diff --git a/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java b/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java
deleted file mode 100644
index f07e1f8..0000000
--- a/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java
+++ /dev/null
@@ -1,26 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.constructors;
13
14// a
15public class BaseClass {
16
17 // <init>()V
18 public BaseClass() {
19 System.out.println("Default constructor");
20 }
21
22 // <init>(I)V
23 public BaseClass(int i) {
24 System.out.println("Int constructor " + i);
25 }
26}
diff --git a/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java b/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java
deleted file mode 100644
index 71439fd..0000000
--- a/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java
+++ /dev/null
@@ -1,58 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.constructors;
13
14// b
15public class Caller {
16
17 // a()V
18 public void callBaseDefault() {
19 // a.<init>()V
20 System.out.println(new BaseClass());
21 }
22
23 // b()V
24 public void callBaseInt() {
25 // a.<init>(I)V
26 System.out.println(new BaseClass(5));
27 }
28
29 // c()V
30 public void callSubDefault() {
31 // d.<init>()V
32 System.out.println(new SubClass());
33 }
34
35 // d()V
36 public void callSubInt() {
37 // d.<init>(I)V
38 System.out.println(new SubClass(6));
39 }
40
41 // e()V
42 public void callSubIntInt() {
43 // d.<init>(II)V
44 System.out.println(new SubClass(4, 2));
45 }
46
47 // f()V
48 public void callSubSubInt() {
49 // e.<init>(I)V
50 System.out.println(new SubSubClass(3));
51 }
52
53 // g()V
54 public void callDefaultConstructable() {
55 // c.<init>()V
56 System.out.println(new DefaultConstructable());
57 }
58}
diff --git a/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java b/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java
deleted file mode 100644
index c3d4170..0000000
--- a/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java
+++ /dev/null
@@ -1,16 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.constructors;
13
14public class DefaultConstructable {
15 // only default constructor
16}
diff --git a/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java b/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java
deleted file mode 100644
index bc56b3b..0000000
--- a/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java
+++ /dev/null
@@ -1,39 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.constructors;
13
14// d extends a
15public class SubClass extends BaseClass {
16
17 // <init>()V
18 public SubClass() {
19 // a.<init>()V
20 }
21
22 // <init>(I)V
23 public SubClass(int num) {
24 // <init>()V
25 this();
26 System.out.println("SubClass " + num);
27 }
28
29 // <init>(II)V
30 public SubClass(int a, int b) {
31 // <init>(I)V
32 this(a + b);
33 }
34
35 // <init>(III)V
36 public SubClass(int a, int b, int c) {
37 // a.<init>()V
38 }
39}
diff --git a/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java b/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java
deleted file mode 100644
index 87b69d3..0000000
--- a/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java
+++ /dev/null
@@ -1,22 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.constructors;
13
14// e extends d
15public class SubSubClass extends SubClass {
16
17 // <init>(I)V
18 public SubSubClass(int i) {
19 // c.<init>(I)V
20 super(i);
21 }
22}
diff --git a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java
deleted file mode 100644
index b9c4929..0000000
--- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java
+++ /dev/null
@@ -1,32 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.inheritanceTree;
13
14// a
15public abstract class BaseClass {
16
17 // a
18 private String name;
19
20 // <init>(Ljava/lang/String;)V
21 protected BaseClass(String name) {
22 this.name = name;
23 }
24
25 // a()Ljava/lang/String;
26 public String getName() {
27 return name;
28 }
29
30 // a()V
31 public abstract void doBaseThings();
32}
diff --git a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java
deleted file mode 100644
index 50e963c..0000000
--- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java
+++ /dev/null
@@ -1,22 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.inheritanceTree;
13
14// b extends a
15public abstract class SubclassA extends BaseClass {
16
17 // <init>(Ljava/lang/String;)V
18 protected SubclassA(String name) {
19 // call to a.<init>(Ljava/lang/String)V
20 super(name);
21 }
22}
diff --git a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java
deleted file mode 100644
index d0dd664..0000000
--- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java
+++ /dev/null
@@ -1,41 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.inheritanceTree;
13
14// c extends a
15public class SubclassB extends BaseClass {
16
17 // a
18 private int numThings;
19
20 // <init>()V
21 protected SubclassB() {
22 // a.<init>(Ljava/lang/String;)V
23 super("B");
24
25 // access to a
26 numThings = 4;
27 }
28
29 @Override
30 // a()V
31 public void doBaseThings() {
32 // call to a.a()Ljava/lang/String;
33 System.out.println("Base things by B! " + getName());
34 }
35
36 // b()V
37 public void doBThings() {
38 // access to a
39 System.out.println("" + numThings + " B things!");
40 }
41}
diff --git a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java
deleted file mode 100644
index c584570..0000000
--- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java
+++ /dev/null
@@ -1,35 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.inheritanceTree;
13
14// d extends b
15public class SubsubclassAA extends SubclassA {
16
17 protected SubsubclassAA() {
18 // call to b.<init>(Ljava/lang/String;)V
19 super("AA");
20 }
21
22 @Override
23 // a()Ljava/lang/String;
24 public String getName() {
25 // call to b.a()Ljava/lang/String;
26 return "subsub" + super.getName();
27 }
28
29 @Override
30 // a()V
31 public void doBaseThings() {
32 // call to d.a()Ljava/lang/String;
33 System.out.println("Base things by " + getName());
34 }
35}
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java
deleted file mode 100644
index f652d87..0000000
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java
+++ /dev/null
@@ -1,25 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.innerClasses;
13
14public class A_Anonymous {
15
16 public void foo() {
17 Runnable runnable = new Runnable() {
18 @Override
19 public void run() {
20 // don't care
21 }
22 };
23 runnable.run();
24 }
25}
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java
deleted file mode 100644
index d1b7601..0000000
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java
+++ /dev/null
@@ -1,24 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.innerClasses;
13
14public class B_AnonymousWithScopeArgs {
15
16 public static void foo(final D_Simple arg) {
17 System.out.println(new Object() {
18 @Override
19 public String toString() {
20 return arg.toString();
21 }
22 });
23 }
24}
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java
deleted file mode 100644
index 94061fa..0000000
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java
+++ /dev/null
@@ -1,31 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.innerClasses;
13
14@SuppressWarnings("unused")
15public class C_ConstructorArgs {
16
17 Inner i;
18
19 public void foo() {
20 i = new Inner(5);
21 }
22
23 class Inner {
24
25 private int a;
26
27 public Inner(int a) {
28 this.a = a;
29 }
30 }
31}
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java
deleted file mode 100644
index 71b3a6d..0000000
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java
+++ /dev/null
@@ -1,19 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.innerClasses;
13
14public class D_Simple {
15
16 class Inner {
17 // nothing to do
18 }
19}
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java
deleted file mode 100644
index 976ec42..0000000
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java
+++ /dev/null
@@ -1,32 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.innerClasses;
13
14public class E_AnonymousWithOuterAccess {
15
16 // reproduction of error case documented at:
17 // https://bitbucket.org/cuchaz/enigma/issue/61/stackoverflowerror-when-deobfuscating
18
19 public Object makeInner() {
20 outerMethod();
21 return new Object() {
22 @Override
23 public String toString() {
24 return outerMethod();
25 }
26 };
27 }
28
29 private String outerMethod() {
30 return "foo";
31 }
32}
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java
deleted file mode 100644
index b1de3c9..0000000
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java
+++ /dev/null
@@ -1,30 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.innerClasses;
13
14public class F_ClassTree {
15
16 public class Level1 {
17
18 public int f1;
19
20 public class Level2 {
21
22 public int f2;
23
24 public class Level3 {
25
26 public int f3;
27 }
28 }
29 }
30}
diff --git a/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java b/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java
deleted file mode 100644
index ddc4e31..0000000
--- a/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java
+++ /dev/null
@@ -1,25 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.loneClass;
13
14public class LoneClass {
15
16 private String name;
17
18 public LoneClass(String name) {
19 this.name = name;
20 }
21
22 public String getName() {
23 return name;
24 }
25}
diff --git a/src/test/java/cuchaz/enigma/inputs/packageAccess/Base.java b/src/test/java/cuchaz/enigma/inputs/packageAccess/Base.java
deleted file mode 100644
index 6f5fe30..0000000
--- a/src/test/java/cuchaz/enigma/inputs/packageAccess/Base.java
+++ /dev/null
@@ -1,7 +0,0 @@
1package cuchaz.enigma.inputs.packageAccess;
2
3public class Base {
4 protected int make() {
5 return 42;
6 }
7}
diff --git a/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java b/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java
deleted file mode 100644
index cf0f657..0000000
--- a/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java
+++ /dev/null
@@ -1,12 +0,0 @@
1package cuchaz.enigma.inputs.packageAccess;
2
3public class SamePackageChild extends Base {
4
5 class Inner {
6 final int value;
7
8 Inner() {
9 value = SamePackageChild.this.make(); // no synthetic method
10 }
11 }
12}
diff --git a/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java b/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java
deleted file mode 100644
index 19fb19c..0000000
--- a/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java
+++ /dev/null
@@ -1,14 +0,0 @@
1package cuchaz.enigma.inputs.packageAccess.sub;
2
3import cuchaz.enigma.inputs.packageAccess.Base;
4
5public class OtherPackageChild extends Base {
6
7 class Inner {
8 final int value;
9
10 Inner() {
11 value = OtherPackageChild.this.make(); // synthetic method call
12 }
13 }
14}
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java b/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java
deleted file mode 100644
index 26f3718..0000000
--- a/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java
+++ /dev/null
@@ -1,33 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.translation;
13
14public class A_Basic {
15
16 public int one;
17 public float two;
18 public String three;
19
20 public void m1() {
21 }
22
23 public int m2() {
24 return 42;
25 }
26
27 public void m3(int a1) {
28 }
29
30 public int m4(int a1) {
31 return 5; // chosen by fair die roll, guaranteed to be random
32 }
33}
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java b/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java
deleted file mode 100644
index fd7f6e7..0000000
--- a/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java
+++ /dev/null
@@ -1,26 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.translation;
13
14public class B_BaseClass {
15
16 public int f1;
17 public char f2;
18
19 public int m1() {
20 return 5;
21 }
22
23 public int m2() {
24 return 42;
25 }
26}
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java b/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java
deleted file mode 100644
index 9d74e44..0000000
--- a/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java
+++ /dev/null
@@ -1,28 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.translation;
13
14public class C_SubClass extends B_BaseClass {
15
16 public char f2; // shadows B_BaseClass.f2
17 public int f3;
18 public int f4;
19
20 @Override
21 public int m1() {
22 return 32;
23 }
24
25 public int m3() {
26 return 7;
27 }
28}
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java b/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java
deleted file mode 100644
index 99c83bb..0000000
--- a/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java
+++ /dev/null
@@ -1,29 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.translation;
13
14import java.util.ArrayList;
15import java.util.List;
16
17public class D_AnonymousTesting {
18
19 public List<Object> getObjs() {
20 List<Object> objs = new ArrayList<Object>();
21 objs.add(new Object() {
22 @Override
23 public String toString() {
24 return "Object!";
25 }
26 });
27 return objs;
28 }
29}
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java b/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java
deleted file mode 100644
index 0b8cf2a..0000000
--- a/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java
+++ /dev/null
@@ -1,32 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.translation;
13
14import java.util.Iterator;
15
16public class E_Bridges implements Iterator<Object> {
17
18 @Override
19 public boolean hasNext() {
20 return false;
21 }
22
23 @Override
24 public String next() {
25 // the compiler will generate a bridge for this method
26 return "foo";
27 }
28
29 @Override
30 public void remove() {
31 }
32}
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java b/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java
deleted file mode 100644
index 8a92792..0000000
--- a/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java
+++ /dev/null
@@ -1,31 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.translation;
13
14@SuppressWarnings("FinalizeCalledExplicitly")
15public class F_ObjectMethods {
16
17 public void callEmAll()
18 throws Throwable {
19 clone();
20 equals(this);
21 finalize();
22 getClass();
23 hashCode();
24 notify();
25 notifyAll();
26 toString();
27 wait();
28 wait(0);
29 wait(0, 0);
30 }
31}
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java b/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java
deleted file mode 100644
index a1e6a85..0000000
--- a/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java
+++ /dev/null
@@ -1,36 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.translation;
13
14public class G_OuterClass {
15
16 public class A_InnerClass {
17
18 public int f1;
19 public String f2;
20
21 public void m1() {}
22
23 public class A_InnerInnerClass {
24
25 public int f3;
26
27 public void m2() {}
28 }
29 }
30
31 public class B_NamelessClass {
32 public class A_NamedInnerClass {
33 public int f4;
34 }
35 }
36}
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java b/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java
deleted file mode 100644
index 013c55a..0000000
--- a/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java
+++ /dev/null
@@ -1,40 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.translation;
13
14public class H_NamelessClass {
15
16 public class A_InnerClass {
17
18 public int f1;
19 public String f2;
20
21 public void m1() {}
22
23 public class A_InnerInnerClass {
24
25 public int f3;
26
27 public void m2() {}
28 }
29 }
30
31 public class B_NamelessClass {
32 public class A_NamedInnerClass {
33 public int f4;
34
35 public class A_AnotherInnerClass {}
36
37 public class B_YetAnotherInnerClass {}
38 }
39 }
40}
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java b/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java
deleted file mode 100644
index fd2ebdd..0000000
--- a/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java
+++ /dev/null
@@ -1,35 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.inputs.translation;
13
14import java.util.List;
15import java.util.Map;
16
17public class I_Generics {
18
19 public List<Integer> f1;
20 public List<A_Type> f2;
21 public Map<A_Type, A_Type> f3;
22 public B_Generic<Integer> f5;
23 public B_Generic<A_Type> f6;
24
25 public class A_Type {
26 }
27
28 public class B_Generic<T> {
29 public T f4;
30
31 public T m1() {
32 return null;
33 }
34 }
35}
diff --git a/src/test/java/cuchaz/enigma/mapping/TestComments.java b/src/test/java/cuchaz/enigma/mapping/TestComments.java
deleted file mode 100644
index b3a6005..0000000
--- a/src/test/java/cuchaz/enigma/mapping/TestComments.java
+++ /dev/null
@@ -1,40 +0,0 @@
1package cuchaz.enigma.mapping;
2
3import java.io.IOException;
4import java.net.URISyntaxException;
5import java.nio.file.Path;
6import java.nio.file.Paths;
7
8import cuchaz.enigma.ProgressListener;
9import cuchaz.enigma.throwables.MappingParseException;
10import cuchaz.enigma.translation.mapping.EntryMapping;
11import cuchaz.enigma.translation.mapping.MappingFileNameFormat;
12import cuchaz.enigma.translation.mapping.MappingSaveParameters;
13import cuchaz.enigma.translation.mapping.serde.EnigmaMappingsReader;
14import cuchaz.enigma.translation.mapping.serde.TinyV2Writer;
15import cuchaz.enigma.translation.mapping.tree.EntryTree;
16import org.junit.Test;
17
18public class TestComments {
19 private static Path DIRECTORY;
20
21 static {
22 try {
23 DIRECTORY = Paths.get(TestTinyV2InnerClasses.class.getResource("/comments/").toURI());
24 } catch (URISyntaxException e) {
25 throw new RuntimeException(e);
26 }
27 }
28
29 @Test
30 public void testParseAndWrite() throws IOException, MappingParseException {
31 ProgressListener progressListener = ProgressListener.none();
32 MappingSaveParameters params = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF);
33 EntryTree<EntryMapping> mappings = EnigmaMappingsReader.DIRECTORY.read(
34 DIRECTORY, progressListener, params);
35
36 new TinyV2Writer("intermediary", "named")
37 .write(mappings, DIRECTORY.resolve("convertedtiny.tiny"), progressListener, params);
38 }
39
40} \ No newline at end of file
diff --git a/src/test/java/cuchaz/enigma/mapping/TestTinyV2InnerClasses.java b/src/test/java/cuchaz/enigma/mapping/TestTinyV2InnerClasses.java
deleted file mode 100644
index 7cfdaca..0000000
--- a/src/test/java/cuchaz/enigma/mapping/TestTinyV2InnerClasses.java
+++ /dev/null
@@ -1,41 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.mapping;
13
14import cuchaz.enigma.Enigma;
15import cuchaz.enigma.EnigmaProject;
16import cuchaz.enigma.ProgressListener;
17import cuchaz.enigma.translation.mapping.serde.EnigmaMappingsReader;
18import cuchaz.enigma.translation.representation.entry.ClassEntry;
19import org.junit.Test;
20
21import java.nio.file.Path;
22import java.nio.file.Paths;
23
24import static cuchaz.enigma.TestEntryFactory.newClass;
25
26public final class TestTinyV2InnerClasses {
27 private Path jar;
28 private Path mappings;
29
30 public TestTinyV2InnerClasses() throws Exception {
31 jar = Paths.get("build/test-obf/innerClasses.jar");
32 mappings = Paths.get(TestTinyV2InnerClasses.class.getResource("/tinyV2InnerClasses/").toURI());
33 }
34
35// @Test
36 public void testMappings() throws Exception {
37 EnigmaProject project = Enigma.create().openJar(jar, ProgressListener.none());
38 project.setMappings(EnigmaMappingsReader.DIRECTORY.read(mappings, ProgressListener.none(), project.getEnigma().getProfile().getMappingSaveParameters()));
39
40 }
41}
diff --git a/src/test/java/cuchaz/enigma/mapping/TestV2Main.java b/src/test/java/cuchaz/enigma/mapping/TestV2Main.java
deleted file mode 100644
index 021a90c..0000000
--- a/src/test/java/cuchaz/enigma/mapping/TestV2Main.java
+++ /dev/null
@@ -1,24 +0,0 @@
1package cuchaz.enigma.mapping;
2
3import cuchaz.enigma.ProgressListener;
4import cuchaz.enigma.translation.mapping.EntryMapping;
5import cuchaz.enigma.translation.mapping.MappingFileNameFormat;
6import cuchaz.enigma.translation.mapping.MappingSaveParameters;
7import cuchaz.enigma.translation.mapping.serde.EnigmaMappingsReader;
8import cuchaz.enigma.translation.mapping.serde.TinyV2Writer;
9import cuchaz.enigma.translation.mapping.tree.EntryTree;
10
11import java.nio.file.Path;
12import java.nio.file.Paths;
13
14public final class TestV2Main {
15 public static void main(String... args) throws Exception {
16 Path path = Paths.get(TestV2Main.class.getResource("/tinyV2InnerClasses/").toURI());
17
18 MappingSaveParameters parameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF);
19
20 EntryTree<EntryMapping> tree = EnigmaMappingsReader.DIRECTORY.read(path, ProgressListener.none(), parameters);
21
22 new TinyV2Writer("obf", "deobf").write(tree, Paths.get("currentYarn.tiny"), ProgressListener.none(), parameters);
23 }
24}
diff --git a/src/test/java/cuchaz/enigma/resources/translation.mappings b/src/test/java/cuchaz/enigma/resources/translation.mappings
deleted file mode 100644
index c08765c..0000000
--- a/src/test/java/cuchaz/enigma/resources/translation.mappings
+++ /dev/null
@@ -1,41 +0,0 @@
1CLASS a deobf/A_Basic
2 FIELD a f1 I
3 FIELD a f2 F
4 FIELD a f3 Ljava/lang/String;
5 METHOD a m1 ()V
6 METHOD a m2 ()I
7 METHOD a m3 (I)V
8 METHOD a m4 (I)I
9CLASS b deobf/B_BaseClass
10 FIELD a f1 I
11 FIELD a f2 C
12 METHOD a m1 ()I
13 METHOD b m2 ()I
14CLASS c deobf/C_SubClass
15 FIELD b f2 C
16 FIELD b f3 I
17 FIELD c f4 I
18 METHOD a m1 ()I
19 METHOD c m3 ()I
20CLASS g deobf/G_OuterClass
21 CLASS g$a A_InnerClass
22 CLASS g$a$a A_InnerInnerClass
23 FIELD a f3 I
24 METHOD a m2 ()V
25 FIELD a f1 I
26 FIELD a f2 Ljava/lang/String;
27 METHOD a m1 ()V
28 CLASS g$b
29 CLASS g$b$a A_NamedInnerClass
30 FIELD a f4 I
31CLASS h
32CLASS i deobf/I_Generics
33 CLASS i$a A_Type
34 CLASS i$b B_Generic
35 FIELD a f4 Ljava/lang/Object;
36 METHOD a m1 ()Ljava/lang/Object;
37 FIELD a f1 Ljava/util/List;
38 FIELD b f2 Ljava/util/List;
39 FIELD a f3 Ljava/util/Map;
40 FIELD a f5 Li$b;
41 FIELD b f6 Li$b;
diff --git a/src/test/resources/comments/test.mapping b/src/test/resources/comments/test.mapping
deleted file mode 100644
index d134558..0000000
--- a/src/test/resources/comments/test.mapping
+++ /dev/null
@@ -1,18 +0,0 @@
1CLASS net/minecraft/class_1158 net/minecraft/util/math/Quaternion
2 COMMENT it circel
3 COMMENT next line
4 FIELD field_21493 IDENTITY Lnet/minecraft/class_1158;
5 COMMENT moar comment thing
6 COMMENT near field
7 METHOD foo bar (FFFF)V
8 COMMENT method comment
9 COMMENT second line
10 COMMENT third line
11 ARG 1 b
12 COMMENT arg comment
13 CLASS old new
14 COMMENT inner comment
15 FIELD field_19263 iterator Lnet/minecraft/class_3980;
16 METHOD tryAdvance (Ljava/util/function/Consumer;)Z
17 ARG 1 consumer
18 COMMENT very inner comment \ No newline at end of file
diff --git a/src/test/resources/packageAccess/correctMappings/base/Base.mapping b/src/test/resources/packageAccess/correctMappings/base/Base.mapping
deleted file mode 100644
index 0a86def..0000000
--- a/src/test/resources/packageAccess/correctMappings/base/Base.mapping
+++ /dev/null
@@ -1 +0,0 @@
1CLASS a base/Base
diff --git a/src/test/resources/packageAccess/correctMappings/base/One.mapping b/src/test/resources/packageAccess/correctMappings/base/One.mapping
deleted file mode 100644
index dd4c208..0000000
--- a/src/test/resources/packageAccess/correctMappings/base/One.mapping
+++ /dev/null
@@ -1 +0,0 @@
1CLASS b base/One
diff --git a/src/test/resources/packageAccess/correctMappings/two/Two.mapping b/src/test/resources/packageAccess/correctMappings/two/Two.mapping
deleted file mode 100644
index a179349..0000000
--- a/src/test/resources/packageAccess/correctMappings/two/Two.mapping
+++ /dev/null
@@ -1 +0,0 @@
1CLASS c two/Two
diff --git a/src/test/resources/packageAccess/wrongMappings/base/Base.mapping b/src/test/resources/packageAccess/wrongMappings/base/Base.mapping
deleted file mode 100644
index 0a86def..0000000
--- a/src/test/resources/packageAccess/wrongMappings/base/Base.mapping
+++ /dev/null
@@ -1 +0,0 @@
1CLASS a base/Base
diff --git a/src/test/resources/packageAccess/wrongMappings/one/One.mapping b/src/test/resources/packageAccess/wrongMappings/one/One.mapping
deleted file mode 100644
index 15b42cf..0000000
--- a/src/test/resources/packageAccess/wrongMappings/one/One.mapping
+++ /dev/null
@@ -1 +0,0 @@
1CLASS b one/One
diff --git a/src/test/resources/packageAccess/wrongMappings/two/Two.mapping b/src/test/resources/packageAccess/wrongMappings/two/Two.mapping
deleted file mode 100644
index a179349..0000000
--- a/src/test/resources/packageAccess/wrongMappings/two/Two.mapping
+++ /dev/null
@@ -1 +0,0 @@
1CLASS c two/Two
diff --git a/src/test/resources/proguard-build.conf b/src/test/resources/proguard-build.conf
deleted file mode 100644
index ba3575a..0000000
--- a/src/test/resources/proguard-build.conf
+++ /dev/null
@@ -1,6 +0,0 @@
1-dontoptimize
2-dontobfuscate
3-dontwarn
4-keep class cuchaz.enigma.Main { static void main(java.lang.String[]); }
5-keep class cuchaz.enigma.CommandMain { static void main(java.lang.String[]); }
6-keep class de.sciss.syntaxpane.** { *; }
diff --git a/src/test/resources/proguard-test.conf b/src/test/resources/proguard-test.conf
deleted file mode 100644
index 9411d26..0000000
--- a/src/test/resources/proguard-test.conf
+++ /dev/null
@@ -1,8 +0,0 @@
1-overloadaggressively
2-repackageclasses
3-allowaccessmodification
4-dontoptimize
5-dontshrink
6-keepparameternames
7-keepattributes
8-keep class cuchaz.enigma.inputs.Keep
diff --git a/src/test/resources/tinyV2InnerClasses/c.mapping b/src/test/resources/tinyV2InnerClasses/c.mapping
deleted file mode 100644
index f9b0442..0000000
--- a/src/test/resources/tinyV2InnerClasses/c.mapping
+++ /dev/null
@@ -1,2 +0,0 @@
1CLASS c
2 CLASS a Kid
diff --git a/src/test/resources/tinyV2InnerClasses/cuchaz/enigma/Dad.mapping b/src/test/resources/tinyV2InnerClasses/cuchaz/enigma/Dad.mapping
deleted file mode 100644
index 8d43ba9..0000000
--- a/src/test/resources/tinyV2InnerClasses/cuchaz/enigma/Dad.mapping
+++ /dev/null
@@ -1,5 +0,0 @@
1CLASS f cuchaz/enigma/Dad
2 CLASS a One
3 CLASS a Two
4 CLASS a
5 FIELD a value I