Commit 3970fce5 authored by Ahmed Ashour's avatar Ahmed Ashour Committed by skylot

test: use NYI instead of comment (PR #551)

parent eda22724
package jadx.tests.integration.arith; package jadx.tests.integration.arith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jadx.NotYetImplemented;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest; import jadx.tests.api.IntegrationTest;
...@@ -28,10 +32,16 @@ public class TestArith extends IntegrationTest { ...@@ -28,10 +32,16 @@ public class TestArith extends IntegrationTest {
public void test() { public void test() {
ClassNode cls = getClassNode(TestCls.class); ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString(); String code = cls.getCode().toString();
}
@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
// TODO: reduce code vars by name assertThat(code, containsString("a += 2;"));
// assertThat(code, containsString("a += 2;")); assertThat(code, containsString("a++;"));
// assertThat(code, containsString("a++;"));
} }
@Test @Test
...@@ -39,9 +49,16 @@ public class TestArith extends IntegrationTest { ...@@ -39,9 +49,16 @@ public class TestArith extends IntegrationTest {
noDebugInfo(); noDebugInfo();
ClassNode cls = getClassNode(TestCls.class); ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString(); String code = cls.getCode().toString();
}
@Test
@NotYetImplemented
public void testNoDebug2() {
noDebugInfo();
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
// TODO: simplify for variables without debug names assertThat(code, containsString("i += 2;"));
// assertThat(code, containsString("i += 2;")); assertThat(code, containsString("i++;"));
// assertThat(code, containsString("i++;"));
} }
} }
package jadx.tests.integration.arith; package jadx.tests.integration.arith;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.Test;
import jadx.NotYetImplemented;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
public class TestArith2 extends IntegrationTest { public class TestArith2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
...@@ -20,13 +23,20 @@ public class TestArith2 extends IntegrationTest { ...@@ -20,13 +23,20 @@ public class TestArith2 extends IntegrationTest {
} }
} }
// @Test @Test
public void test() { public void test() {
ClassNode cls = getClassNode(TestCls.class); ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString(); String code = cls.getCode().toString();
assertThat(code, containsString("return (a + 2) * 3;")); assertThat(code, containsString("return (a + 2) * 3;"));
assertThat(code, not(containsString("a + 2 * 3"))); assertThat(code, not(containsString("a + 2 * 3")));
}
@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("return a + b + c;")); assertThat(code, containsString("return a + b + c;"));
assertThat(code, not(containsString("return (a + b) + c;"))); assertThat(code, not(containsString("return (a + b) + c;")));
......
...@@ -19,25 +19,25 @@ public class TestFieldIncrement3 extends IntegrationTest { ...@@ -19,25 +19,25 @@ public class TestFieldIncrement3 extends IntegrationTest {
static Vector2 directVect = new Vector2(); static Vector2 directVect = new Vector2();
static Vector2 newPos = new Vector2(); static Vector2 newPos = new Vector2();
private static void test() { public static void test() {
Random rd = new Random(); Random rd = new Random();
int direction = rd.nextInt(7); int direction = rd.nextInt(7);
switch (direction) { switch (direction) {
case 0: case 0:
targetPos.x = (float) (((tileX + 1) * 55) + 55); targetPos.x = ((tileX + 1) * 55) + 55;
targetPos.y = (float) (((tileY + 1) * 35) + 35); targetPos.y = ((tileY + 1) * 35) + 35;
break; break;
case 2: case 2:
targetPos.x = (float) (((tileX + 1) * 55) + 55); targetPos.x = ((tileX + 1) * 55) + 55;
targetPos.y = (float) (((tileY - 1) * 35) + 35); targetPos.y = ((tileY - 1) * 35) + 35;
break; break;
case 4: case 4:
targetPos.x = (float) (((tileX - 1) * 55) + 55); targetPos.x = ((tileX - 1) * 55) + 55;
targetPos.y = (float) (((tileY - 1) * 35) + 35); targetPos.y = ((tileY - 1) * 35) + 35;
break; break;
case 6: case 6:
targetPos.x = (float) (((tileX - 1) * 55) + 55); targetPos.x = ((tileX - 1) * 55) + 55;
targetPos.y = (float) (((tileY + 1) * 35) + 35); targetPos.y = ((tileY + 1) * 35) + 35;
break; break;
default: default:
break; break;
...@@ -45,7 +45,7 @@ public class TestFieldIncrement3 extends IntegrationTest { ...@@ -45,7 +45,7 @@ public class TestFieldIncrement3 extends IntegrationTest {
directVect.x = targetPos.x - newPos.x; directVect.x = targetPos.x - newPos.x;
directVect.y = targetPos.y - newPos.y; directVect.y = targetPos.y - newPos.y;
float hPos = (float) Math.sqrt((double) ((directVect.x * directVect.x) + (directVect.y * directVect.y))); float hPos = (float) Math.sqrt((directVect.x * directVect.x) + (directVect.y * directVect.y));
directVect.x /= hPos; directVect.x /= hPos;
directVect.y /= hPos; directVect.y /= hPos;
} }
......
...@@ -2,6 +2,7 @@ package jadx.tests.integration.conditions; ...@@ -2,6 +2,7 @@ package jadx.tests.integration.conditions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jadx.NotYetImplemented;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest; import jadx.tests.api.IntegrationTest;
...@@ -26,11 +27,19 @@ public class TestConditions16 extends IntegrationTest { ...@@ -26,11 +27,19 @@ public class TestConditions16 extends IntegrationTest {
} }
@Test @Test
@NotYetImplemented
public void test() { public void test() {
ClassNode cls = getClassNode(TestCls.class); ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString(); String code = cls.getCode().toString();
// assertThat(code, containsOne("return a < 0 || (b % 2 != 0 && a > 28) || b < 0;")); assertThat(code, containsOne("return a < 0 || (b % 2 != 0 && a > 28) || b < 0;"));
}
@Test
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("return a < 0 || ((b % 2 != 0 && a > 28) || b < 0);")); assertThat(code, containsOne("return a < 0 || ((b % 2 != 0 && a > 28) || b < 0);"));
} }
} }
...@@ -31,7 +31,6 @@ public class TestConditions8 extends IntegrationTest { ...@@ -31,7 +31,6 @@ public class TestConditions8 extends IntegrationTest {
} }
private void showMore() { private void showMore() {
} }
private int size() { private int size() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment