diff options
| author | 2018-07-18 13:46:00 +0100 | |
|---|---|---|
| committer | 2018-07-18 13:46:00 +0100 | |
| commit | 1ebe691c12f68beea378b133ddc4bcbde7f3f795 (patch) | |
| tree | fb051d9fde5644bd144a7e9d7bcecc70a256359c /src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java | |
| parent | Recursively rebuild method names (diff) | |
| parent | Update version number (diff) | |
| download | enigma-fork-1ebe691c12f68beea378b133ddc4bcbde7f3f795.tar.gz enigma-fork-1ebe691c12f68beea378b133ddc4bcbde7f3f795.tar.xz enigma-fork-1ebe691c12f68beea378b133ddc4bcbde7f3f795.zip | |
Merge pull request #62 from OpenModLoader/asm
ASM based class translator
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java')
| -rw-r--r-- | src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java index edb859a..763639a 100644 --- a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java +++ b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java | |||
| @@ -13,22 +13,20 @@ package cuchaz.enigma; | |||
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.EntryReference; | 14 | import cuchaz.enigma.analysis.EntryReference; |
| 15 | import cuchaz.enigma.analysis.JarIndex; | 15 | import cuchaz.enigma.analysis.JarIndex; |
| 16 | import cuchaz.enigma.mapping.BehaviorEntry; | 16 | import cuchaz.enigma.analysis.ParsedJar; |
| 17 | import cuchaz.enigma.mapping.ClassEntry; | 17 | import cuchaz.enigma.mapping.entry.ClassEntry; |
| 18 | import cuchaz.enigma.mapping.entry.MethodDefEntry; | ||
| 19 | import cuchaz.enigma.mapping.entry.MethodEntry; | ||
| 20 | import cuchaz.enigma.mapping.entry.ReferencedEntryPool; | ||
| 18 | import org.junit.Test; | 21 | import org.junit.Test; |
| 19 | 22 | ||
| 20 | import java.io.File; | 23 | import java.io.File; |
| 21 | import java.util.Collection; | 24 | import java.util.Collection; |
| 22 | import java.util.jar.JarFile; | 25 | import java.util.jar.JarFile; |
| 23 | 26 | ||
| 24 | import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByConstructor; | 27 | import static cuchaz.enigma.TestEntryFactory.*; |
| 25 | import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; | ||
| 26 | import static cuchaz.enigma.TestEntryFactory.newClass; | ||
| 27 | import static cuchaz.enigma.TestEntryFactory.newConstructor; | ||
| 28 | import static org.hamcrest.MatcherAssert.assertThat; | 28 | import static org.hamcrest.MatcherAssert.assertThat; |
| 29 | import static org.hamcrest.Matchers.containsInAnyOrder; | 29 | import static org.hamcrest.Matchers.*; |
| 30 | import static org.hamcrest.Matchers.empty; | ||
| 31 | import static org.hamcrest.Matchers.is; | ||
| 32 | 30 | ||
| 33 | public class TestJarIndexConstructorReferences { | 31 | public class TestJarIndexConstructorReferences { |
| 34 | 32 | ||
| @@ -41,90 +39,90 @@ public class TestJarIndexConstructorReferences { | |||
| 41 | private ClassEntry callerClass = newClass("b"); | 39 | private ClassEntry callerClass = newClass("b"); |
| 42 | 40 | ||
| 43 | public TestJarIndexConstructorReferences() | 41 | public TestJarIndexConstructorReferences() |
| 44 | throws Exception { | 42 | throws Exception { |
| 45 | File jarFile = new File("build/test-obf/constructors.jar"); | 43 | File jarFile = new File("build/test-obf/constructors.jar"); |
| 46 | index = new JarIndex(); | 44 | index = new JarIndex(new ReferencedEntryPool()); |
| 47 | index.indexJar(new JarFile(jarFile), false); | 45 | index.indexJar(new ParsedJar(new JarFile(jarFile)), false); |
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | @Test | 48 | @Test |
| 51 | public void obfEntries() { | 49 | public void obfEntries() { |
| 52 | assertThat(index.getObfClassEntries(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, | 50 | assertThat(index.getObfClassEntries(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, |
| 53 | subClass, subsubClass, defaultClass, callerClass)); | 51 | subClass, subsubClass, defaultClass, callerClass)); |
| 54 | } | 52 | } |
| 55 | 53 | ||
| 56 | @Test | 54 | @Test |
| 57 | @SuppressWarnings("unchecked") | 55 | @SuppressWarnings("unchecked") |
| 58 | public void baseDefault() { | 56 | public void baseDefault() { |
| 59 | BehaviorEntry source = newConstructor(baseClass, "()V"); | 57 | MethodEntry source = newMethod(baseClass, "<init>", "()V"); |
| 60 | Collection<EntryReference<BehaviorEntry, BehaviorEntry>> references = index.getBehaviorReferences(source); | 58 | Collection<EntryReference<MethodEntry, MethodDefEntry>> references = index.getMethodsReferencing(source); |
| 61 | assertThat(references, containsInAnyOrder( | 59 | assertThat(references, containsInAnyOrder( |
| 62 | newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), | 60 | newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), |
| 63 | newBehaviorReferenceByConstructor(source, subClass.getName(), "()V"), | 61 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "()V"), |
| 64 | newBehaviorReferenceByConstructor(source, subClass.getName(), "(III)V") | 62 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(III)V") |
| 65 | )); | 63 | )); |
| 66 | } | 64 | } |
| 67 | 65 | ||
| 68 | @Test | 66 | @Test |
| 69 | @SuppressWarnings("unchecked") | 67 | @SuppressWarnings("unchecked") |
| 70 | public void baseInt() { | 68 | public void baseInt() { |
| 71 | BehaviorEntry source = newConstructor(baseClass, "(I)V"); | 69 | MethodEntry source = newMethod(baseClass, "<init>", "(I)V"); |
| 72 | assertThat(index.getBehaviorReferences(source), containsInAnyOrder( | 70 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( |
| 73 | newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") | 71 | newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") |
| 74 | )); | 72 | )); |
| 75 | } | 73 | } |
| 76 | 74 | ||
| 77 | @Test | 75 | @Test |
| 78 | @SuppressWarnings("unchecked") | 76 | @SuppressWarnings("unchecked") |
| 79 | public void subDefault() { | 77 | public void subDefault() { |
| 80 | BehaviorEntry source = newConstructor(subClass, "()V"); | 78 | MethodEntry source = newMethod(subClass, "<init>", "()V"); |
| 81 | assertThat(index.getBehaviorReferences(source), containsInAnyOrder( | 79 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( |
| 82 | newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"), | 80 | newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"), |
| 83 | newBehaviorReferenceByConstructor(source, subClass.getName(), "(I)V") | 81 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(I)V") |
| 84 | )); | 82 | )); |
| 85 | } | 83 | } |
| 86 | 84 | ||
| 87 | @Test | 85 | @Test |
| 88 | @SuppressWarnings("unchecked") | 86 | @SuppressWarnings("unchecked") |
| 89 | public void subInt() { | 87 | public void subInt() { |
| 90 | BehaviorEntry source = newConstructor(subClass, "(I)V"); | 88 | MethodEntry source = newMethod(subClass, "<init>", "(I)V"); |
| 91 | assertThat(index.getBehaviorReferences(source), containsInAnyOrder( | 89 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( |
| 92 | newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"), | 90 | newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"), |
| 93 | newBehaviorReferenceByConstructor(source, subClass.getName(), "(II)V"), | 91 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(II)V"), |
| 94 | newBehaviorReferenceByConstructor(source, subsubClass.getName(), "(I)V") | 92 | newBehaviorReferenceByMethod(source, subsubClass.getName(), "<init>", "(I)V") |
| 95 | )); | 93 | )); |
| 96 | } | 94 | } |
| 97 | 95 | ||
| 98 | @Test | 96 | @Test |
| 99 | @SuppressWarnings("unchecked") | 97 | @SuppressWarnings("unchecked") |
| 100 | public void subIntInt() { | 98 | public void subIntInt() { |
| 101 | BehaviorEntry source = newConstructor(subClass, "(II)V"); | 99 | MethodEntry source = newMethod(subClass, "<init>", "(II)V"); |
| 102 | assertThat(index.getBehaviorReferences(source), containsInAnyOrder( | 100 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( |
| 103 | newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") | 101 | newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") |
| 104 | )); | 102 | )); |
| 105 | } | 103 | } |
| 106 | 104 | ||
| 107 | @Test | 105 | @Test |
| 108 | public void subIntIntInt() { | 106 | public void subIntIntInt() { |
| 109 | BehaviorEntry source = newConstructor(subClass, "(III)V"); | 107 | MethodEntry source = newMethod(subClass, "<init>", "(III)V"); |
| 110 | assertThat(index.getBehaviorReferences(source), is(empty())); | 108 | assertThat(index.getMethodsReferencing(source), is(empty())); |
| 111 | } | 109 | } |
| 112 | 110 | ||
| 113 | @Test | 111 | @Test |
| 114 | @SuppressWarnings("unchecked") | 112 | @SuppressWarnings("unchecked") |
| 115 | public void subsubInt() { | 113 | public void subsubInt() { |
| 116 | BehaviorEntry source = newConstructor(subsubClass, "(I)V"); | 114 | MethodEntry source = newMethod(subsubClass, "<init>", "(I)V"); |
| 117 | assertThat(index.getBehaviorReferences(source), containsInAnyOrder( | 115 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( |
| 118 | newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") | 116 | newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") |
| 119 | )); | 117 | )); |
| 120 | } | 118 | } |
| 121 | 119 | ||
| 122 | @Test | 120 | @Test |
| 123 | @SuppressWarnings("unchecked") | 121 | @SuppressWarnings("unchecked") |
| 124 | public void defaultConstructable() { | 122 | public void defaultConstructable() { |
| 125 | BehaviorEntry source = newConstructor(defaultClass, "()V"); | 123 | MethodEntry source = newMethod(defaultClass, "<init>", "()V"); |
| 126 | assertThat(index.getBehaviorReferences(source), containsInAnyOrder( | 124 | assertThat(index.getMethodsReferencing(source), containsInAnyOrder( |
| 127 | newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V") | 125 | newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V") |
| 128 | )); | 126 | )); |
| 129 | } | 127 | } |
| 130 | } | 128 | } |