From 0f47403d0220757fed189b76e2071e25b1025cb8 Mon Sep 17 00:00:00 2001 From: Runemoro Date: Wed, 3 Jun 2020 13:39:42 -0400 Subject: Split GUI code to separate module (#242) * Split into modules * Post merge compile fixes Co-authored-by: modmuss50 --- .../cuchaz/enigma/PackageVisibilityIndexTest.java | 53 ----- src/test/java/cuchaz/enigma/TestDeobfed.java | 100 --------- src/test/java/cuchaz/enigma/TestDeobfuscator.java | 41 ---- src/test/java/cuchaz/enigma/TestEntryFactory.java | 49 ---- src/test/java/cuchaz/enigma/TestInnerClasses.java | 85 ------- .../enigma/TestJarIndexConstructorReferences.java | 124 ----------- .../cuchaz/enigma/TestJarIndexInheritanceTree.java | 227 ------------------- .../java/cuchaz/enigma/TestJarIndexLoneClass.java | 157 ------------- .../java/cuchaz/enigma/TestMethodDescriptor.java | 247 --------------------- src/test/java/cuchaz/enigma/TestSourceIndex.java | 74 ------ .../java/cuchaz/enigma/TestTokensConstructors.java | 137 ------------ src/test/java/cuchaz/enigma/TestTranslator.java | 155 ------------- .../java/cuchaz/enigma/TestTypeDescriptor.java | 243 -------------------- src/test/java/cuchaz/enigma/TokenChecker.java | 65 ------ .../enigma/command/CheckMappingsCommandTest.java | 20 -- src/test/java/cuchaz/enigma/inputs/Keep.java | 18 -- .../enigma/inputs/constructors/BaseClass.java | 26 --- .../cuchaz/enigma/inputs/constructors/Caller.java | 58 ----- .../inputs/constructors/DefaultConstructable.java | 16 -- .../enigma/inputs/constructors/SubClass.java | 39 ---- .../enigma/inputs/constructors/SubSubClass.java | 22 -- .../enigma/inputs/inheritanceTree/BaseClass.java | 32 --- .../enigma/inputs/inheritanceTree/SubclassA.java | 22 -- .../enigma/inputs/inheritanceTree/SubclassB.java | 41 ---- .../inputs/inheritanceTree/SubsubclassAA.java | 35 --- .../enigma/inputs/innerClasses/A_Anonymous.java | 25 --- .../innerClasses/B_AnonymousWithScopeArgs.java | 24 -- .../inputs/innerClasses/C_ConstructorArgs.java | 31 --- .../enigma/inputs/innerClasses/D_Simple.java | 19 -- .../innerClasses/E_AnonymousWithOuterAccess.java | 32 --- .../enigma/inputs/innerClasses/F_ClassTree.java | 30 --- .../cuchaz/enigma/inputs/loneClass/LoneClass.java | 25 --- .../cuchaz/enigma/inputs/packageAccess/Base.java | 7 - .../inputs/packageAccess/SamePackageChild.java | 12 - .../packageAccess/sub/OtherPackageChild.java | 14 -- .../cuchaz/enigma/inputs/translation/A_Basic.java | 33 --- .../enigma/inputs/translation/B_BaseClass.java | 26 --- .../enigma/inputs/translation/C_SubClass.java | 28 --- .../inputs/translation/D_AnonymousTesting.java | 29 --- .../enigma/inputs/translation/E_Bridges.java | 32 --- .../enigma/inputs/translation/F_ObjectMethods.java | 31 --- .../enigma/inputs/translation/G_OuterClass.java | 36 --- .../enigma/inputs/translation/H_NamelessClass.java | 40 ---- .../enigma/inputs/translation/I_Generics.java | 35 --- .../java/cuchaz/enigma/mapping/TestComments.java | 40 ---- .../enigma/mapping/TestTinyV2InnerClasses.java | 41 ---- .../java/cuchaz/enigma/mapping/TestV2Main.java | 24 -- .../cuchaz/enigma/resources/translation.mappings | 41 ---- src/test/resources/comments/test.mapping | 18 -- .../correctMappings/base/Base.mapping | 1 - .../packageAccess/correctMappings/base/One.mapping | 1 - .../packageAccess/correctMappings/two/Two.mapping | 1 - .../packageAccess/wrongMappings/base/Base.mapping | 1 - .../packageAccess/wrongMappings/one/One.mapping | 1 - .../packageAccess/wrongMappings/two/Two.mapping | 1 - src/test/resources/proguard-build.conf | 6 - src/test/resources/proguard-test.conf | 8 - src/test/resources/tinyV2InnerClasses/c.mapping | 2 - .../tinyV2InnerClasses/cuchaz/enigma/Dad.mapping | 5 - 59 files changed, 2786 deletions(-) delete mode 100644 src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java delete mode 100644 src/test/java/cuchaz/enigma/TestDeobfed.java delete mode 100644 src/test/java/cuchaz/enigma/TestDeobfuscator.java delete mode 100644 src/test/java/cuchaz/enigma/TestEntryFactory.java delete mode 100644 src/test/java/cuchaz/enigma/TestInnerClasses.java delete mode 100644 src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java delete mode 100644 src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java delete mode 100644 src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java delete mode 100644 src/test/java/cuchaz/enigma/TestMethodDescriptor.java delete mode 100644 src/test/java/cuchaz/enigma/TestSourceIndex.java delete mode 100644 src/test/java/cuchaz/enigma/TestTokensConstructors.java delete mode 100644 src/test/java/cuchaz/enigma/TestTranslator.java delete mode 100644 src/test/java/cuchaz/enigma/TestTypeDescriptor.java delete mode 100644 src/test/java/cuchaz/enigma/TokenChecker.java delete mode 100644 src/test/java/cuchaz/enigma/command/CheckMappingsCommandTest.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/Keep.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/constructors/Caller.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/packageAccess/Base.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java delete mode 100644 src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java delete mode 100644 src/test/java/cuchaz/enigma/mapping/TestComments.java delete mode 100644 src/test/java/cuchaz/enigma/mapping/TestTinyV2InnerClasses.java delete mode 100644 src/test/java/cuchaz/enigma/mapping/TestV2Main.java delete mode 100644 src/test/java/cuchaz/enigma/resources/translation.mappings delete mode 100644 src/test/resources/comments/test.mapping delete mode 100644 src/test/resources/packageAccess/correctMappings/base/Base.mapping delete mode 100644 src/test/resources/packageAccess/correctMappings/base/One.mapping delete mode 100644 src/test/resources/packageAccess/correctMappings/two/Two.mapping delete mode 100644 src/test/resources/packageAccess/wrongMappings/base/Base.mapping delete mode 100644 src/test/resources/packageAccess/wrongMappings/one/One.mapping delete mode 100644 src/test/resources/packageAccess/wrongMappings/two/Two.mapping delete mode 100644 src/test/resources/proguard-build.conf delete mode 100644 src/test/resources/proguard-test.conf delete mode 100644 src/test/resources/tinyV2InnerClasses/c.mapping delete mode 100644 src/test/resources/tinyV2InnerClasses/cuchaz/enigma/Dad.mapping (limited to 'src/test') diff --git a/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java b/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java deleted file mode 100644 index 1dc9748b..00000000 --- a/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.analysis.ClassCache; -import cuchaz.enigma.analysis.index.JarIndex; -import cuchaz.enigma.analysis.index.PackageVisibilityIndex; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import org.junit.Test; - -import java.nio.file.Paths; - -import static cuchaz.enigma.TestEntryFactory.newClass; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; - -public class PackageVisibilityIndexTest { - - private static final ClassEntry KEEP = newClass("cuchaz/enigma/inputs/Keep"); - private static final ClassEntry BASE = newClass("a"); - private static final ClassEntry SAME_PACKAGE_CHILD = newClass("b"); - private static final ClassEntry SAME_PACKAGE_CHILD_INNER = newClass("b$a"); - private static final ClassEntry OTHER_PACKAGE_CHILD = newClass("c"); - private static final ClassEntry OTHER_PACKAGE_CHILD_INNER = newClass("c$a"); - private final JarIndex jarIndex; - - public PackageVisibilityIndexTest() throws Exception { - ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/packageAccess.jar")); - jarIndex = classCache.index(ProgressListener.none()); - } - - @Test - public void test() { - PackageVisibilityIndex visibilityIndex = jarIndex.getPackageVisibilityIndex(); - assertThat(visibilityIndex.getPartition(BASE), containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER)); - System.out.println(visibilityIndex.getPartitions()); - assertThat(visibilityIndex.getPartitions(), containsInAnyOrder( - containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER), - containsInAnyOrder(OTHER_PACKAGE_CHILD, OTHER_PACKAGE_CHILD_INNER), - contains(KEEP) - )); - } -} diff --git a/src/test/java/cuchaz/enigma/TestDeobfed.java b/src/test/java/cuchaz/enigma/TestDeobfed.java deleted file mode 100644 index d64a745b..00000000 --- a/src/test/java/cuchaz/enigma/TestDeobfed.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.analysis.ClassCache; -import cuchaz.enigma.analysis.index.JarIndex; -import cuchaz.enigma.network.EnigmaServer; -import cuchaz.enigma.source.Decompiler; -import cuchaz.enigma.source.Decompilers; -import cuchaz.enigma.source.SourceSettings; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.nio.file.Paths; - -import static cuchaz.enigma.TestEntryFactory.newClass; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsInAnyOrder; - -public class TestDeobfed { - - private static Enigma enigma; - private static ClassCache classCache; - private static JarIndex index; - - @BeforeClass - public static void beforeClass() throws Exception { - enigma = Enigma.create(); - - classCache = ClassCache.of(Paths.get("build/test-deobf/translation.jar")); - index = classCache.index(ProgressListener.none()); - } - - @Test - public void obfEntries() { - assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( - newClass("cuchaz/enigma/inputs/Keep"), - newClass("a"), - newClass("b"), - newClass("c"), - newClass("d"), - newClass("d$1"), - newClass("e"), - newClass("f"), - newClass("g"), - newClass("g$a"), - newClass("g$a$a"), - newClass("g$b"), - newClass("g$b$a"), - newClass("h"), - newClass("h$a"), - newClass("h$a$a"), - newClass("h$b"), - newClass("h$b$a"), - newClass("h$b$a$a"), - newClass("h$b$a$b"), - newClass("i"), - newClass("i$a"), - newClass("i$b") - )); - } - - @Test - public void decompile() { - EnigmaProject project = new EnigmaProject(enigma, classCache, index, new byte[EnigmaServer.CHECKSUM_SIZE]); - Decompiler decompiler = Decompilers.PROCYON.create(project.getClassCache(), new SourceSettings(false, false)); - - decompiler.getSource("a"); - decompiler.getSource("b"); - decompiler.getSource("c"); - decompiler.getSource("d"); - decompiler.getSource("d$1"); - decompiler.getSource("e"); - decompiler.getSource("f"); - decompiler.getSource("g"); - decompiler.getSource("g$a"); - decompiler.getSource("g$a$a"); - decompiler.getSource("g$b"); - decompiler.getSource("g$b$a"); - decompiler.getSource("h"); - decompiler.getSource("h$a"); - decompiler.getSource("h$a$a"); - decompiler.getSource("h$b"); - decompiler.getSource("h$b$a"); - decompiler.getSource("h$b$a$a"); - decompiler.getSource("h$b$a$b"); - decompiler.getSource("i"); - decompiler.getSource("i$a"); - decompiler.getSource("i$b"); - } -} diff --git a/src/test/java/cuchaz/enigma/TestDeobfuscator.java b/src/test/java/cuchaz/enigma/TestDeobfuscator.java deleted file mode 100644 index 6619d26e..00000000 --- a/src/test/java/cuchaz/enigma/TestDeobfuscator.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.source.Decompiler; -import cuchaz.enigma.source.Decompilers; -import cuchaz.enigma.source.SourceSettings; -import org.junit.Test; - -import java.io.IOException; -import java.nio.file.Paths; - -public class TestDeobfuscator { - private EnigmaProject openProject() throws IOException { - Enigma enigma = Enigma.create(); - return enigma.openJar(Paths.get("build/test-obf/loneClass.jar"), ProgressListener.none()); - } - - @Test - public void loadJar() - throws Exception { - openProject(); - } - - @Test - public void decompileClass() throws Exception { - EnigmaProject project = openProject(); - Decompiler decompiler = Decompilers.PROCYON.create(project.getClassCache(), new SourceSettings(false, false)); - - decompiler.getSource("a").asString(); - } -} diff --git a/src/test/java/cuchaz/enigma/TestEntryFactory.java b/src/test/java/cuchaz/enigma/TestEntryFactory.java deleted file mode 100644 index 9e1425a2..00000000 --- a/src/test/java/cuchaz/enigma/TestEntryFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.analysis.EntryReference; -import cuchaz.enigma.translation.representation.*; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import cuchaz.enigma.translation.representation.entry.FieldEntry; -import cuchaz.enigma.translation.representation.entry.MethodEntry; - -public class TestEntryFactory { - - public static ClassEntry newClass(String name) { - return new ClassEntry(name); - } - - public static FieldEntry newField(String className, String fieldName, String fieldType) { - return newField(newClass(className), fieldName, fieldType); - } - - public static FieldEntry newField(ClassEntry classEntry, String fieldName, String fieldType) { - return new FieldEntry(classEntry, fieldName, new TypeDescriptor(fieldType)); - } - - public static MethodEntry newMethod(String className, String methodName, String methodSignature) { - return newMethod(newClass(className), methodName, methodSignature); - } - - public static MethodEntry newMethod(ClassEntry classEntry, String methodName, String methodSignature) { - return new MethodEntry(classEntry, methodName, new MethodDescriptor(methodSignature)); - } - - public static EntryReference newFieldReferenceByMethod(FieldEntry fieldEntry, String callerClassName, String callerName, String callerSignature) { - return new EntryReference<>(fieldEntry, "", newMethod(callerClassName, callerName, callerSignature)); - } - - public static EntryReference newBehaviorReferenceByMethod(MethodEntry methodEntry, String callerClassName, String callerName, String callerSignature) { - return new EntryReference<>(methodEntry, "", newMethod(callerClassName, callerName, callerSignature)); - } -} diff --git a/src/test/java/cuchaz/enigma/TestInnerClasses.java b/src/test/java/cuchaz/enigma/TestInnerClasses.java deleted file mode 100644 index 85c72f81..00000000 --- a/src/test/java/cuchaz/enigma/TestInnerClasses.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.analysis.ClassCache; -import cuchaz.enigma.analysis.index.JarIndex; -import cuchaz.enigma.source.Decompiler; -import cuchaz.enigma.source.Decompilers; -import cuchaz.enigma.source.SourceSettings; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import org.junit.Test; - -import java.nio.file.Paths; - -import static cuchaz.enigma.TestEntryFactory.newClass; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -public class TestInnerClasses { - - private static final ClassEntry SimpleOuter = newClass("d"); - private static final ClassEntry SimpleInner = newClass("d$a"); - private static final ClassEntry ConstructorArgsOuter = newClass("c"); - private static final ClassEntry ConstructorArgsInner = newClass("c$a"); - private static final ClassEntry ClassTreeRoot = newClass("f"); - private static final ClassEntry ClassTreeLevel1 = newClass("f$a"); - private static final ClassEntry ClassTreeLevel2 = newClass("f$a$a"); - private static final ClassEntry ClassTreeLevel3 = newClass("f$a$a$a"); - private final JarIndex index; - private final Decompiler decompiler; - - public TestInnerClasses() throws Exception { - ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/innerClasses.jar")); - index = classCache.index(ProgressListener.none()); - decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false)); - } - - @Test - public void simple() { - decompile(SimpleOuter); - } - - @Test - public void constructorArgs() { - decompile(ConstructorArgsOuter); - } - - @Test - public void classTree() { - - // root level - assertThat(index.getEntryIndex().hasClass(ClassTreeRoot), is(true)); - - // level 1 - ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() - + "$" + ClassTreeLevel1.getSimpleName()); - assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); - - // level 2 - fullClassEntry = new ClassEntry(ClassTreeRoot.getName() - + "$" + ClassTreeLevel1.getSimpleName() - + "$" + ClassTreeLevel2.getSimpleName()); - assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); - - // level 3 - fullClassEntry = new ClassEntry(ClassTreeRoot.getName() - + "$" + ClassTreeLevel1.getSimpleName() - + "$" + ClassTreeLevel2.getSimpleName() - + "$" + ClassTreeLevel3.getSimpleName()); - assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); - } - - private void decompile(ClassEntry classEntry) { - decompiler.getSource(classEntry.getName()); - } -} diff --git a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java deleted file mode 100644 index 48975c82..00000000 --- a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.analysis.ClassCache; -import cuchaz.enigma.analysis.EntryReference; -import cuchaz.enigma.analysis.index.JarIndex; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import cuchaz.enigma.translation.representation.entry.MethodDefEntry; -import cuchaz.enigma.translation.representation.entry.MethodEntry; -import org.junit.Test; - -import java.nio.file.Paths; -import java.util.Collection; - -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; - -public class TestJarIndexConstructorReferences { - - private JarIndex index; - - private ClassEntry baseClass = newClass("a"); - private ClassEntry subClass = newClass("d"); - private ClassEntry subsubClass = newClass("e"); - private ClassEntry defaultClass = newClass("c"); - private ClassEntry callerClass = newClass("b"); - - public TestJarIndexConstructorReferences() throws Exception { - ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/constructors.jar")); - index = classCache.index(ProgressListener.none()); - } - - @Test - public void obfEntries() { - assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, - subClass, subsubClass, defaultClass, callerClass)); - } - - @Test - @SuppressWarnings("unchecked") - public void baseDefault() { - MethodEntry source = newMethod(baseClass, "", "()V"); - Collection> references = index.getReferenceIndex().getReferencesToMethod(source); - assertThat(references, containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), - newBehaviorReferenceByMethod(source, subClass.getName(), "", "()V"), - newBehaviorReferenceByMethod(source, subClass.getName(), "", "(III)V") - )); - } - - @Test - @SuppressWarnings("unchecked") - public void baseInt() { - MethodEntry source = newMethod(baseClass, "", "(I)V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") - )); - } - - @Test - @SuppressWarnings("unchecked") - public void subDefault() { - MethodEntry source = newMethod(subClass, "", "()V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"), - newBehaviorReferenceByMethod(source, subClass.getName(), "", "(I)V") - )); - } - - @Test - @SuppressWarnings("unchecked") - public void subInt() { - MethodEntry source = newMethod(subClass, "", "(I)V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"), - newBehaviorReferenceByMethod(source, subClass.getName(), "", "(II)V"), - newBehaviorReferenceByMethod(source, subsubClass.getName(), "", "(I)V") - )); - } - - @Test - @SuppressWarnings("unchecked") - public void subIntInt() { - MethodEntry source = newMethod(subClass, "", "(II)V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") - )); - } - - @Test - public void subIntIntInt() { - MethodEntry source = newMethod(subClass, "", "(III)V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), is(empty())); - } - - @Test - @SuppressWarnings("unchecked") - public void subsubInt() { - MethodEntry source = newMethod(subsubClass, "", "(I)V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") - )); - } - - @Test - @SuppressWarnings("unchecked") - public void defaultConstructable() { - MethodEntry source = newMethod(defaultClass, "", "()V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V") - )); - } -} diff --git a/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java b/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java deleted file mode 100644 index 76e379c3..00000000 --- a/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.analysis.ClassCache; -import cuchaz.enigma.analysis.EntryReference; -import cuchaz.enigma.analysis.index.EntryIndex; -import cuchaz.enigma.analysis.index.InheritanceIndex; -import cuchaz.enigma.analysis.index.JarIndex; -import cuchaz.enigma.translation.mapping.EntryResolver; -import cuchaz.enigma.translation.mapping.IndexEntryResolver; -import cuchaz.enigma.translation.representation.AccessFlags; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import cuchaz.enigma.translation.representation.entry.FieldEntry; -import cuchaz.enigma.translation.representation.entry.MethodDefEntry; -import cuchaz.enigma.translation.representation.entry.MethodEntry; -import org.junit.Test; -import org.objectweb.asm.Opcodes; - -import java.nio.file.Paths; -import java.util.Collection; - -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; - -public class TestJarIndexInheritanceTree { - - private JarIndex index; - - private ClassEntry baseClass = newClass("a"); - private ClassEntry subClassA = newClass("b"); - private ClassEntry subClassAA = newClass("d"); - private ClassEntry subClassB = newClass("c"); - private FieldEntry nameField = newField(baseClass, "a", "Ljava/lang/String;"); - private FieldEntry numThingsField = newField(subClassB, "a", "I"); - - public TestJarIndexInheritanceTree() - throws Exception { - ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/inheritanceTree.jar")); - index = classCache.index(ProgressListener.none()); - } - - @Test - public void obfEntries() { - assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( - newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB - )); - } - - @Test - public void translationIndex() { - - InheritanceIndex index = this.index.getInheritanceIndex(); - - // base class - assertThat(index.getParents(baseClass), is(empty())); - assertThat(index.getAncestors(baseClass), is(empty())); - assertThat(index.getChildren(baseClass), containsInAnyOrder(subClassA, subClassB - )); - - // subclass a - assertThat(index.getParents(subClassA), contains(baseClass)); - assertThat(index.getAncestors(subClassA), containsInAnyOrder(baseClass)); - assertThat(index.getChildren(subClassA), contains(subClassAA)); - - // subclass aa - assertThat(index.getParents(subClassAA), contains(subClassA)); - assertThat(index.getAncestors(subClassAA), containsInAnyOrder(subClassA, baseClass)); - assertThat(index.getChildren(subClassAA), is(empty())); - - // subclass b - assertThat(index.getParents(subClassB), contains(baseClass)); - assertThat(index.getAncestors(subClassB), containsInAnyOrder(baseClass)); - assertThat(index.getChildren(subClassB), is(empty())); - } - - @Test - public void access() { - assertThat(index.getEntryIndex().getFieldAccess(nameField), is(new AccessFlags(Opcodes.ACC_PRIVATE))); - assertThat(index.getEntryIndex().getFieldAccess(numThingsField), is(new AccessFlags(Opcodes.ACC_PRIVATE))); - } - - @Test - public void relatedMethodImplementations() { - - Collection entries; - - EntryResolver resolver = new IndexEntryResolver(index); - // getName() - entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()Ljava/lang/String;")); - assertThat(entries, containsInAnyOrder( - newMethod(baseClass, "a", "()Ljava/lang/String;"), - newMethod(subClassAA, "a", "()Ljava/lang/String;") - )); - entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()Ljava/lang/String;")); - assertThat(entries, containsInAnyOrder( - newMethod(baseClass, "a", "()Ljava/lang/String;"), - newMethod(subClassAA, "a", "()Ljava/lang/String;") - )); - - // doBaseThings() - entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()V")); - assertThat(entries, containsInAnyOrder( - newMethod(baseClass, "a", "()V"), - newMethod(subClassAA, "a", "()V"), - newMethod(subClassB, "a", "()V") - )); - entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()V")); - assertThat(entries, containsInAnyOrder( - newMethod(baseClass, "a", "()V"), - newMethod(subClassAA, "a", "()V"), - newMethod(subClassB, "a", "()V") - )); - entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "a", "()V")); - assertThat(entries, containsInAnyOrder( - newMethod(baseClass, "a", "()V"), - newMethod(subClassAA, "a", "()V"), - newMethod(subClassB, "a", "()V") - )); - - // doBThings - entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "b", "()V")); - assertThat(entries, containsInAnyOrder(newMethod(subClassB, "b", "()V"))); - } - - @Test - @SuppressWarnings("unchecked") - public void fieldReferences() { - Collection> references; - - // name - references = index.getReferenceIndex().getReferencesToField(nameField); - assertThat(references, containsInAnyOrder( - newFieldReferenceByMethod(nameField, baseClass.getName(), "", "(Ljava/lang/String;)V"), - newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;") - )); - - // numThings - references = index.getReferenceIndex().getReferencesToField(numThingsField); - assertThat(references, containsInAnyOrder( - newFieldReferenceByMethod(numThingsField, subClassB.getName(), "", "()V"), - newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V") - )); - } - - @Test - @SuppressWarnings("unchecked") - public void behaviorReferences() { - - MethodEntry source; - Collection> references; - - // baseClass constructor - source = newMethod(baseClass, "", "(Ljava/lang/String;)V"); - references = index.getReferenceIndex().getReferencesToMethod(source); - assertThat(references, containsInAnyOrder( - newBehaviorReferenceByMethod(source, subClassA.getName(), "", "(Ljava/lang/String;)V"), - newBehaviorReferenceByMethod(source, subClassB.getName(), "", "()V") - )); - - // subClassA constructor - source = newMethod(subClassA, "", "(Ljava/lang/String;)V"); - references = index.getReferenceIndex().getReferencesToMethod(source); - assertThat(references, containsInAnyOrder( - newBehaviorReferenceByMethod(source, subClassAA.getName(), "", "()V") - )); - - // baseClass.getName() - source = newMethod(baseClass, "a", "()Ljava/lang/String;"); - references = index.getReferenceIndex().getReferencesToMethod(source); - assertThat(references, containsInAnyOrder( - newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()Ljava/lang/String;"), - newBehaviorReferenceByMethod(source, subClassB.getName(), "a", "()V") - )); - - // subclassAA.getName() - source = newMethod(subClassAA, "a", "()Ljava/lang/String;"); - references = index.getReferenceIndex().getReferencesToMethod(source); - assertThat(references, containsInAnyOrder( - newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V") - )); - } - - @Test - public void containsEntries() { - EntryIndex entryIndex = index.getEntryIndex(); - // classes - assertThat(entryIndex.hasClass(baseClass), is(true)); - assertThat(entryIndex.hasClass(subClassA), is(true)); - assertThat(entryIndex.hasClass(subClassAA), is(true)); - assertThat(entryIndex.hasClass(subClassB), is(true)); - - // fields - assertThat(entryIndex.hasField(nameField), is(true)); - assertThat(entryIndex.hasField(numThingsField), is(true)); - - // methods - // getName() - assertThat(entryIndex.hasMethod(newMethod(baseClass, "a", "()Ljava/lang/String;")), is(true)); - assertThat(entryIndex.hasMethod(newMethod(subClassA, "a", "()Ljava/lang/String;")), is(false)); - assertThat(entryIndex.hasMethod(newMethod(subClassAA, "a", "()Ljava/lang/String;")), is(true)); - assertThat(entryIndex.hasMethod(newMethod(subClassB, "a", "()Ljava/lang/String;")), is(false)); - - // doBaseThings() - assertThat(entryIndex.hasMethod(newMethod(baseClass, "a", "()V")), is(true)); - assertThat(entryIndex.hasMethod(newMethod(subClassA, "a", "()V")), is(false)); - assertThat(entryIndex.hasMethod(newMethod(subClassAA, "a", "()V")), is(true)); - assertThat(entryIndex.hasMethod(newMethod(subClassB, "a", "()V")), is(true)); - - // doBThings() - assertThat(entryIndex.hasMethod(newMethod(baseClass, "b", "()V")), is(false)); - assertThat(entryIndex.hasMethod(newMethod(subClassA, "b", "()V")), is(false)); - assertThat(entryIndex.hasMethod(newMethod(subClassAA, "b", "()V")), is(false)); - assertThat(entryIndex.hasMethod(newMethod(subClassB, "b", "()V")), is(true)); - - } -} diff --git a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java b/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java deleted file mode 100644 index 103c366b..00000000 --- a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.analysis.*; -import cuchaz.enigma.analysis.index.EntryIndex; -import cuchaz.enigma.analysis.index.InheritanceIndex; -import cuchaz.enigma.analysis.index.JarIndex; -import cuchaz.enigma.translation.VoidTranslator; -import cuchaz.enigma.translation.representation.AccessFlags; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import cuchaz.enigma.translation.representation.entry.FieldEntry; -import cuchaz.enigma.translation.representation.entry.MethodDefEntry; -import cuchaz.enigma.translation.representation.entry.MethodEntry; -import org.junit.Test; - -import java.nio.file.Paths; -import java.util.Collection; -import java.util.List; - -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; - -public class TestJarIndexLoneClass { - - private JarIndex index; - - public TestJarIndexLoneClass() throws Exception { - ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/loneClass.jar")); - index = classCache.index(ProgressListener.none()); - } - - @Test - public void obfEntries() { - assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( - newClass("cuchaz/enigma/inputs/Keep"), - newClass("a") - )); - } - - @Test - public void translationIndex() { - InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); - assertThat(inheritanceIndex.getParents(new ClassEntry("a")), is(empty())); - assertThat(inheritanceIndex.getParents(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); - assertThat(inheritanceIndex.getAncestors(new ClassEntry("a")), is(empty())); - assertThat(inheritanceIndex.getAncestors(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); - assertThat(inheritanceIndex.getChildren(new ClassEntry("a")), is(empty())); - assertThat(inheritanceIndex.getChildren(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); - } - - @Test - public void access() { - EntryIndex entryIndex = index.getEntryIndex(); - assertThat(entryIndex.getFieldAccess(newField("a", "a", "Ljava/lang/String;")), is(AccessFlags.PRIVATE)); - assertThat(entryIndex.getMethodAccess(newMethod("a", "a", "()Ljava/lang/String;")), is(AccessFlags.PUBLIC)); - assertThat(entryIndex.getFieldAccess(newField("a", "b", "Ljava/lang/String;")), is(nullValue())); - assertThat(entryIndex.getFieldAccess(newField("a", "a", "LFoo;")), is(nullValue())); - } - - @Test - public void classInheritance() { - IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index); - ClassInheritanceTreeNode node = treeBuilder.buildClassInheritance(VoidTranslator.INSTANCE, newClass("a")); - assertThat(node, is(not(nullValue()))); - assertThat(node.getObfClassName(), is("a")); - assertThat(node.getChildCount(), is(0)); - } - - @Test - public void methodInheritance() { - IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index); - MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); - MethodInheritanceTreeNode node = treeBuilder.buildMethodInheritance(VoidTranslator.INSTANCE, source); - assertThat(node, is(not(nullValue()))); - assertThat(node.getMethodEntry(), is(source)); - assertThat(node.getChildCount(), is(0)); - } - - @Test - public void classImplementations() { - IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index); - ClassImplementationsTreeNode node = treeBuilder.buildClassImplementations(VoidTranslator.INSTANCE, newClass("a")); - assertThat(node, is(nullValue())); - } - - @Test - public void methodImplementations() { - IndexTreeBuilder treeBuilder = new IndexTreeBuilder(index); - MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); - - List nodes = treeBuilder.buildMethodImplementations(VoidTranslator.INSTANCE, source); - assertThat(nodes, hasSize(1)); - assertThat(nodes.get(0).getMethodEntry(), is(source)); - } - - @Test - public void relatedMethodImplementations() { - Collection entries = index.getEntryResolver().resolveEquivalentMethods(newMethod("a", "a", "()Ljava/lang/String;")); - assertThat(entries, containsInAnyOrder( - newMethod("a", "a", "()Ljava/lang/String;") - )); - } - - @Test - @SuppressWarnings("unchecked") - public void fieldReferences() { - FieldEntry source = newField("a", "a", "Ljava/lang/String;"); - Collection> references = index.getReferenceIndex().getReferencesToField(source); - assertThat(references, containsInAnyOrder( - newFieldReferenceByMethod(source, "a", "", "(Ljava/lang/String;)V"), - newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") - )); - } - - @Test - public void behaviorReferences() { - assertThat(index.getReferenceIndex().getReferencesToMethod(newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); - } - - @Test - public void interfaces() { - assertThat(index.getInheritanceIndex().getParents(new ClassEntry("a")), is(empty())); - } - - @Test - public void implementingClasses() { - assertThat(index.getInheritanceIndex().getChildren(new ClassEntry("a")), is(empty())); - } - - @Test - public void isInterface() { - assertThat(index.getInheritanceIndex().isParent(new ClassEntry("a")), is(false)); - } - - @Test - public void testContains() { - EntryIndex entryIndex = index.getEntryIndex(); - assertThat(entryIndex.hasClass(newClass("a")), is(true)); - assertThat(entryIndex.hasClass(newClass("b")), is(false)); - assertThat(entryIndex.hasField(newField("a", "a", "Ljava/lang/String;")), is(true)); - assertThat(entryIndex.hasField(newField("a", "b", "Ljava/lang/String;")), is(false)); - assertThat(entryIndex.hasField(newField("a", "a", "LFoo;")), is(false)); - assertThat(entryIndex.hasMethod(newMethod("a", "a", "()Ljava/lang/String;")), is(true)); - assertThat(entryIndex.hasMethod(newMethod("a", "b", "()Ljava/lang/String;")), is(false)); - } -} diff --git a/src/test/java/cuchaz/enigma/TestMethodDescriptor.java b/src/test/java/cuchaz/enigma/TestMethodDescriptor.java deleted file mode 100644 index a73880dd..00000000 --- a/src/test/java/cuchaz/enigma/TestMethodDescriptor.java +++ /dev/null @@ -1,247 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.translation.representation.MethodDescriptor; -import cuchaz.enigma.translation.representation.TypeDescriptor; -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; - -public class TestMethodDescriptor { - - @Test - public void easiest() { - final MethodDescriptor sig = new MethodDescriptor("()V"); - assertThat(sig.getArgumentDescs(), is(empty())); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); - } - - @Test - public void primitives() { - { - final MethodDescriptor sig = new MethodDescriptor("(I)V"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); - } - { - final MethodDescriptor sig = new MethodDescriptor("(I)I"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("I"))); - } - { - final MethodDescriptor sig = new MethodDescriptor("(IBCJ)Z"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I"), - new TypeDescriptor("B"), - new TypeDescriptor("C"), - new TypeDescriptor("J") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z"))); - } - } - - @Test - public void classes() { - { - final MethodDescriptor sig = new MethodDescriptor("([LFoo;)V"); - assertThat(sig.getArgumentDescs().size(), is(1)); - assertThat(sig.getArgumentDescs().get(0), is(new TypeDescriptor("[LFoo;"))); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); - } - { - final MethodDescriptor sig = new MethodDescriptor("(LFoo;)LBar;"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("LFoo;") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;"))); - } - { - final MethodDescriptor sig = new MethodDescriptor("(LFoo;LMoo;LZoo;)LBar;"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("LFoo;"), - new TypeDescriptor("LMoo;"), - new TypeDescriptor("LZoo;") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;"))); - } - } - - @Test - public void arrays() { - { - final MethodDescriptor sig = new MethodDescriptor("([I)V"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("[I") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); - } - { - final MethodDescriptor sig = new MethodDescriptor("([I)[J"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("[I") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[J"))); - } - { - final MethodDescriptor sig = new MethodDescriptor("([I[Z[F)[D"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("[I"), - new TypeDescriptor("[Z"), - new TypeDescriptor("[F") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[D"))); - } - } - - @Test - public void mixed() { - { - final MethodDescriptor sig = new MethodDescriptor("(I[JLFoo;)Z"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I"), - new TypeDescriptor("[J"), - new TypeDescriptor("LFoo;") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z"))); - } - { - final MethodDescriptor sig = new MethodDescriptor("(III)[LFoo;"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I"), - new TypeDescriptor("I"), - new TypeDescriptor("I") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[LFoo;"))); - } - } - - @Test - public void replaceClasses() { - { - final MethodDescriptor oldSig = new MethodDescriptor("()V"); - final MethodDescriptor sig = oldSig.remap(s -> null); - assertThat(sig.getArgumentDescs(), is(empty())); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); - } - { - final MethodDescriptor oldSig = new MethodDescriptor("(IJLFoo;)V"); - final MethodDescriptor sig = oldSig.remap(s -> null); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I"), - new TypeDescriptor("J"), - new TypeDescriptor("LFoo;") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); - } - { - final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;"); - final MethodDescriptor sig = oldSig.remap(s -> { - if (s.equals("Foo")) { - return "Bar"; - } - return null; - }); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("LBar;"), - new TypeDescriptor("LBar;") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LMoo;"))); - } - { - final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;"); - final MethodDescriptor sig = oldSig.remap(s -> { - if (s.equals("Moo")) { - return "Cow"; - } - return null; - }); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("LFoo;"), - new TypeDescriptor("LBar;") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LCow;"))); - } - } - - @Test - public void replaceArrayClasses() { - { - final MethodDescriptor oldSig = new MethodDescriptor("([LFoo;)[[[LBar;"); - final MethodDescriptor sig = oldSig.remap(s -> { - if (s.equals("Foo")) { - return "Food"; - } else if (s.equals("Bar")) { - return "Beer"; - } - return null; - }); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("[LFood;") - )); - assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[[[LBeer;"))); - } - } - - @Test - public void equals() { - - // base - assertThat(new MethodDescriptor("()V"), is(new MethodDescriptor("()V"))); - - // arguments - assertThat(new MethodDescriptor("(I)V"), is(new MethodDescriptor("(I)V"))); - assertThat(new MethodDescriptor("(ZIZ)V"), is(new MethodDescriptor("(ZIZ)V"))); - assertThat(new MethodDescriptor("(LFoo;)V"), is(new MethodDescriptor("(LFoo;)V"))); - assertThat(new MethodDescriptor("(LFoo;LBar;)V"), is(new MethodDescriptor("(LFoo;LBar;)V"))); - assertThat(new MethodDescriptor("([I)V"), is(new MethodDescriptor("([I)V"))); - assertThat(new MethodDescriptor("([[D[[[J)V"), is(new MethodDescriptor("([[D[[[J)V"))); - - assertThat(new MethodDescriptor("()V"), is(not(new MethodDescriptor("(I)V")))); - assertThat(new MethodDescriptor("(I)V"), is(not(new MethodDescriptor("()V")))); - assertThat(new MethodDescriptor("(IJ)V"), is(not(new MethodDescriptor("(JI)V")))); - assertThat(new MethodDescriptor("([[Z)V"), is(not(new MethodDescriptor("([[LFoo;)V")))); - assertThat(new MethodDescriptor("(LFoo;LBar;)V"), is(not(new MethodDescriptor("(LFoo;LCow;)V")))); - assertThat(new MethodDescriptor("([LFoo;LBar;)V"), is(not(new MethodDescriptor("(LFoo;LCow;)V")))); - - // return desc - assertThat(new MethodDescriptor("()I"), is(new MethodDescriptor("()I"))); - assertThat(new MethodDescriptor("()Z"), is(new MethodDescriptor("()Z"))); - assertThat(new MethodDescriptor("()[D"), is(new MethodDescriptor("()[D"))); - assertThat(new MethodDescriptor("()[[[Z"), is(new MethodDescriptor("()[[[Z"))); - assertThat(new MethodDescriptor("()LFoo;"), is(new MethodDescriptor("()LFoo;"))); - assertThat(new MethodDescriptor("()[LFoo;"), is(new MethodDescriptor("()[LFoo;"))); - - assertThat(new MethodDescriptor("()I"), is(not(new MethodDescriptor("()Z")))); - assertThat(new MethodDescriptor("()Z"), is(not(new MethodDescriptor("()I")))); - assertThat(new MethodDescriptor("()[D"), is(not(new MethodDescriptor("()[J")))); - assertThat(new MethodDescriptor("()[[[Z"), is(not(new MethodDescriptor("()[[Z")))); - assertThat(new MethodDescriptor("()LFoo;"), is(not(new MethodDescriptor("()LBar;")))); - assertThat(new MethodDescriptor("()[LFoo;"), is(not(new MethodDescriptor("()[LBar;")))); - } - - @Test - public void testToString() { - assertThat(new MethodDescriptor("()V").toString(), is("()V")); - assertThat(new MethodDescriptor("(I)V").toString(), is("(I)V")); - assertThat(new MethodDescriptor("(ZIZ)V").toString(), is("(ZIZ)V")); - assertThat(new MethodDescriptor("(LFoo;)V").toString(), is("(LFoo;)V")); - assertThat(new MethodDescriptor("(LFoo;LBar;)V").toString(), is("(LFoo;LBar;)V")); - assertThat(new MethodDescriptor("([I)V").toString(), is("([I)V")); - assertThat(new MethodDescriptor("([[D[[[J)V").toString(), is("([[D[[[J)V")); - } -} diff --git a/src/test/java/cuchaz/enigma/TestSourceIndex.java b/src/test/java/cuchaz/enigma/TestSourceIndex.java deleted file mode 100644 index b2016089..00000000 --- a/src/test/java/cuchaz/enigma/TestSourceIndex.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import com.google.common.collect.Sets; -import cuchaz.enigma.analysis.ClassCache; -import cuchaz.enigma.source.*; -import cuchaz.enigma.analysis.index.JarIndex; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import org.junit.Test; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Set; - -public class TestSourceIndex { - @Test - public void indexEverything() - throws Exception { - // Figure out where Minecraft is... - final String mcDir = System.getProperty("enigma.test.minecraftdir"); - Path mcJar = null; - if (mcDir == null) { - String osname = System.getProperty("os.name").toLowerCase(); - if (osname.contains("nix") || osname.contains("nux") || osname.contains("solaris")) { - mcJar = Paths.get(System.getProperty("user.home"), ".minecraft/versions/1.8.3/1.8.3.jar"); - } else if (osname.contains("mac") || osname.contains("darwin")) { - mcJar = Paths.get(System.getProperty("user.home"), "Library/Application Support/minecraft/versions/1.8.3/1.8.3.jar"); - } else if (osname.contains("win")) { - mcJar = Paths.get(System.getenv("AppData"), ".minecraft/versions/1.8.3/1.8.3.jar"); - } - } else { - mcJar = Paths.get(mcDir, "versions/1.8.3/1.8.3.jar"); - } - - if (mcJar == null) { - throw new NullPointerException("Couldn't find jar"); - } - - Enigma enigma = Enigma.create(); - EnigmaProject project = enigma.openJar(mcJar, ProgressListener.none()); - - ClassCache classCache = project.getClassCache(); - JarIndex index = project.getJarIndex(); - - Decompiler decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false)); - - // get all classes that aren't inner classes - Set classEntries = Sets.newHashSet(); - for (ClassEntry obfClassEntry : index.getEntryIndex().getClasses()) { - if (!obfClassEntry.isInnerClass()) { - classEntries.add(obfClassEntry); - } - } - - for (ClassEntry obfClassEntry : classEntries) { - try { - Source source = decompiler.getSource(obfClassEntry.getName()); - source.index(); - } catch (Throwable t) { - throw new Error("Unable to index " + obfClassEntry, t); - } - } - } -} diff --git a/src/test/java/cuchaz/enigma/TestTokensConstructors.java b/src/test/java/cuchaz/enigma/TestTokensConstructors.java deleted file mode 100644 index 0398de4f..00000000 --- a/src/test/java/cuchaz/enigma/TestTokensConstructors.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.translation.representation.entry.MethodEntry; -import org.junit.Test; - -import java.nio.file.Paths; - -import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; -import static cuchaz.enigma.TestEntryFactory.newMethod; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; - -public class TestTokensConstructors extends TokenChecker { - - public TestTokensConstructors() - throws Exception { - super(Paths.get("build/test-obf/constructors.jar")); - } - - @Test - public void baseDeclarations() { - assertThat(getDeclarationToken(newMethod("a", "", "()V")), is("a")); - assertThat(getDeclarationToken(newMethod("a", "", "(I)V")), is("a")); - } - - @Test - public void subDeclarations() { - assertThat(getDeclarationToken(newMethod("d", "", "()V")), is("d")); - assertThat(getDeclarationToken(newMethod("d", "", "(I)V")), is("d")); - assertThat(getDeclarationToken(newMethod("d", "", "(II)V")), is("d")); - assertThat(getDeclarationToken(newMethod("d", "", "(III)V")), is("d")); - } - - @Test - public void subsubDeclarations() { - assertThat(getDeclarationToken(newMethod("e", "", "(I)V")), is("e")); - } - - @Test - public void defaultDeclarations() { - assertThat(getDeclarationToken(newMethod("c", "", "()V")), nullValue()); - } - - @Test - public void baseDefaultReferences() { - MethodEntry source = newMethod("a", "", "()V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "a", "()V")), - containsInAnyOrder("a") - ); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "", "()V")), - is(empty()) // implicit call, not decompiled to token - ); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "", "(III)V")), - is(empty()) // implicit call, not decompiled to token - ); - } - - @Test - public void baseIntReferences() { - MethodEntry source = newMethod("a", "", "(I)V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "b", "()V")), - containsInAnyOrder("a") - ); - } - - @Test - public void subDefaultReferences() { - MethodEntry source = newMethod("d", "", "()V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "c", "()V")), - containsInAnyOrder("d") - ); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "", "(I)V")), - containsInAnyOrder("this") - ); - } - - @Test - public void subIntReferences() { - MethodEntry source = newMethod("d", "", "(I)V"); - assertThat(getReferenceTokens( - newBehaviorReferenceByMethod(source, "b", "d", "()V")), - containsInAnyOrder("d") - ); - assertThat(getReferenceTokens( - newBehaviorReferenceByMethod(source, "d", "", "(II)V")), - containsInAnyOrder("this") - ); - assertThat(getReferenceTokens( - newBehaviorReferenceByMethod(source, "e", "", "(I)V")), - containsInAnyOrder("super") - ); - } - - @Test - public void subIntIntReferences() { - MethodEntry source = newMethod("d", "", "(II)V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "e", "()V")), - containsInAnyOrder("d") - ); - } - - @Test - public void subsubIntReferences() { - MethodEntry source = newMethod("e", "", "(I)V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "f", "()V")), - containsInAnyOrder("e") - ); - } - - @Test - public void defaultConstructableReferences() { - MethodEntry source = newMethod("c", "", "()V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "g", "()V")), - containsInAnyOrder("c") - ); - } -} diff --git a/src/test/java/cuchaz/enigma/TestTranslator.java b/src/test/java/cuchaz/enigma/TestTranslator.java deleted file mode 100644 index a420afe1..00000000 --- a/src/test/java/cuchaz/enigma/TestTranslator.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.translation.representation.entry.Entry; -import org.junit.BeforeClass; -import org.junit.Test; - -import static cuchaz.enigma.TestEntryFactory.*; - -public class TestTranslator { - - @BeforeClass - public static void beforeClass() - throws Exception { - //TODO FIx - //deobfuscator = new Enigma(new JarFile("build/test-obf/translation.jar")); - //try (InputStream in = TestTranslator.class.getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) { - // mappings = new MappingsJsonReader().read(new InputStreamReader(in)); - // deobfuscator.setMappings(mappings); - // deobfTranslator = deobfuscator.getTranslator(TranslationDirection.Deobfuscating); - // obfTranslator = deobfuscator.getTranslator(TranslationDirection.Obfuscating); - //} - } - - @Test - public void basicClasses() { - assertMapping(newClass("a"), newClass("deobf/A_Basic")); - assertMapping(newClass("b"), newClass("deobf/B_BaseClass")); - assertMapping(newClass("c"), newClass("deobf/C_SubClass")); - } - - @Test - public void basicFields() { - assertMapping(newField("a", "a", "I"), newField("deobf/A_Basic", "f1", "I")); - assertMapping(newField("a", "a", "F"), newField("deobf/A_Basic", "f2", "F")); - assertMapping(newField("a", "a", "Ljava/lang/String;"), newField("deobf/A_Basic", "f3", "Ljava/lang/String;")); - } - - @Test - public void basicMethods() { - assertMapping(newMethod("a", "a", "()V"), newMethod("deobf/A_Basic", "m1", "()V")); - assertMapping(newMethod("a", "a", "()I"), newMethod("deobf/A_Basic", "m2", "()I")); - assertMapping(newMethod("a", "a", "(I)V"), newMethod("deobf/A_Basic", "m3", "(I)V")); - assertMapping(newMethod("a", "a", "(I)I"), newMethod("deobf/A_Basic", "m4", "(I)I")); - } - - // TODO: basic constructors - - @Test - public void inheritanceFields() { - assertMapping(newField("b", "a", "I"), newField("deobf/B_BaseClass", "f1", "I")); - assertMapping(newField("b", "a", "C"), newField("deobf/B_BaseClass", "f2", "C")); - assertMapping(newField("c", "b", "I"), newField("deobf/C_SubClass", "f3", "I")); - assertMapping(newField("c", "c", "I"), newField("deobf/C_SubClass", "f4", "I")); - } - - @Test - public void inheritanceFieldsShadowing() { - assertMapping(newField("c", "b", "C"), newField("deobf/C_SubClass", "f2", "C")); - } - - @Test - public void inheritanceFieldsBySubClass() { - assertMapping(newField("c", "a", "I"), newField("deobf/C_SubClass", "f1", "I")); - // NOTE: can't reference b.C by subclass since it's shadowed - } - - @Test - public void inheritanceMethods() { - assertMapping(newMethod("b", "a", "()I"), newMethod("deobf/B_BaseClass", "m1", "()I")); - assertMapping(newMethod("b", "b", "()I"), newMethod("deobf/B_BaseClass", "m2", "()I")); - assertMapping(newMethod("c", "c", "()I"), newMethod("deobf/C_SubClass", "m3", "()I")); - } - - @Test - public void inheritanceMethodsOverrides() { - assertMapping(newMethod("c", "a", "()I"), newMethod("deobf/C_SubClass", "m1", "()I")); - } - - @Test - public void inheritanceMethodsBySubClass() { - assertMapping(newMethod("c", "b", "()I"), newMethod("deobf/C_SubClass", "m2", "()I")); - } - - @Test - public void innerClasses() { - - // classes - assertMapping(newClass("g"), newClass("deobf/G_OuterClass")); - assertMapping(newClass("g$a"), newClass("deobf/G_OuterClass$A_InnerClass")); - assertMapping(newClass("g$a$a"), newClass("deobf/G_OuterClass$A_InnerClass$A_InnerInnerClass")); - assertMapping(newClass("g$b"), newClass("deobf/G_OuterClass$b")); - assertMapping(newClass("g$b$a"), newClass("deobf/G_OuterClass$b$A_NamedInnerClass")); - - // fields - assertMapping(newField("g$a", "a", "I"), newField("deobf/G_OuterClass$A_InnerClass", "f1", "I")); - assertMapping(newField("g$a", "a", "Ljava/lang/String;"), newField("deobf/G_OuterClass$A_InnerClass", "f2", "Ljava/lang/String;")); - assertMapping(newField("g$a$a", "a", "I"), newField("deobf/G_OuterClass$A_InnerClass$A_InnerInnerClass", "f3", "I")); - assertMapping(newField("g$b$a", "a", "I"), newField("deobf/G_OuterClass$b$A_NamedInnerClass", "f4", "I")); - - // methods - assertMapping(newMethod("g$a", "a", "()V"), newMethod("deobf/G_OuterClass$A_InnerClass", "m1", "()V")); - assertMapping(newMethod("g$a$a", "a", "()V"), newMethod("deobf/G_OuterClass$A_InnerClass$A_InnerInnerClass", "m2", "()V")); - } - - @Test - public void namelessClass() { - assertMapping(newClass("h"), newClass("h")); - } - - @Test - public void testGenerics() { - - // classes - assertMapping(newClass("i"), newClass("deobf/I_Generics")); - assertMapping(newClass("i$a"), newClass("deobf/I_Generics$A_Type")); - assertMapping(newClass("i$b"), newClass("deobf/I_Generics$B_Generic")); - - // fields - assertMapping(newField("i", "a", "Ljava/util/List;"), newField("deobf/I_Generics", "f1", "Ljava/util/List;")); - assertMapping(newField("i", "b", "Ljava/util/List;"), newField("deobf/I_Generics", "f2", "Ljava/util/List;")); - assertMapping(newField("i", "a", "Ljava/util/Map;"), newField("deobf/I_Generics", "f3", "Ljava/util/Map;")); - assertMapping(newField("i$b", "a", "Ljava/lang/Object;"), newField("deobf/I_Generics$B_Generic", "f4", "Ljava/lang/Object;")); - assertMapping(newField("i", "a", "Li$b;"), newField("deobf/I_Generics", "f5", "Ldeobf/I_Generics$B_Generic;")); - assertMapping(newField("i", "b", "Li$b;"), newField("deobf/I_Generics", "f6", "Ldeobf/I_Generics$B_Generic;")); - - // methods - assertMapping(newMethod("i$b", "a", "()Ljava/lang/Object;"), newMethod("deobf/I_Generics$B_Generic", "m1", "()Ljava/lang/Object;")); - } - - private void assertMapping(Entry obf, Entry deobf) { - //assertThat(deobfTranslator.translateEntry(obf), is(deobf)); - //assertThat(obfTranslator.translateEntry(deobf), is(obf)); - - //String deobfName = deobfTranslator.translate(obf); - //if (deobfName != null) { - // assertThat(deobfName, is(deobf.getName())); - //} - - //String obfName = obfTranslator.translate(deobf); - //if (obfName != null) { - // assertThat(obfName, is(obf.getName())); - //} - } -} diff --git a/src/test/java/cuchaz/enigma/TestTypeDescriptor.java b/src/test/java/cuchaz/enigma/TestTypeDescriptor.java deleted file mode 100644 index b9ebe559..00000000 --- a/src/test/java/cuchaz/enigma/TestTypeDescriptor.java +++ /dev/null @@ -1,243 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import cuchaz.enigma.translation.representation.TypeDescriptor; -import org.junit.Test; - -import static cuchaz.enigma.TestEntryFactory.newClass; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; - -public class TestTypeDescriptor { - - @Test - public void isVoid() { - assertThat(new TypeDescriptor("V").isVoid(), is(true)); - assertThat(new TypeDescriptor("Z").isVoid(), is(false)); - assertThat(new TypeDescriptor("B").isVoid(), is(false)); - assertThat(new TypeDescriptor("C").isVoid(), is(false)); - assertThat(new TypeDescriptor("I").isVoid(), is(false)); - assertThat(new TypeDescriptor("J").isVoid(), is(false)); - assertThat(new TypeDescriptor("F").isVoid(), is(false)); - assertThat(new TypeDescriptor("D").isVoid(), is(false)); - assertThat(new TypeDescriptor("LFoo;").isVoid(), is(false)); - assertThat(new TypeDescriptor("[I").isVoid(), is(false)); - } - - @Test - public void isPrimitive() { - assertThat(new TypeDescriptor("V").isPrimitive(), is(false)); - assertThat(new TypeDescriptor("Z").isPrimitive(), is(true)); - assertThat(new TypeDescriptor("B").isPrimitive(), is(true)); - assertThat(new TypeDescriptor("C").isPrimitive(), is(true)); - assertThat(new TypeDescriptor("I").isPrimitive(), is(true)); - assertThat(new TypeDescriptor("J").isPrimitive(), is(true)); - assertThat(new TypeDescriptor("F").isPrimitive(), is(true)); - assertThat(new TypeDescriptor("D").isPrimitive(), is(true)); - assertThat(new TypeDescriptor("LFoo;").isPrimitive(), is(false)); - assertThat(new TypeDescriptor("[I").isPrimitive(), is(false)); - } - - @Test - public void getPrimitive() { - assertThat(new TypeDescriptor("Z").getPrimitive(), is(TypeDescriptor.Primitive.BOOLEAN)); - assertThat(new TypeDescriptor("B").getPrimitive(), is(TypeDescriptor.Primitive.BYTE)); - assertThat(new TypeDescriptor("C").getPrimitive(), is(TypeDescriptor.Primitive.CHARACTER)); - assertThat(new TypeDescriptor("I").getPrimitive(), is(TypeDescriptor.Primitive.INTEGER)); - assertThat(new TypeDescriptor("J").getPrimitive(), is(TypeDescriptor.Primitive.LONG)); - assertThat(new TypeDescriptor("F").getPrimitive(), is(TypeDescriptor.Primitive.FLOAT)); - assertThat(new TypeDescriptor("D").getPrimitive(), is(TypeDescriptor.Primitive.DOUBLE)); - } - - @Test - public void isClass() { - assertThat(new TypeDescriptor("V").isType(), is(false)); - assertThat(new TypeDescriptor("Z").isType(), is(false)); - assertThat(new TypeDescriptor("B").isType(), is(false)); - assertThat(new TypeDescriptor("C").isType(), is(false)); - assertThat(new TypeDescriptor("I").isType(), is(false)); - assertThat(new TypeDescriptor("J").isType(), is(false)); - assertThat(new TypeDescriptor("F").isType(), is(false)); - assertThat(new TypeDescriptor("D").isType(), is(false)); - assertThat(new TypeDescriptor("LFoo;").isType(), is(true)); - assertThat(new TypeDescriptor("[I").isType(), is(false)); - } - - @Test - public void getClassEntry() { - assertThat(new TypeDescriptor("LFoo;").getTypeEntry(), is(newClass("Foo"))); - assertThat(new TypeDescriptor("Ljava/lang/String;").getTypeEntry(), is(newClass("java/lang/String"))); - } - - @Test - public void getArrayClassEntry() { - assertThat(new TypeDescriptor("[LFoo;").getTypeEntry(), is(newClass("Foo"))); - assertThat(new TypeDescriptor("[[[Ljava/lang/String;").getTypeEntry(), is(newClass("java/lang/String"))); - } - - @Test - public void isArray() { - assertThat(new TypeDescriptor("V").isArray(), is(false)); - assertThat(new TypeDescriptor("Z").isArray(), is(false)); - assertThat(new TypeDescriptor("B").isArray(), is(false)); - assertThat(new TypeDescriptor("C").isArray(), is(false)); - assertThat(new TypeDescriptor("I").isArray(), is(false)); - assertThat(new TypeDescriptor("J").isArray(), is(false)); - assertThat(new TypeDescriptor("F").isArray(), is(false)); - assertThat(new TypeDescriptor("D").isArray(), is(false)); - assertThat(new TypeDescriptor("LFoo;").isArray(), is(false)); - assertThat(new TypeDescriptor("[I").isArray(), is(true)); - } - - @Test - public void getArrayDimension() { - assertThat(new TypeDescriptor("[I").getArrayDimension(), is(1)); - assertThat(new TypeDescriptor("[[I").getArrayDimension(), is(2)); - assertThat(new TypeDescriptor("[[[I").getArrayDimension(), is(3)); - } - - @Test - public void getArrayType() { - assertThat(new TypeDescriptor("[I").getArrayType(), is(new TypeDescriptor("I"))); - assertThat(new TypeDescriptor("[[I").getArrayType(), is(new TypeDescriptor("I"))); - assertThat(new TypeDescriptor("[[[I").getArrayType(), is(new TypeDescriptor("I"))); - assertThat(new TypeDescriptor("[Ljava/lang/String;").getArrayType(), is(new TypeDescriptor("Ljava/lang/String;"))); - } - - @Test - public void hasClass() { - assertThat(new TypeDescriptor("LFoo;").containsType(), is(true)); - assertThat(new TypeDescriptor("Ljava/lang/String;").containsType(), is(true)); - assertThat(new TypeDescriptor("[LBar;").containsType(), is(true)); - assertThat(new TypeDescriptor("[[[LCat;").containsType(), is(true)); - - assertThat(new TypeDescriptor("V").containsType(), is(false)); - assertThat(new TypeDescriptor("[I").containsType(), is(false)); - assertThat(new TypeDescriptor("[[[I").containsType(), is(false)); - assertThat(new TypeDescriptor("Z").containsType(), is(false)); - } - - @Test - public void parseVoid() { - final String answer = "V"; - assertThat(TypeDescriptor.parseFirst("V"), is(answer)); - assertThat(TypeDescriptor.parseFirst("VVV"), is(answer)); - assertThat(TypeDescriptor.parseFirst("VIJ"), is(answer)); - assertThat(TypeDescriptor.parseFirst("V[I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("VLFoo;"), is(answer)); - assertThat(TypeDescriptor.parseFirst("V[LFoo;"), is(answer)); - } - - @Test - public void parsePrimitive() { - final String answer = "I"; - assertThat(TypeDescriptor.parseFirst("I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("III"), is(answer)); - assertThat(TypeDescriptor.parseFirst("IJZ"), is(answer)); - assertThat(TypeDescriptor.parseFirst("I[I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("ILFoo;"), is(answer)); - assertThat(TypeDescriptor.parseFirst("I[LFoo;"), is(answer)); - } - - @Test - public void parseClass() { - { - final String answer = "LFoo;"; - assertThat(TypeDescriptor.parseFirst("LFoo;"), is(answer)); - assertThat(TypeDescriptor.parseFirst("LFoo;I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("LFoo;JZ"), is(answer)); - assertThat(TypeDescriptor.parseFirst("LFoo;[I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("LFoo;LFoo;"), is(answer)); - assertThat(TypeDescriptor.parseFirst("LFoo;[LFoo;"), is(answer)); - } - { - final String answer = "Ljava/lang/String;"; - assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;"), is(answer)); - assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;JZ"), is(answer)); - assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;[I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;LFoo;"), is(answer)); - assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;[LFoo;"), is(answer)); - } - } - - @Test - public void parseArray() { - { - final String answer = "[I"; - assertThat(TypeDescriptor.parseFirst("[I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[III"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[IJZ"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[I[I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[ILFoo;"), is(answer)); - } - { - final String answer = "[[I"; - assertThat(TypeDescriptor.parseFirst("[[I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[[III"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[[IJZ"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[[I[I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[[ILFoo;"), is(answer)); - } - { - final String answer = "[LFoo;"; - assertThat(TypeDescriptor.parseFirst("[LFoo;"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[LFoo;II"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[LFoo;JZ"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[LFoo;[I"), is(answer)); - assertThat(TypeDescriptor.parseFirst("[LFoo;LFoo;"), is(answer)); - } - } - - @Test - public void equals() { - assertThat(new TypeDescriptor("V"), is(new TypeDescriptor("V"))); - assertThat(new TypeDescriptor("Z"), is(new TypeDescriptor("Z"))); - assertThat(new TypeDescriptor("B"), is(new TypeDescriptor("B"))); - assertThat(new TypeDescriptor("C"), is(new TypeDescriptor("C"))); - assertThat(new TypeDescriptor("I"), is(new TypeDescriptor("I"))); - assertThat(new TypeDescriptor("J"), is(new TypeDescriptor("J"))); - assertThat(new TypeDescriptor("F"), is(new TypeDescriptor("F"))); - assertThat(new TypeDescriptor("D"), is(new TypeDescriptor("D"))); - assertThat(new TypeDescriptor("LFoo;"), is(new TypeDescriptor("LFoo;"))); - assertThat(new TypeDescriptor("[I"), is(new TypeDescriptor("[I"))); - assertThat(new TypeDescriptor("[[[I"), is(new TypeDescriptor("[[[I"))); - assertThat(new TypeDescriptor("[LFoo;"), is(new TypeDescriptor("[LFoo;"))); - - assertThat(new TypeDescriptor("V"), is(not(new TypeDescriptor("I")))); - assertThat(new TypeDescriptor("I"), is(not(new TypeDescriptor("J")))); - assertThat(new TypeDescriptor("I"), is(not(new TypeDescriptor("LBar;")))); - assertThat(new TypeDescriptor("I"), is(not(new TypeDescriptor("[I")))); - assertThat(new TypeDescriptor("LFoo;"), is(not(new TypeDescriptor("LBar;")))); - assertThat(new TypeDescriptor("[I"), is(not(new TypeDescriptor("[Z")))); - assertThat(new TypeDescriptor("[[[I"), is(not(new TypeDescriptor("[I")))); - assertThat(new TypeDescriptor("[LFoo;"), is(not(new TypeDescriptor("[LBar;")))); - } - - @Test - public void testToString() { - assertThat(new TypeDescriptor("V").toString(), is("V")); - assertThat(new TypeDescriptor("Z").toString(), is("Z")); - assertThat(new TypeDescriptor("B").toString(), is("B")); - assertThat(new TypeDescriptor("C").toString(), is("C")); - assertThat(new TypeDescriptor("I").toString(), is("I")); - assertThat(new TypeDescriptor("J").toString(), is("J")); - assertThat(new TypeDescriptor("F").toString(), is("F")); - assertThat(new TypeDescriptor("D").toString(), is("D")); - assertThat(new TypeDescriptor("LFoo;").toString(), is("LFoo;")); - assertThat(new TypeDescriptor("[I").toString(), is("[I")); - assertThat(new TypeDescriptor("[[[I").toString(), is("[[[I")); - assertThat(new TypeDescriptor("[LFoo;").toString(), is("[LFoo;")); - } -} diff --git a/src/test/java/cuchaz/enigma/TokenChecker.java b/src/test/java/cuchaz/enigma/TokenChecker.java deleted file mode 100644 index 48d0c830..00000000 --- a/src/test/java/cuchaz/enigma/TokenChecker.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma; - -import com.google.common.collect.Lists; -import cuchaz.enigma.analysis.ClassCache; -import cuchaz.enigma.analysis.EntryReference; -import cuchaz.enigma.source.SourceIndex; -import cuchaz.enigma.source.*; -import cuchaz.enigma.analysis.Token; -import cuchaz.enigma.translation.representation.entry.Entry; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; - -public class TokenChecker { - private final Decompiler decompiler; - - protected TokenChecker(Path path) throws IOException { - ClassCache classCache = ClassCache.of(path); - decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false)); - } - - protected String getDeclarationToken(Entry entry) { - // decompile the class - Source source = decompiler.getSource(entry.getContainingClass().getFullName()); - // DEBUG - // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null ); - String string = source.asString(); - SourceIndex index = source.index(); - - // get the token value - Token token = index.getDeclarationToken(entry); - if (token == null) { - return null; - } - return string.substring(token.start, token.end); - } - - @SuppressWarnings("unchecked") - protected Collection getReferenceTokens(EntryReference, ? extends Entry> reference) { - // decompile the class - Source source = decompiler.getSource(reference.context.getContainingClass().getFullName()); - String string = source.asString(); - SourceIndex index = source.index(); - - // get the token values - List values = Lists.newArrayList(); - for (Token token : index.getReferenceTokens((EntryReference, Entry>) reference)) { - values.add(string.substring(token.start, token.end)); - } - return values; - } -} 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 f3b9f85e..00000000 --- a/src/test/java/cuchaz/enigma/command/CheckMappingsCommandTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package cuchaz.enigma.command; - -import org.junit.Test; - -import java.io.File; - -public class CheckMappingsCommandTest { - - @Test(expected = IllegalStateException.class) - public void testWrong() throws Exception { - new CheckMappingsCommand().run(new File("build/test-obf/packageAccess.jar").getAbsolutePath(), new File("src/test/resources" + - "/packageAccess/wrongMappings").getAbsolutePath()); - } - - @Test - public void testRight() throws Exception { - new CheckMappingsCommand().run(new File("build/test-obf/packageAccess.jar").getAbsolutePath(), new File("src/test/resources" + - "/packageAccess/correctMappings").getAbsolutePath()); - } -} 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 4dbe8e2f..00000000 --- a/src/test/java/cuchaz/enigma/inputs/Keep.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs; - -public class Keep { - public static void main(String[] args) { - System.out.println("Keep me!"); - } -} 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 f07e1f8b..00000000 --- a/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.constructors; - -// a -public class BaseClass { - - // ()V - public BaseClass() { - System.out.println("Default constructor"); - } - - // (I)V - public BaseClass(int i) { - System.out.println("Int constructor " + i); - } -} 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 71439fd1..00000000 --- a/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.constructors; - -// b -public class Caller { - - // a()V - public void callBaseDefault() { - // a.()V - System.out.println(new BaseClass()); - } - - // b()V - public void callBaseInt() { - // a.(I)V - System.out.println(new BaseClass(5)); - } - - // c()V - public void callSubDefault() { - // d.()V - System.out.println(new SubClass()); - } - - // d()V - public void callSubInt() { - // d.(I)V - System.out.println(new SubClass(6)); - } - - // e()V - public void callSubIntInt() { - // d.(II)V - System.out.println(new SubClass(4, 2)); - } - - // f()V - public void callSubSubInt() { - // e.(I)V - System.out.println(new SubSubClass(3)); - } - - // g()V - public void callDefaultConstructable() { - // c.()V - System.out.println(new DefaultConstructable()); - } -} 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 c3d41705..00000000 --- a/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.constructors; - -public class DefaultConstructable { - // only default constructor -} 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 bc56b3b2..00000000 --- a/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.constructors; - -// d extends a -public class SubClass extends BaseClass { - - // ()V - public SubClass() { - // a.()V - } - - // (I)V - public SubClass(int num) { - // ()V - this(); - System.out.println("SubClass " + num); - } - - // (II)V - public SubClass(int a, int b) { - // (I)V - this(a + b); - } - - // (III)V - public SubClass(int a, int b, int c) { - // a.()V - } -} 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 87b69d32..00000000 --- a/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.constructors; - -// e extends d -public class SubSubClass extends SubClass { - - // (I)V - public SubSubClass(int i) { - // c.(I)V - super(i); - } -} 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 b9c4929c..00000000 --- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.inheritanceTree; - -// a -public abstract class BaseClass { - - // a - private String name; - - // (Ljava/lang/String;)V - protected BaseClass(String name) { - this.name = name; - } - - // a()Ljava/lang/String; - public String getName() { - return name; - } - - // a()V - public abstract void doBaseThings(); -} 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 50e963c0..00000000 --- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.inheritanceTree; - -// b extends a -public abstract class SubclassA extends BaseClass { - - // (Ljava/lang/String;)V - protected SubclassA(String name) { - // call to a.(Ljava/lang/String)V - super(name); - } -} 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 d0dd664d..00000000 --- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.inheritanceTree; - -// c extends a -public class SubclassB extends BaseClass { - - // a - private int numThings; - - // ()V - protected SubclassB() { - // a.(Ljava/lang/String;)V - super("B"); - - // access to a - numThings = 4; - } - - @Override - // a()V - public void doBaseThings() { - // call to a.a()Ljava/lang/String; - System.out.println("Base things by B! " + getName()); - } - - // b()V - public void doBThings() { - // access to a - System.out.println("" + numThings + " B things!"); - } -} 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 c5845702..00000000 --- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.inheritanceTree; - -// d extends b -public class SubsubclassAA extends SubclassA { - - protected SubsubclassAA() { - // call to b.(Ljava/lang/String;)V - super("AA"); - } - - @Override - // a()Ljava/lang/String; - public String getName() { - // call to b.a()Ljava/lang/String; - return "subsub" + super.getName(); - } - - @Override - // a()V - public void doBaseThings() { - // call to d.a()Ljava/lang/String; - System.out.println("Base things by " + getName()); - } -} 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 f652d875..00000000 --- a/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.innerClasses; - -public class A_Anonymous { - - public void foo() { - Runnable runnable = new Runnable() { - @Override - public void run() { - // don't care - } - }; - runnable.run(); - } -} 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 d1b7601f..00000000 --- a/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.innerClasses; - -public class B_AnonymousWithScopeArgs { - - public static void foo(final D_Simple arg) { - System.out.println(new Object() { - @Override - public String toString() { - return arg.toString(); - } - }); - } -} 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 94061faa..00000000 --- a/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.innerClasses; - -@SuppressWarnings("unused") -public class C_ConstructorArgs { - - Inner i; - - public void foo() { - i = new Inner(5); - } - - class Inner { - - private int a; - - public Inner(int a) { - this.a = a; - } - } -} 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 71b3a6d8..00000000 --- a/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.innerClasses; - -public class D_Simple { - - class Inner { - // nothing to do - } -} 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 976ec426..00000000 --- a/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.innerClasses; - -public class E_AnonymousWithOuterAccess { - - // reproduction of error case documented at: - // https://bitbucket.org/cuchaz/enigma/issue/61/stackoverflowerror-when-deobfuscating - - public Object makeInner() { - outerMethod(); - return new Object() { - @Override - public String toString() { - return outerMethod(); - } - }; - } - - private String outerMethod() { - return "foo"; - } -} 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 b1de3c9a..00000000 --- a/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.innerClasses; - -public class F_ClassTree { - - public class Level1 { - - public int f1; - - public class Level2 { - - public int f2; - - public class Level3 { - - public int f3; - } - } - } -} 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 ddc4e319..00000000 --- a/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.loneClass; - -public class LoneClass { - - private String name; - - public LoneClass(String name) { - this.name = name; - } - - public String getName() { - return name; - } -} 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 6f5fe304..00000000 --- a/src/test/java/cuchaz/enigma/inputs/packageAccess/Base.java +++ /dev/null @@ -1,7 +0,0 @@ -package cuchaz.enigma.inputs.packageAccess; - -public class Base { - protected int make() { - return 42; - } -} 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 cf0f6574..00000000 --- a/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java +++ /dev/null @@ -1,12 +0,0 @@ -package cuchaz.enigma.inputs.packageAccess; - -public class SamePackageChild extends Base { - - class Inner { - final int value; - - Inner() { - value = SamePackageChild.this.make(); // no synthetic method - } - } -} 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 19fb19c2..00000000 --- a/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java +++ /dev/null @@ -1,14 +0,0 @@ -package cuchaz.enigma.inputs.packageAccess.sub; - -import cuchaz.enigma.inputs.packageAccess.Base; - -public class OtherPackageChild extends Base { - - class Inner { - final int value; - - Inner() { - value = OtherPackageChild.this.make(); // synthetic method call - } - } -} 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 26f3718c..00000000 --- a/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.translation; - -public class A_Basic { - - public int one; - public float two; - public String three; - - public void m1() { - } - - public int m2() { - return 42; - } - - public void m3(int a1) { - } - - public int m4(int a1) { - return 5; // chosen by fair die roll, guaranteed to be random - } -} 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 fd7f6e7e..00000000 --- a/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.translation; - -public class B_BaseClass { - - public int f1; - public char f2; - - public int m1() { - return 5; - } - - public int m2() { - return 42; - } -} 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 9d74e443..00000000 --- a/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.translation; - -public class C_SubClass extends B_BaseClass { - - public char f2; // shadows B_BaseClass.f2 - public int f3; - public int f4; - - @Override - public int m1() { - return 32; - } - - public int m3() { - return 7; - } -} 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 99c83bbf..00000000 --- a/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.translation; - -import java.util.ArrayList; -import java.util.List; - -public class D_AnonymousTesting { - - public List getObjs() { - List objs = new ArrayList(); - objs.add(new Object() { - @Override - public String toString() { - return "Object!"; - } - }); - return objs; - } -} 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 0b8cf2a5..00000000 --- a/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.translation; - -import java.util.Iterator; - -public class E_Bridges implements Iterator { - - @Override - public boolean hasNext() { - return false; - } - - @Override - public String next() { - // the compiler will generate a bridge for this method - return "foo"; - } - - @Override - public void remove() { - } -} 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 8a92792a..00000000 --- a/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.translation; - -@SuppressWarnings("FinalizeCalledExplicitly") -public class F_ObjectMethods { - - public void callEmAll() - throws Throwable { - clone(); - equals(this); - finalize(); - getClass(); - hashCode(); - notify(); - notifyAll(); - toString(); - wait(); - wait(0); - wait(0, 0); - } -} 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 a1e6a85c..00000000 --- a/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.translation; - -public class G_OuterClass { - - public class A_InnerClass { - - public int f1; - public String f2; - - public void m1() {} - - public class A_InnerInnerClass { - - public int f3; - - public void m2() {} - } - } - - public class B_NamelessClass { - public class A_NamedInnerClass { - public int f4; - } - } -} 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 013c55ae..00000000 --- a/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.translation; - -public class H_NamelessClass { - - public class A_InnerClass { - - public int f1; - public String f2; - - public void m1() {} - - public class A_InnerInnerClass { - - public int f3; - - public void m2() {} - } - } - - public class B_NamelessClass { - public class A_NamedInnerClass { - public int f4; - - public class A_AnotherInnerClass {} - - public class B_YetAnotherInnerClass {} - } - } -} 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 fd2ebdd5..00000000 --- a/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.inputs.translation; - -import java.util.List; -import java.util.Map; - -public class I_Generics { - - public List f1; - public List f2; - public Map f3; - public B_Generic f5; - public B_Generic f6; - - public class A_Type { - } - - public class B_Generic { - public T f4; - - public T m1() { - return null; - } - } -} 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 b3a60056..00000000 --- a/src/test/java/cuchaz/enigma/mapping/TestComments.java +++ /dev/null @@ -1,40 +0,0 @@ -package cuchaz.enigma.mapping; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Path; -import java.nio.file.Paths; - -import cuchaz.enigma.ProgressListener; -import cuchaz.enigma.throwables.MappingParseException; -import cuchaz.enigma.translation.mapping.EntryMapping; -import cuchaz.enigma.translation.mapping.MappingFileNameFormat; -import cuchaz.enigma.translation.mapping.MappingSaveParameters; -import cuchaz.enigma.translation.mapping.serde.EnigmaMappingsReader; -import cuchaz.enigma.translation.mapping.serde.TinyV2Writer; -import cuchaz.enigma.translation.mapping.tree.EntryTree; -import org.junit.Test; - -public class TestComments { - private static Path DIRECTORY; - - static { - try { - DIRECTORY = Paths.get(TestTinyV2InnerClasses.class.getResource("/comments/").toURI()); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - @Test - public void testParseAndWrite() throws IOException, MappingParseException { - ProgressListener progressListener = ProgressListener.none(); - MappingSaveParameters params = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); - EntryTree mappings = EnigmaMappingsReader.DIRECTORY.read( - DIRECTORY, progressListener, params); - - new TinyV2Writer("intermediary", "named") - .write(mappings, DIRECTORY.resolve("convertedtiny.tiny"), progressListener, params); - } - -} \ 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 7cfdacaa..00000000 --- a/src/test/java/cuchaz/enigma/mapping/TestTinyV2InnerClasses.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public - * License v3.0 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * Contributors: - * Jeff Martin - initial API and implementation - ******************************************************************************/ - -package cuchaz.enigma.mapping; - -import cuchaz.enigma.Enigma; -import cuchaz.enigma.EnigmaProject; -import cuchaz.enigma.ProgressListener; -import cuchaz.enigma.translation.mapping.serde.EnigmaMappingsReader; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import org.junit.Test; - -import java.nio.file.Path; -import java.nio.file.Paths; - -import static cuchaz.enigma.TestEntryFactory.newClass; - -public final class TestTinyV2InnerClasses { - private Path jar; - private Path mappings; - - public TestTinyV2InnerClasses() throws Exception { - jar = Paths.get("build/test-obf/innerClasses.jar"); - mappings = Paths.get(TestTinyV2InnerClasses.class.getResource("/tinyV2InnerClasses/").toURI()); - } - -// @Test - public void testMappings() throws Exception { - EnigmaProject project = Enigma.create().openJar(jar, ProgressListener.none()); - project.setMappings(EnigmaMappingsReader.DIRECTORY.read(mappings, ProgressListener.none(), project.getEnigma().getProfile().getMappingSaveParameters())); - - } -} 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 021a90cb..00000000 --- a/src/test/java/cuchaz/enigma/mapping/TestV2Main.java +++ /dev/null @@ -1,24 +0,0 @@ -package cuchaz.enigma.mapping; - -import cuchaz.enigma.ProgressListener; -import cuchaz.enigma.translation.mapping.EntryMapping; -import cuchaz.enigma.translation.mapping.MappingFileNameFormat; -import cuchaz.enigma.translation.mapping.MappingSaveParameters; -import cuchaz.enigma.translation.mapping.serde.EnigmaMappingsReader; -import cuchaz.enigma.translation.mapping.serde.TinyV2Writer; -import cuchaz.enigma.translation.mapping.tree.EntryTree; - -import java.nio.file.Path; -import java.nio.file.Paths; - -public final class TestV2Main { - public static void main(String... args) throws Exception { - Path path = Paths.get(TestV2Main.class.getResource("/tinyV2InnerClasses/").toURI()); - - MappingSaveParameters parameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); - - EntryTree tree = EnigmaMappingsReader.DIRECTORY.read(path, ProgressListener.none(), parameters); - - new TinyV2Writer("obf", "deobf").write(tree, Paths.get("currentYarn.tiny"), ProgressListener.none(), parameters); - } -} 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 c08765c7..00000000 --- a/src/test/java/cuchaz/enigma/resources/translation.mappings +++ /dev/null @@ -1,41 +0,0 @@ -CLASS a deobf/A_Basic - FIELD a f1 I - FIELD a f2 F - FIELD a f3 Ljava/lang/String; - METHOD a m1 ()V - METHOD a m2 ()I - METHOD a m3 (I)V - METHOD a m4 (I)I -CLASS b deobf/B_BaseClass - FIELD a f1 I - FIELD a f2 C - METHOD a m1 ()I - METHOD b m2 ()I -CLASS c deobf/C_SubClass - FIELD b f2 C - FIELD b f3 I - FIELD c f4 I - METHOD a m1 ()I - METHOD c m3 ()I -CLASS g deobf/G_OuterClass - CLASS g$a A_InnerClass - CLASS g$a$a A_InnerInnerClass - FIELD a f3 I - METHOD a m2 ()V - FIELD a f1 I - FIELD a f2 Ljava/lang/String; - METHOD a m1 ()V - CLASS g$b - CLASS g$b$a A_NamedInnerClass - FIELD a f4 I -CLASS h -CLASS i deobf/I_Generics - CLASS i$a A_Type - CLASS i$b B_Generic - FIELD a f4 Ljava/lang/Object; - METHOD a m1 ()Ljava/lang/Object; - FIELD a f1 Ljava/util/List; - FIELD b f2 Ljava/util/List; - FIELD a f3 Ljava/util/Map; - FIELD a f5 Li$b; - 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 d1345583..00000000 --- a/src/test/resources/comments/test.mapping +++ /dev/null @@ -1,18 +0,0 @@ -CLASS net/minecraft/class_1158 net/minecraft/util/math/Quaternion - COMMENT it circel - COMMENT next line - FIELD field_21493 IDENTITY Lnet/minecraft/class_1158; - COMMENT moar comment thing - COMMENT near field - METHOD foo bar (FFFF)V - COMMENT method comment - COMMENT second line - COMMENT third line - ARG 1 b - COMMENT arg comment - CLASS old new - COMMENT inner comment - FIELD field_19263 iterator Lnet/minecraft/class_3980; - METHOD tryAdvance (Ljava/util/function/Consumer;)Z - ARG 1 consumer - 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 0a86def0..00000000 --- a/src/test/resources/packageAccess/correctMappings/base/Base.mapping +++ /dev/null @@ -1 +0,0 @@ -CLASS 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 dd4c2083..00000000 --- a/src/test/resources/packageAccess/correctMappings/base/One.mapping +++ /dev/null @@ -1 +0,0 @@ -CLASS 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 a179349c..00000000 --- a/src/test/resources/packageAccess/correctMappings/two/Two.mapping +++ /dev/null @@ -1 +0,0 @@ -CLASS 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 0a86def0..00000000 --- a/src/test/resources/packageAccess/wrongMappings/base/Base.mapping +++ /dev/null @@ -1 +0,0 @@ -CLASS 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 15b42cf5..00000000 --- a/src/test/resources/packageAccess/wrongMappings/one/One.mapping +++ /dev/null @@ -1 +0,0 @@ -CLASS 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 a179349c..00000000 --- a/src/test/resources/packageAccess/wrongMappings/two/Two.mapping +++ /dev/null @@ -1 +0,0 @@ -CLASS c two/Two diff --git a/src/test/resources/proguard-build.conf b/src/test/resources/proguard-build.conf deleted file mode 100644 index ba3575ae..00000000 --- a/src/test/resources/proguard-build.conf +++ /dev/null @@ -1,6 +0,0 @@ --dontoptimize --dontobfuscate --dontwarn --keep class cuchaz.enigma.Main { static void main(java.lang.String[]); } --keep class cuchaz.enigma.CommandMain { static void main(java.lang.String[]); } --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 9411d269..00000000 --- a/src/test/resources/proguard-test.conf +++ /dev/null @@ -1,8 +0,0 @@ --overloadaggressively --repackageclasses --allowaccessmodification --dontoptimize --dontshrink --keepparameternames --keepattributes --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 f9b04428..00000000 --- a/src/test/resources/tinyV2InnerClasses/c.mapping +++ /dev/null @@ -1,2 +0,0 @@ -CLASS c - 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 8d43ba90..00000000 --- a/src/test/resources/tinyV2InnerClasses/cuchaz/enigma/Dad.mapping +++ /dev/null @@ -1,5 +0,0 @@ -CLASS f cuchaz/enigma/Dad - CLASS a One - CLASS a Two - CLASS a - FIELD a value I -- cgit v1.2.3