Skip to content

Commit

Permalink
add debug test
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzun66 committed Dec 20, 2024
1 parent 77a7107 commit 1a33bc3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions shared-test-resources/bugfixes/TrapSSA.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import java.io.*;
class TrapSSA {
public static void main(String[] args) throws IOException {
byte[] data;
try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
output.write(args[0].getBytes("UTF-8"));
data = output.toByteArray();
}
System.out.println(new String(data, "UTF-8"));
}
}
17 changes: 17 additions & 0 deletions sootup.tests/src/test/java/sootup/tests/InsertBeforeAfterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import sootup.core.model.SourceType;
import sootup.core.signatures.MethodSignature;
import sootup.core.types.ClassType;
import sootup.core.util.DotExporter;
import sootup.java.bytecode.frontend.inputlocation.PathBasedAnalysisInputLocation;
import sootup.java.core.JavaIdentifierFactory;
import sootup.java.core.language.JavaJimple;
Expand Down Expand Up @@ -667,4 +668,20 @@ public void testInsertAfterBlockMiddle2() {
+ "}\n";
Assertions.assertEquals(exceptedBody, builder.build().toString());
}

@Test
public void testErrors() {
ClassType clazzType = factory.getClassType("TrapSSA");
MethodSignature methodSignature =
factory.getMethodSignature(
clazzType, "main", "void", Collections.singletonList("java.lang.String[]"));
final Path path = Paths.get(location + "TrapSSA.class");
PathBasedAnalysisInputLocation inputLocation =
new PathBasedAnalysisInputLocation.ClassFileBasedAnalysisInputLocation(
path, "", SourceType.Application);
JavaView view = new JavaView(inputLocation);
Body body = view.getMethod(methodSignature).get().getBody();
System.out.println(DotExporter.createUrlToWebeditor(body.getStmtGraph()));
System.out.println(body);
}
}

0 comments on commit 1a33bc3

Please sign in to comment.