From 1bb90233b922e637d7ee52255085c525e72e971e Mon Sep 17 00:00:00 2001 From: Skylot Date: Mon, 27 Jan 2020 19:23:35 +0000 Subject: [PATCH] test: NYI tests for #836 and #837 --- .../integration/types/TestTypeResolver11.java | 38 ++++++++++++++++ .../integration/types/TestTypeResolver12.java | 43 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver11.java create mode 100644 jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver12.java diff --git a/jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver11.java b/jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver11.java new file mode 100644 index 00000000..584dd312 --- /dev/null +++ b/jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver11.java @@ -0,0 +1,38 @@ +package jadx.tests.integration.types; + +import org.junit.jupiter.api.Test; + +import jadx.NotYetImplemented; +import jadx.tests.api.IntegrationTest; + +public class TestTypeResolver11 extends IntegrationTest { + + public static class TestCls { + public Void test(Object... objArr) { + int val = (Integer) objArr[0]; + String str = (String) objArr[1]; + call(str, str, val, val); + return null; + } + + private void call(String a, String b, int... val) { + } + + public void check() { + test(1, "str"); + } + } + + @NotYetImplemented("Missing cast") + @Test + public void test() { + getClassNode(TestCls.class); + } + + @NotYetImplemented("Missing cast") + @Test + public void testNoDebug() { + noDebugInfo(); + getClassNode(TestCls.class); + } +} diff --git a/jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver12.java b/jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver12.java new file mode 100644 index 00000000..8b0c63db --- /dev/null +++ b/jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver12.java @@ -0,0 +1,43 @@ +package jadx.tests.integration.types; + +import java.lang.ref.WeakReference; + +import org.junit.jupiter.api.Test; + +import jadx.NotYetImplemented; +import jadx.tests.api.IntegrationTest; + +import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; + +public class TestTypeResolver12 extends IntegrationTest { + + public abstract static class TestCls { + private WeakReference ref; + + public void test(String str) { + T obj = this.ref.get(); + if (obj != null) { + call(obj, str); + } + } + + public abstract void call(T t, String str); + } + + @Test + public void test() { + assertThat(getClassNode(TestCls.class)) + .code() + .containsOne("T obj = this.ref.get();"); + } + + @NotYetImplemented("Generic type inference") + @Test + public void testNoDebug() { + noDebugInfo(); + assertThat(getClassNode(TestCls.class)) + .code() + .doesNotContain("Object obj") + .containsOne("T obj = this.ref.get();"); + } +} -- GitLab