From 7545625af4254bf745e89c107fa69e45b255392e Mon Sep 17 00:00:00 2001 From: Skylot Date: Tue, 10 Dec 2019 19:10:00 +0000 Subject: [PATCH] test: add NYI test for empty finally block (#789) --- .../trycatch/TestEmptyFinally.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 jadx-core/src/test/java/jadx/tests/integration/trycatch/TestEmptyFinally.java diff --git a/jadx-core/src/test/java/jadx/tests/integration/trycatch/TestEmptyFinally.java b/jadx-core/src/test/java/jadx/tests/integration/trycatch/TestEmptyFinally.java new file mode 100644 index 000000000..972891de1 --- /dev/null +++ b/jadx-core/src/test/java/jadx/tests/integration/trycatch/TestEmptyFinally.java @@ -0,0 +1,39 @@ +package jadx.tests.integration.trycatch; + +import java.io.FileInputStream; +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import jadx.NotYetImplemented; +import jadx.core.dex.nodes.ClassNode; +import jadx.tests.api.IntegrationTest; + +import static jadx.tests.api.utils.JadxMatchers.containsOne; +import static org.hamcrest.MatcherAssert.assertThat; + +public class TestEmptyFinally extends IntegrationTest { + + public static class TestCls { + @SuppressWarnings("EmptyFinallyBlock") + public void test(FileInputStream f1) { + try { + f1.close(); + } catch (IOException e) { + // do nothing + } finally { + // ignore + } + } + } + + @NotYetImplemented + @Test + public void test() { + ClassNode cls = getClassNode(TestCls.class); + String code = cls.getCode().toString(); + + assertThat(code, containsOne("} catch (IOException e) {")); + assertThat(code, containsOne("} finally {")); // ??? + } +}