diff options
| author | 2015-05-21 23:30:00 +0100 | |
|---|---|---|
| committer | 2015-05-21 23:30:00 +0100 | |
| commit | e3f452250e51b7271f3989c7dfd12e4422934942 (patch) | |
| tree | 5aa482f9a6e21eb318a3e23e7d8274d77c73faf6 /test/cuchaz/enigma/TestTokensConstructors.java | |
| download | enigma-fork-e3f452250e51b7271f3989c7dfd12e4422934942.tar.gz enigma-fork-e3f452250e51b7271f3989c7dfd12e4422934942.tar.xz enigma-fork-e3f452250e51b7271f3989c7dfd12e4422934942.zip | |
Support Gradle alongside SSJB
This makes builds faster, simpler and better automated but still keeps
Cuchaz happy. :)
Diffstat (limited to 'test/cuchaz/enigma/TestTokensConstructors.java')
| -rw-r--r-- | test/cuchaz/enigma/TestTokensConstructors.java | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/test/cuchaz/enigma/TestTokensConstructors.java b/test/cuchaz/enigma/TestTokensConstructors.java new file mode 100644 index 0000000..66c6fd1 --- /dev/null +++ b/test/cuchaz/enigma/TestTokensConstructors.java | |||
| @@ -0,0 +1,136 @@ | |||
| 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 | package cuchaz.enigma; | ||
| 12 | |||
| 13 | import static cuchaz.enigma.TestEntryFactory.*; | ||
| 14 | import static org.hamcrest.MatcherAssert.*; | ||
| 15 | import static org.hamcrest.Matchers.*; | ||
| 16 | |||
| 17 | import java.util.jar.JarFile; | ||
| 18 | |||
| 19 | import org.junit.Test; | ||
| 20 | |||
| 21 | import cuchaz.enigma.mapping.BehaviorEntry; | ||
| 22 | |||
| 23 | public class TestTokensConstructors extends TokenChecker { | ||
| 24 | |||
| 25 | public TestTokensConstructors() | ||
| 26 | throws Exception { | ||
| 27 | super(new JarFile("build/test-obf/constructors.jar")); | ||
| 28 | } | ||
| 29 | |||
| 30 | @Test | ||
| 31 | public void baseDeclarations() { | ||
| 32 | assertThat(getDeclarationToken(newConstructor("none/a", "()V")), is("a")); | ||
| 33 | assertThat(getDeclarationToken(newConstructor("none/a", "(I)V")), is("a")); | ||
| 34 | } | ||
| 35 | |||
| 36 | @Test | ||
| 37 | public void subDeclarations() { | ||
| 38 | assertThat(getDeclarationToken(newConstructor("none/d", "()V")), is("d")); | ||
| 39 | assertThat(getDeclarationToken(newConstructor("none/d", "(I)V")), is("d")); | ||
| 40 | assertThat(getDeclarationToken(newConstructor("none/d", "(II)V")), is("d")); | ||
| 41 | assertThat(getDeclarationToken(newConstructor("none/d", "(III)V")), is("d")); | ||
| 42 | } | ||
| 43 | |||
| 44 | @Test | ||
| 45 | public void subsubDeclarations() { | ||
| 46 | assertThat(getDeclarationToken(newConstructor("none/e", "(I)V")), is("e")); | ||
| 47 | } | ||
| 48 | |||
| 49 | @Test | ||
| 50 | public void defaultDeclarations() { | ||
| 51 | assertThat(getDeclarationToken(newConstructor("none/c", "()V")), nullValue()); | ||
| 52 | } | ||
| 53 | |||
| 54 | @Test | ||
| 55 | public void baseDefaultReferences() { | ||
| 56 | BehaviorEntry source = newConstructor("none/a", "()V"); | ||
| 57 | assertThat( | ||
| 58 | getReferenceTokens(newBehaviorReferenceByMethod(source, "none/b", "a", "()V")), | ||
| 59 | containsInAnyOrder("a") | ||
| 60 | ); | ||
| 61 | assertThat( | ||
| 62 | getReferenceTokens(newBehaviorReferenceByConstructor(source, "none/d", "()V")), | ||
| 63 | is(empty()) // implicit call, not decompiled to token | ||
| 64 | ); | ||
| 65 | assertThat( | ||
| 66 | getReferenceTokens(newBehaviorReferenceByConstructor(source, "none/d", "(III)V")), | ||
| 67 | is(empty()) // implicit call, not decompiled to token | ||
| 68 | ); | ||
| 69 | } | ||
| 70 | |||
| 71 | @Test | ||
| 72 | public void baseIntReferences() { | ||
| 73 | BehaviorEntry source = newConstructor("none/a", "(I)V"); | ||
| 74 | assertThat( | ||
| 75 | getReferenceTokens(newBehaviorReferenceByMethod(source, "none/b", "b", "()V")), | ||
| 76 | containsInAnyOrder("a") | ||
| 77 | ); | ||
| 78 | } | ||
| 79 | |||
| 80 | @Test | ||
| 81 | public void subDefaultReferences() { | ||
| 82 | BehaviorEntry source = newConstructor("none/d", "()V"); | ||
| 83 | assertThat( | ||
| 84 | getReferenceTokens(newBehaviorReferenceByMethod(source, "none/b", "c", "()V")), | ||
| 85 | containsInAnyOrder("d") | ||
| 86 | ); | ||
| 87 | assertThat( | ||
| 88 | getReferenceTokens(newBehaviorReferenceByConstructor(source, "none/d", "(I)V")), | ||
| 89 | containsInAnyOrder("this") | ||
| 90 | ); | ||
| 91 | } | ||
| 92 | |||
| 93 | @Test | ||
| 94 | public void subIntReferences() { | ||
| 95 | BehaviorEntry source = newConstructor("none/d", "(I)V"); | ||
| 96 | assertThat(getReferenceTokens( | ||
| 97 | newBehaviorReferenceByMethod(source, "none/b", "d", "()V")), | ||
| 98 | containsInAnyOrder("d") | ||
| 99 | ); | ||
| 100 | assertThat(getReferenceTokens( | ||
| 101 | newBehaviorReferenceByConstructor(source, "none/d", "(II)V")), | ||
| 102 | containsInAnyOrder("this") | ||
| 103 | ); | ||
| 104 | assertThat(getReferenceTokens( | ||
| 105 | newBehaviorReferenceByConstructor(source, "none/e", "(I)V")), | ||
| 106 | containsInAnyOrder("super") | ||
| 107 | ); | ||
| 108 | } | ||
| 109 | |||
| 110 | @Test | ||
| 111 | public void subIntIntReferences() { | ||
| 112 | BehaviorEntry source = newConstructor("none/d", "(II)V"); | ||
| 113 | assertThat( | ||
| 114 | getReferenceTokens(newBehaviorReferenceByMethod(source, "none/b", "e", "()V")), | ||
| 115 | containsInAnyOrder("d") | ||
| 116 | ); | ||
| 117 | } | ||
| 118 | |||
| 119 | @Test | ||
| 120 | public void subsubIntReferences() { | ||
| 121 | BehaviorEntry source = newConstructor("none/e", "(I)V"); | ||
| 122 | assertThat( | ||
| 123 | getReferenceTokens(newBehaviorReferenceByMethod(source, "none/b", "f", "()V")), | ||
| 124 | containsInAnyOrder("e") | ||
| 125 | ); | ||
| 126 | } | ||
| 127 | |||
| 128 | @Test | ||
| 129 | public void defaultConstructableReferences() { | ||
| 130 | BehaviorEntry source = newConstructor("none/c", "()V"); | ||
| 131 | assertThat( | ||
| 132 | getReferenceTokens(newBehaviorReferenceByMethod(source, "none/b", "g", "()V")), | ||
| 133 | containsInAnyOrder("c") | ||
| 134 | ); | ||
| 135 | } | ||
| 136 | } | ||