diff options
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java')
| -rw-r--r-- | src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java deleted file mode 100644 index 48975c8..0000000 --- a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java +++ /dev/null | |||
| @@ -1,124 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | |||
| 12 | package cuchaz.enigma; | ||
| 13 | |||
| 14 | import cuchaz.enigma.analysis.ClassCache; | ||
| 15 | import cuchaz.enigma.analysis.EntryReference; | ||
| 16 | import cuchaz.enigma.analysis.index.JarIndex; | ||
| 17 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 18 | import cuchaz.enigma.translation.representation.entry.MethodDefEntry; | ||
| 19 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 20 | import org.junit.Test; | ||
| 21 | |||
| 22 | import java.nio.file.Paths; | ||
| 23 | import java.util.Collection; | ||
| 24 | |||
| 25 | import static cuchaz.enigma.TestEntryFactory.*; | ||
| 26 | import static org.hamcrest.MatcherAssert.assertThat; | ||
| 27 | import static org.hamcrest.Matchers.*; | ||
| 28 | |||
| 29 | public class TestJarIndexConstructorReferences { | ||
| 30 | |||
| 31 | private JarIndex index; | ||
| 32 | |||
| 33 | private ClassEntry baseClass = newClass("a"); | ||
| 34 | private ClassEntry subClass = newClass("d"); | ||
| 35 | private ClassEntry subsubClass = newClass("e"); | ||
| 36 | private ClassEntry defaultClass = newClass("c"); | ||
| 37 | private ClassEntry callerClass = newClass("b"); | ||
| 38 | |||
| 39 | public TestJarIndexConstructorReferences() throws Exception { | ||
| 40 | ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/constructors.jar")); | ||
| 41 | index = classCache.index(ProgressListener.none()); | ||
| 42 | } | ||
| 43 | |||
| 44 | @Test | ||
| 45 | public void obfEntries() { | ||
| 46 | assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, | ||
| 47 | subClass, subsubClass, defaultClass, callerClass)); | ||
| 48 | } | ||
| 49 | |||
| 50 | @Test | ||
| 51 | @SuppressWarnings("unchecked") | ||
| 52 | public void baseDefault() { | ||
| 53 | MethodEntry source = newMethod(baseClass, "<init>", "()V"); | ||
| 54 | Collection<EntryReference<MethodEntry, MethodDefEntry>> references = index.getReferenceIndex().getReferencesToMethod(source); | ||
| 55 | assertThat(references, containsInAnyOrder( | ||
| 56 | newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), | ||
| 57 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "()V"), | ||
| 58 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(III)V") | ||
| 59 | )); | ||
| 60 | } | ||
| 61 | |||
| 62 | @Test | ||
| 63 | @SuppressWarnings("unchecked") | ||
| 64 | public void baseInt() { | ||
| 65 | MethodEntry source = newMethod(baseClass, "<init>", "(I)V"); | ||
| 66 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( | ||
| 67 | newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") | ||
| 68 | )); | ||
| 69 | } | ||
| 70 | |||
| 71 | @Test | ||
| 72 | @SuppressWarnings("unchecked") | ||
| 73 | public void subDefault() { | ||
| 74 | MethodEntry source = newMethod(subClass, "<init>", "()V"); | ||
| 75 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( | ||
| 76 | newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"), | ||
| 77 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(I)V") | ||
| 78 | )); | ||
| 79 | } | ||
| 80 | |||
| 81 | @Test | ||
| 82 | @SuppressWarnings("unchecked") | ||
| 83 | public void subInt() { | ||
| 84 | MethodEntry source = newMethod(subClass, "<init>", "(I)V"); | ||
| 85 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( | ||
| 86 | newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"), | ||
| 87 | newBehaviorReferenceByMethod(source, subClass.getName(), "<init>", "(II)V"), | ||
| 88 | newBehaviorReferenceByMethod(source, subsubClass.getName(), "<init>", "(I)V") | ||
| 89 | )); | ||
| 90 | } | ||
| 91 | |||
| 92 | @Test | ||
| 93 | @SuppressWarnings("unchecked") | ||
| 94 | public void subIntInt() { | ||
| 95 | MethodEntry source = newMethod(subClass, "<init>", "(II)V"); | ||
| 96 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( | ||
| 97 | newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") | ||
| 98 | )); | ||
| 99 | } | ||
| 100 | |||
| 101 | @Test | ||
| 102 | public void subIntIntInt() { | ||
| 103 | MethodEntry source = newMethod(subClass, "<init>", "(III)V"); | ||
| 104 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), is(empty())); | ||
| 105 | } | ||
| 106 | |||
| 107 | @Test | ||
| 108 | @SuppressWarnings("unchecked") | ||
| 109 | public void subsubInt() { | ||
| 110 | MethodEntry source = newMethod(subsubClass, "<init>", "(I)V"); | ||
| 111 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( | ||
| 112 | newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") | ||
| 113 | )); | ||
| 114 | } | ||
| 115 | |||
| 116 | @Test | ||
| 117 | @SuppressWarnings("unchecked") | ||
| 118 | public void defaultConstructable() { | ||
| 119 | MethodEntry source = newMethod(defaultClass, "<init>", "()V"); | ||
| 120 | assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( | ||
| 121 | newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V") | ||
| 122 | )); | ||
| 123 | } | ||
| 124 | } | ||