diff options
author | Roman Shevchenko <roman.shevchenko@jetbrains.com> | 2014-09-09 21:47:56 +0400 |
---|---|---|
committer | Roman Shevchenko <roman.shevchenko@jetbrains.com> | 2014-09-09 21:48:38 +0400 |
commit | ccd7b93497e2b82fc20b07208b2beb9753afe1a2 (patch) | |
tree | f17360f79804a71f813231e8d5569c39753bb060 /test/org | |
parent | cf72873535fcdf845c9de9683c6ca542ca8c1ee6 (diff) | |
download | fernflower-ccd7b93497e2b82fc20b07208b2beb9753afe1a2.tar fernflower-ccd7b93497e2b82fc20b07208b2beb9753afe1a2.tar.gz fernflower-ccd7b93497e2b82fc20b07208b2beb9753afe1a2.tar.lz fernflower-ccd7b93497e2b82fc20b07208b2beb9753afe1a2.tar.xz fernflower-ccd7b93497e2b82fc20b07208b2beb9753afe1a2.zip |
Cleanup (test)
Diffstat (limited to 'test/org')
-rw-r--r-- | test/org/jetbrains/java/decompiler/SingleClassesTest.java | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/test/org/jetbrains/java/decompiler/SingleClassesTest.java index 9868011..cdd707f 100644 --- a/test/org/jetbrains/java/decompiler/SingleClassesTest.java +++ b/test/org/jetbrains/java/decompiler/SingleClassesTest.java @@ -21,6 +21,9 @@ import org.junit.Before; import org.junit.Test; import java.io.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -60,14 +63,7 @@ public class SingleClassesTest { assertTrue(classFile.isFile()); ConsoleDecompiler decompiler = fixture.getDecompiler(); - decompiler.addSpace(classFile, true); - File[] innerClasses = classFile.getParentFile().listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.matches(testName + "\\$.+\\.class"); - } - }); - for (File inner : innerClasses) { + for (File inner : collectClasses(classFile)) { decompiler.addSpace(inner, true); } @@ -88,6 +84,25 @@ public class SingleClassesTest { } } + private static List<File> collectClasses(File classFile) { + List<File> files = new ArrayList<File>(); + files.add(classFile); + + File parent = classFile.getParentFile(); + if (parent != null) { + final String pattern = classFile.getName().replace(".class", "") + "\\$.+\\.class"; + File[] inner = parent.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.matches(pattern); + } + }); + if (inner != null) Collections.addAll(files, inner); + } + + return files; + } + private static String getContent(File file) throws IOException { Reader reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); try { |