core: fix processing 'if' at loop end

This commit is contained in:
Skylot
2014-10-24 23:11:29 +04:00
parent 7699cfac02
commit f31c2dcd21
6 changed files with 116 additions and 10 deletions
@@ -0,0 +1,42 @@
package jadx.tests.integration.loops;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
public class TestIfInLoop2 extends IntegrationTest {
public static class TestCls {
public static void test(String str) {
int len = str.length();
int at = 0;
while (at < len) {
char c = str.charAt(at);
int endAt = at + 1;
if (c == 'A') {
while (endAt < len) {
c = str.charAt(endAt);
if (c == 'B') {
break;
}
endAt++;
}
}
at = endAt;
}
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, not(containsString("for (int at = 0; at < len; at = endAt) {")));
}
}