Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added tests with novars for jdk 1.2 and1.3 #42

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions src/test/java/jd/core/test/TryCatchFinallyBRTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,43 @@ public class TryCatchFinallyBRTest extends AbstractTestCase {

@Test
public void testJikes() throws Exception {
test("jikes-1.22");
test("jikes-1.22", false);
}
@Test
public void testJavac_1_2_2_novar() throws Exception {
test("javac-1.2.2", true);
}

@Test
public void testJavac_1_3_1_28() throws Exception {
test("javac-1.3.1_28", true);
}

@Test
public void testJavac_1_4_2_19() throws Exception {
test("javac-1.4.2_19");
test("javac-1.4.2_19", false);
}

@Test
public void testJavac_17_0_4() throws Exception {
test("javac-17.0.4");
test("javac-17.0.4", false);
}

private void test(String compiler) throws IOException {
try (InputStream in = getClass().getResourceAsStream("/try-catch-finally-" + compiler + ".jar")) {
private void test(String compiler, boolean noVar) throws IOException {
StringBuilder expectedFileName = new StringBuilder("TryCatchFinallyBR");
StringBuilder jarPath = new StringBuilder("/try-catch-finally-");
jarPath.append(compiler);
if (noVar) {
expectedFileName.append("-novar");
jarPath.append("-novar");
}
expectedFileName.append(".txt");
jarPath.append(".jar");
try (InputStream in = getClass().getResourceAsStream(jarPath.toString())) {
ZipLoader loader = new ZipLoader(in);
String internalClassName = "jd/core/test/TryCatchFinallyBR";
String output = decompile(internalClassName, loader);
assertEquals(IOUtils.toString(getClass().getResource("TryCatchFinallyBR.txt"), StandardCharsets.UTF_8), output);
assertEquals(IOUtils.toString(getClass().getResource(expectedFileName.toString()), StandardCharsets.UTF_8), output);
}
}

}
30 changes: 30 additions & 0 deletions src/test/resources/jd/core/test/TryCatchFinallyBR-novar.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* */ package jd.core.test;
/* */
/* */ import java.io.BufferedReader;
/* */ import java.io.File;
/* */ import java.io.IOException;
/* */
/* */ public class TryCatchFinallyBR
/* */ {
/* */ void tryCatchFinally(File paramFile)
/* */ {
/* 11 */ BufferedReader localBufferedReader = null;
/* */ try {
/* 13 */ localBufferedReader = new BufferedReader(new java.io.FileReader(paramFile));
/* */ String str;
/* 15 */ while ((str = localBufferedReader.readLine()) != null) {
/* 16 */ System.out.println(str);
/* */ }
/* */ } catch (Exception localException) {
/* 19 */ localException.printStackTrace();
/* */ } finally {
/* 21 */ if (localBufferedReader != null) {
/* */ try {
/* 23 */ localBufferedReader.close();
/* */ } catch (IOException localIOException) {
/* 25 */ localIOException.printStackTrace();
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
Binary file not shown.
Binary file not shown.