summaryrefslogtreecommitdiff
path: root/src/test/java/cuchaz/enigma/TestInnerClasses.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestInnerClasses.java')
-rw-r--r--src/test/java/cuchaz/enigma/TestInnerClasses.java85
1 files changed, 0 insertions, 85 deletions
diff --git a/src/test/java/cuchaz/enigma/TestInnerClasses.java b/src/test/java/cuchaz/enigma/TestInnerClasses.java
deleted file mode 100644
index 85c72f8..0000000
--- a/src/test/java/cuchaz/enigma/TestInnerClasses.java
+++ /dev/null
@@ -1,85 +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.analysis.ClassCache;
15import cuchaz.enigma.analysis.index.JarIndex;
16import cuchaz.enigma.source.Decompiler;
17import cuchaz.enigma.source.Decompilers;
18import cuchaz.enigma.source.SourceSettings;
19import cuchaz.enigma.translation.representation.entry.ClassEntry;
20import org.junit.Test;
21
22import java.nio.file.Paths;
23
24import static cuchaz.enigma.TestEntryFactory.newClass;
25import static org.hamcrest.MatcherAssert.assertThat;
26import static org.hamcrest.Matchers.is;
27
28public class TestInnerClasses {
29
30 private static final ClassEntry SimpleOuter = newClass("d");
31 private static final ClassEntry SimpleInner = newClass("d$a");
32 private static final ClassEntry ConstructorArgsOuter = newClass("c");
33 private static final ClassEntry ConstructorArgsInner = newClass("c$a");
34 private static final ClassEntry ClassTreeRoot = newClass("f");
35 private static final ClassEntry ClassTreeLevel1 = newClass("f$a");
36 private static final ClassEntry ClassTreeLevel2 = newClass("f$a$a");
37 private static final ClassEntry ClassTreeLevel3 = newClass("f$a$a$a");
38 private final JarIndex index;
39 private final Decompiler decompiler;
40
41 public TestInnerClasses() throws Exception {
42 ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/innerClasses.jar"));
43 index = classCache.index(ProgressListener.none());
44 decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false));
45 }
46
47 @Test
48 public void simple() {
49 decompile(SimpleOuter);
50 }
51
52 @Test
53 public void constructorArgs() {
54 decompile(ConstructorArgsOuter);
55 }
56
57 @Test
58 public void classTree() {
59
60 // root level
61 assertThat(index.getEntryIndex().hasClass(ClassTreeRoot), is(true));
62
63 // level 1
64 ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName()
65 + "$" + ClassTreeLevel1.getSimpleName());
66 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true));
67
68 // level 2
69 fullClassEntry = new ClassEntry(ClassTreeRoot.getName()
70 + "$" + ClassTreeLevel1.getSimpleName()
71 + "$" + ClassTreeLevel2.getSimpleName());
72 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true));
73
74 // level 3
75 fullClassEntry = new ClassEntry(ClassTreeRoot.getName()
76 + "$" + ClassTreeLevel1.getSimpleName()
77 + "$" + ClassTreeLevel2.getSimpleName()
78 + "$" + ClassTreeLevel3.getSimpleName());
79 assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true));
80 }
81
82 private void decompile(ClassEntry classEntry) {
83 decompiler.getSource(classEntry.getName());
84 }
85}