提交 d3dbdb24 编写于 作者: A Ahmed Ashour 提交者: skylot

test: use @NYI instead of commented TODO (PR #499)

上级 e585c4ec
...@@ -34,7 +34,6 @@ public class TestStaticFieldsInit extends IntegrationTest { ...@@ -34,7 +34,6 @@ public class TestStaticFieldsInit extends IntegrationTest {
String code = cls.getCode().toString(); String code = cls.getCode().toString();
assertThat(code, not(containsString("public static final String s2 = null;"))); assertThat(code, not(containsString("public static final String s2 = null;")));
// TODO: assertThat(code, containsString("public static final String s3 = null;"));
// assertThat(code, containsString("public static final String s3 = null;"));
} }
} }
package jadx.tests.integration.arith; package jadx.tests.integration.arith;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
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;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
public class TestFieldIncrement2 extends IntegrationTest { public class TestFieldIncrement2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
...@@ -33,7 +34,14 @@ public class TestFieldIncrement2 extends IntegrationTest { ...@@ -33,7 +34,14 @@ public class TestFieldIncrement2 extends IntegrationTest {
assertThat(code, containsString("this.a.f += n;")); assertThat(code, containsString("this.a.f += n;"));
assertThat(code, containsString("a.f *= n;")); assertThat(code, containsString("a.f *= n;"));
// TODO }
// assertThat(code, containsString("this.a.f *= n;"));
@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("this.a.f *= n;"));
} }
} }
package jadx.tests.integration.arrays; package jadx.tests.integration.arrays;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
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;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
public class TestArrayFill2 extends IntegrationTest { public class TestArrayFill2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
...@@ -15,11 +16,6 @@ public class TestArrayFill2 extends IntegrationTest { ...@@ -15,11 +16,6 @@ public class TestArrayFill2 extends IntegrationTest {
public int[] test(int a) { public int[] test(int a) {
return new int[]{1, a + 1, 2}; return new int[]{1, a + 1, 2};
} }
// TODO
// public int[] test2(int a) {
// return new int[]{1, a++, a * 2};
// }
} }
@Test @Test
...@@ -28,8 +24,22 @@ public class TestArrayFill2 extends IntegrationTest { ...@@ -28,8 +24,22 @@ public class TestArrayFill2 extends IntegrationTest {
String code = cls.getCode().toString(); String code = cls.getCode().toString();
assertThat(code, containsString("return new int[]{1, a + 1, 2};")); assertThat(code, containsString("return new int[]{1, a + 1, 2};"));
}
// TODO public static class TestCls2 {
// assertThat(code, containsString("return new int[]{1, a++, a * 2};"));
public int[] test2(int a) {
return new int[]{1, a++, a * 2};
}
}
@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls2.class);
String code = cls.getCode().toString();
assertThat(code, containsString("return new int[]{1, a++, a * 2};"));
} }
} }
...@@ -65,7 +65,6 @@ public class TestConditions3 extends IntegrationTest { ...@@ -65,7 +65,6 @@ public class TestConditions3 extends IntegrationTest {
assertThat(code, containsString("return null;")); assertThat(code, containsString("return null;"));
assertThat(code, not(containsString("else"))); assertThat(code, not(containsString("else")));
// TODO: fix constant inline assertThat(code, not(containsString("AnonymousClass_1")));
// assertThat(code, not(containsString("AnonymousClass_1")));
} }
} }
...@@ -52,6 +52,5 @@ public class TestNestedIf2 extends IntegrationTest { ...@@ -52,6 +52,5 @@ public class TestNestedIf2 extends IntegrationTest {
assertThat(code, containsOne("if (executedCount != repeatCount && isRun(delta, object)) {")); assertThat(code, containsOne("if (executedCount != repeatCount && isRun(delta, object)) {"));
assertThat(code, containsOne("if (finished) {")); assertThat(code, containsOne("if (finished) {"));
assertThat(code, not(containsString("else"))); assertThat(code, not(containsString("else")));
} }
} }
package jadx.tests.integration.conditions; package jadx.tests.integration.conditions;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
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;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestTernary2 extends IntegrationTest { public class TestTernary2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
...@@ -28,7 +31,14 @@ public class TestTernary2 extends IntegrationTest { ...@@ -28,7 +31,14 @@ public class TestTernary2 extends IntegrationTest {
assertEquals(1, count(code, "assertTrue")); assertEquals(1, count(code, "assertTrue"));
assertEquals(1, count(code, "f(1, 0)")); assertEquals(1, count(code, "f(1, 0)"));
// TODO: }
// assertThat(code, containsString("assertTrue(f(1, 0) == 0);"));
@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("assertTrue(f(1, 0) == 0);"));
} }
} }
package jadx.tests.integration.debuginfo; package jadx.tests.integration.debuginfo;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jadx.NotYetImplemented;
import jadx.core.codegen.CodeWriter; import jadx.core.codegen.CodeWriter;
import jadx.core.dex.attributes.nodes.LineAttrNode; import jadx.core.dex.attributes.nodes.LineAttrNode;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.MethodNode;
import jadx.tests.api.IntegrationTest; import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.hamcrest.MatcherAssert.assertThat;
public class TestReturnSourceLine extends IntegrationTest { public class TestReturnSourceLine extends IntegrationTest {
public static class TestCls { public static class TestCls {
...@@ -59,10 +60,18 @@ public class TestReturnSourceLine extends IntegrationTest { ...@@ -59,10 +60,18 @@ public class TestReturnSourceLine extends IntegrationTest {
MethodNode test2 = cls.searchMethodByName("test2(I)I"); MethodNode test2 = cls.searchMethodByName("test2(I)I");
checkLine(lines, codeWriter, test2, 3, "return v - 1;"); checkLine(lines, codeWriter, test2, 3, "return v - 1;");
}
@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
CodeWriter codeWriter = cls.getCode();
String code = codeWriter.toString();
String[] lines = code.split(CodeWriter.NL);
// TODO: MethodNode test3 = cls.searchMethodByName("test3(I)I");
// MethodNode test3 = cls.searchMethodByName("test3(I)I"); checkLine(lines, codeWriter, test3, 3, "return v;");
// checkLine(lines, codeWriter, test3, 3, "return v;");
} }
private static void checkLine(String[] lines, CodeWriter cw, LineAttrNode node, int offset, String str) { private static void checkLine(String[] lines, CodeWriter cw, LineAttrNode node, int offset, String str) {
......
...@@ -79,7 +79,6 @@ public class TestAnonymousClass5 extends IntegrationTest { ...@@ -79,7 +79,6 @@ public class TestAnonymousClass5 extends IntegrationTest {
assertThat(code, containsOne("map.get(name);")); assertThat(code, containsOne("map.get(name);"));
assertThat(code, not(containsString("access$008"))); assertThat(code, not(containsString("access$008")));
// TODO assertThat(code, not(containsString("synthetic")));
// assertThat(code, not(containsString("synthetic")));
} }
} }
package jadx.tests.integration.invoke; package jadx.tests.integration.invoke;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import jadx.NotYetImplemented; import jadx.NotYetImplemented;
import jadx.NotYetImplementedExtension;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest; import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@ExtendWith(NotYetImplementedExtension.class)
public class TestCastInOverloadedInvoke extends IntegrationTest { public class TestCastInOverloadedInvoke extends IntegrationTest {
public static class TestCls { public static class TestCls {
......
package jadx.tests.integration.loops; package jadx.tests.integration.loops;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import jadx.NotYetImplemented;
import jadx.NotYetImplementedExtension;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest; import jadx.tests.api.IntegrationTest;
...@@ -37,7 +40,14 @@ public class TestLoopDetection3 extends IntegrationTest { ...@@ -37,7 +40,14 @@ public class TestLoopDetection3 extends IntegrationTest {
String code = cls.getCode().toString(); String code = cls.getCode().toString();
assertThat(code, containsString("while")); assertThat(code, containsString("while"));
// TODO }
// assertThat(code, containsString("while (--pos >= 0) {"));
@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("while (--pos >= 0) {"));
} }
} }
package jadx.tests.integration.loops; package jadx.tests.integration.loops;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import jadx.NotYetImplemented; import jadx.NotYetImplemented;
import jadx.NotYetImplementedExtension;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest; import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat;
@ExtendWith(NotYetImplementedExtension.class)
public class TestSynchronizedInEndlessLoop extends IntegrationTest { public class TestSynchronizedInEndlessLoop extends IntegrationTest {
public static class TestCls { public static class TestCls {
......
package jadx.tests.integration.others; package jadx.tests.integration.others;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashMap; import java.util.HashMap;
...@@ -8,9 +13,6 @@ import org.junit.jupiter.api.Test; ...@@ -8,9 +13,6 @@ import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest; import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat;
public class TestIssue13a extends IntegrationTest { public class TestIssue13a extends IntegrationTest {
public static class TestCls { public static class TestCls {
...@@ -97,6 +99,6 @@ public class TestIssue13a extends IntegrationTest { ...@@ -97,6 +99,6 @@ public class TestIssue13a extends IntegrationTest {
} }
// TODO: add additional checks // TODO: add additional checks
// assertThat(code, not(containsString("Throwable"))); assertThat(code, not(containsString("Throwable")));
} }
} }
...@@ -2,10 +2,12 @@ package jadx.tests.integration.synchronize; ...@@ -2,10 +2,12 @@ package jadx.tests.integration.synchronize;
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;
import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
public class TestSynchronized2 extends IntegrationTest { public class TestSynchronized2 extends IntegrationTest {
...@@ -23,8 +25,15 @@ public class TestSynchronized2 extends IntegrationTest { ...@@ -23,8 +25,15 @@ public class TestSynchronized2 extends IntegrationTest {
assertThat(code, containsString("private static synchronized boolean test(Object obj) {")); assertThat(code, containsString("private static synchronized boolean test(Object obj) {"));
assertThat(code, containsString("obj.toString() != null;")); assertThat(code, containsString("obj.toString() != null;"));
// TODO }
// assertThat(code, containsString("return obj.toString() != null;"));
// assertThat(code, not(containsString("synchronized ("))); @Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("return obj.toString() != null;"));
assertThat(code, not(containsString("synchronized (")));
} }
} }
...@@ -6,10 +6,12 @@ import java.io.InputStream; ...@@ -6,10 +6,12 @@ import java.io.InputStream;
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;
import static jadx.tests.api.utils.JadxMatchers.containsOne; import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
public class TestFinally2 extends IntegrationTest { public class TestFinally2 extends IntegrationTest {
...@@ -57,7 +59,14 @@ public class TestFinally2 extends IntegrationTest { ...@@ -57,7 +59,14 @@ public class TestFinally2 extends IntegrationTest {
String code = cls.getCode().toString(); String code = cls.getCode().toString();
assertThat(code, containsOne("decode(inputStream);")); assertThat(code, containsOne("decode(inputStream);"));
// TODO }
// assertThat(code, not(containsOne("result =")));
@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, not(containsOne("result =")));
} }
} }
...@@ -6,6 +6,7 @@ import java.io.IOException; ...@@ -6,6 +6,7 @@ import java.io.IOException;
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;
...@@ -48,9 +49,17 @@ public class TestTryCatch5 extends IntegrationTest { ...@@ -48,9 +49,17 @@ public class TestTryCatch5 extends IntegrationTest {
String code = cls.getCode().toString(); String code = cls.getCode().toString();
assertThat(code, containsString("try {")); assertThat(code, containsString("try {"));
// TODO:
// assertThat(code, containsString("output = new FileOutputStream(file);"));
// assertThat(code, containsString("} catch (IOException e) {"));
assertThat(code, containsString("file.delete();")); assertThat(code, containsString("file.delete();"));
} }
@Test
@NotYetImplemented
public void test2() {
disableCompilation();
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("output = new FileOutputStream(file);"));
assertThat(code, containsString("} catch (IOException e) {"));
}
} }
package jadx.tests.integration.trycatch; package jadx.tests.integration.trycatch;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static jadx.tests.api.utils.JadxMatchers.countString;
import static org.hamcrest.MatcherAssert.assertThat;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jadx.NotYetImplemented;
import jadx.core.clsp.NClass; import jadx.core.clsp.NClass;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest; import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat;
public class TestTryCatchFinally2 extends IntegrationTest { public class TestTryCatchFinally2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
...@@ -52,9 +54,16 @@ public class TestTryCatchFinally2 extends IntegrationTest { ...@@ -52,9 +54,16 @@ public class TestTryCatchFinally2 extends IntegrationTest {
assertThat(code, containsOne("for (NClass parent : parents) {")); assertThat(code, containsOne("for (NClass parent : parents) {"));
// TODO
// assertThat(code, countString(2, "for (NClass cls : classes) {"));
assertThat(code, containsOne("for (NClass cls : this.classes) {")); assertThat(code, containsOne("for (NClass cls : this.classes) {"));
assertThat(code, containsOne("for (NClass cls2 : this.classes) {")); assertThat(code, containsOne("for (NClass cls2 : this.classes) {"));
} }
@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, countString(2, "for (NClass cls : classes) {"));
}
} }
...@@ -5,6 +5,7 @@ import java.util.List; ...@@ -5,6 +5,7 @@ import java.util.List;
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;
...@@ -65,7 +66,14 @@ public class TestTryCatchFinally5 extends IntegrationTest { ...@@ -65,7 +66,14 @@ public class TestTryCatchFinally5 extends IntegrationTest {
String code = cls.getCode().toString(); String code = cls.getCode().toString();
assertThat(code, containsOne("} finally {")); assertThat(code, containsOne("} finally {"));
// TODO: remove duplicates on multiple paths }
// assertThat(code, containsOne("d.close();"));
@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("d.close();"));
} }
} }
...@@ -8,14 +8,11 @@ import java.io.IOException; ...@@ -8,14 +8,11 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import jadx.NotYetImplemented; import jadx.NotYetImplemented;
import jadx.NotYetImplementedExtension;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest; import jadx.tests.api.IntegrationTest;
@ExtendWith(NotYetImplementedExtension.class)
public class TryAfterDeclaration extends IntegrationTest { public class TryAfterDeclaration extends IntegrationTest {
/** /**
......
...@@ -2,6 +2,7 @@ package jadx.tests.integration.types; ...@@ -2,6 +2,7 @@ package jadx.tests.integration.types;
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,10 +27,18 @@ public class TestTypeResolver3 extends IntegrationTest { ...@@ -26,10 +27,18 @@ public class TestTypeResolver3 extends IntegrationTest {
ClassNode cls = getClassNode(TestCls.class); ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString(); String code = cls.getCode().toString();
// TODO inline into return
assertThat(code, containsOne("s1.length() == s2.length() ? 0 : s1.length() < s2.length() ? -1 : 1;")); assertThat(code, containsOne("s1.length() == s2.length() ? 0 : s1.length() < s2.length() ? -1 : 1;"));
} }
@Test
@NotYetImplemented
public void test3() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("return s1.length() == s2.length() ? 0 : s1.length() < s2.length() ? -1 : 1;"));
}
@Test @Test
public void test2() { public void test2() {
noDebugInfo(); noDebugInfo();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册