From 035506496e7dc31db93f975d106b529676dbeb6a Mon Sep 17 00:00:00 2001 From: Skylot Date: Sun, 4 Feb 2018 17:08:22 +0300 Subject: [PATCH] core: add endless loop test --- .../integration/loops/TestEndlessLoop.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 jadx-core/src/test/java/jadx/tests/integration/loops/TestEndlessLoop.java diff --git a/jadx-core/src/test/java/jadx/tests/integration/loops/TestEndlessLoop.java b/jadx-core/src/test/java/jadx/tests/integration/loops/TestEndlessLoop.java new file mode 100644 index 000000000..28dedc5e6 --- /dev/null +++ b/jadx-core/src/test/java/jadx/tests/integration/loops/TestEndlessLoop.java @@ -0,0 +1,42 @@ +package jadx.tests.integration.loops; + +import org.junit.Test; + +import jadx.core.dex.nodes.ClassNode; +import jadx.tests.api.IntegrationTest; + +import static jadx.tests.api.utils.JadxMatchers.containsOne; +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.assertThat; + +public class TestEndlessLoop extends IntegrationTest { + + public static class TestCls { + + void test1() { + while (this == this) { + } + } + + void test2() { + do { + } while (this == this); + } + + void test3() { + while (true) { + if (this != this) { + return; + } + } + } + } + + @Test + public void test() { + ClassNode cls = getClassNode(TestCls.class); + String code = cls.getCode().toString(); + + assertThat(code, containsString("while (this == this)")); + } +}