summaryrefslogtreecommitdiff
path: root/src/test/java/cuchaz/enigma/TestTokensConstructors.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestTokensConstructors.java')
-rw-r--r--src/test/java/cuchaz/enigma/TestTokensConstructors.java137
1 files changed, 0 insertions, 137 deletions
diff --git a/src/test/java/cuchaz/enigma/TestTokensConstructors.java b/src/test/java/cuchaz/enigma/TestTokensConstructors.java
deleted file mode 100644
index 0398de4..0000000
--- a/src/test/java/cuchaz/enigma/TestTokensConstructors.java
+++ /dev/null
@@ -1,137 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma;
13
14import cuchaz.enigma.translation.representation.entry.MethodEntry;
15import org.junit.Test;
16
17import java.nio.file.Paths;
18
19import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
20import static cuchaz.enigma.TestEntryFactory.newMethod;
21import static org.hamcrest.MatcherAssert.assertThat;
22import static org.hamcrest.Matchers.*;
23
24public class TestTokensConstructors extends TokenChecker {
25
26 public TestTokensConstructors()
27 throws Exception {
28 super(Paths.get("build/test-obf/constructors.jar"));
29 }
30
31 @Test
32 public void baseDeclarations() {
33 assertThat(getDeclarationToken(newMethod("a", "<init>", "()V")), is("a"));
34 assertThat(getDeclarationToken(newMethod("a", "<init>", "(I)V")), is("a"));
35 }
36
37 @Test
38 public void subDeclarations() {
39 assertThat(getDeclarationToken(newMethod("d", "<init>", "()V")), is("d"));
40 assertThat(getDeclarationToken(newMethod("d", "<init>", "(I)V")), is("d"));
41 assertThat(getDeclarationToken(newMethod("d", "<init>", "(II)V")), is("d"));
42 assertThat(getDeclarationToken(newMethod("d", "<init>", "(III)V")), is("d"));
43 }
44
45 @Test
46 public void subsubDeclarations() {
47 assertThat(getDeclarationToken(newMethod("e", "<init>", "(I)V")), is("e"));
48 }
49
50 @Test
51 public void defaultDeclarations() {
52 assertThat(getDeclarationToken(newMethod("c", "<init>", "()V")), nullValue());
53 }
54
55 @Test
56 public void baseDefaultReferences() {
57 MethodEntry source = newMethod("a", "<init>", "()V");
58 assertThat(
59 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "a", "()V")),
60 containsInAnyOrder("a")
61 );
62 assertThat(
63 getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "()V")),
64 is(empty()) // implicit call, not decompiled to token
65 );
66 assertThat(
67 getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(III)V")),
68 is(empty()) // implicit call, not decompiled to token
69 );
70 }
71
72 @Test
73 public void baseIntReferences() {
74 MethodEntry source = newMethod("a", "<init>", "(I)V");
75 assertThat(
76 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "b", "()V")),
77 containsInAnyOrder("a")
78 );
79 }
80
81 @Test
82 public void subDefaultReferences() {
83 MethodEntry source = newMethod("d", "<init>", "()V");
84 assertThat(
85 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "c", "()V")),
86 containsInAnyOrder("d")
87 );
88 assertThat(
89 getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(I)V")),
90 containsInAnyOrder("this")
91 );
92 }
93
94 @Test
95 public void subIntReferences() {
96 MethodEntry source = newMethod("d", "<init>", "(I)V");
97 assertThat(getReferenceTokens(
98 newBehaviorReferenceByMethod(source, "b", "d", "()V")),
99 containsInAnyOrder("d")
100 );
101 assertThat(getReferenceTokens(
102 newBehaviorReferenceByMethod(source, "d", "<init>", "(II)V")),
103 containsInAnyOrder("this")
104 );
105 assertThat(getReferenceTokens(
106 newBehaviorReferenceByMethod(source, "e", "<init>", "(I)V")),
107 containsInAnyOrder("super")
108 );
109 }
110
111 @Test
112 public void subIntIntReferences() {
113 MethodEntry source = newMethod("d", "<init>", "(II)V");
114 assertThat(
115 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "e", "()V")),
116 containsInAnyOrder("d")
117 );
118 }
119
120 @Test
121 public void subsubIntReferences() {
122 MethodEntry source = newMethod("e", "<init>", "(I)V");
123 assertThat(
124 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "f", "()V")),
125 containsInAnyOrder("e")
126 );
127 }
128
129 @Test
130 public void defaultConstructableReferences() {
131 MethodEntry source = newMethod("c", "<init>", "()V");
132 assertThat(
133 getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "g", "()V")),
134 containsInAnyOrder("c")
135 );
136 }
137}