use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestTryCatchFinally method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("exc(obj);"));
assertThat(code, containsOne("} catch (Exception e) {"));
assertThat(code, containsOne("e.getMessage();"));
assertThat(code, containsOne("} finally {"));
assertThat(code, containsOne("f = true;"));
assertThat(code, containsOne("return this.f;"));
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestTryCatchFinally2 method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("} finally {"));
assertThat(code, containsOne("out.close();"));
assertThat(code, containsOne("for (NClass parent : parents) {"));
// TODO
// assertThat(code, countString(2, "for (NClass cls : classes) {"));
assertThat(code, containsOne("for (NClass cls : this.classes) {"));
assertThat(code, containsOne("for (NClass cls2 : this.classes) {"));
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestTryCatchFinally4 method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("File file = File.createTempFile(\"test\", \"txt\");"));
assertThat(code, containsOne("OutputStream outputStream = new FileOutputStream(file);"));
assertThat(code, containsOne("outputStream.write(1);"));
assertThat(code, containsOne("} finally {"));
assertThat(code, containsOne("outputStream.close();"));
assertThat(code, containsOne("} catch (IOException e) {"));
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestTryCatchFinally6 method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsLines(2, "InputStream is = null;", "try {", indent(1) + "is = new FileInputStream(\"1.txt\");", "} finally {", indent(1) + "if (is != null) {", indent(2) + "is.close();", indent(1) + "}", "}"));
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestTryCatchInIf method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("try {"));
assertThat(code, containsOne("} catch (NumberFormatException e) {"));
}
Aggregations