summaryrefslogtreecommitdiff
path: root/test/463-checker-boolean-simplifier/src/Main.java
diff options
context:
space:
mode:
author Igor Murashkin <iam@google.com> 2017-06-23 13:58:58 -0700
committer Igor Murashkin <iam@google.com> 2017-06-26 14:07:24 +0000
commitbd44132f680430d44790015b42edffc05797e19c (patch)
tree0663bda2c6e5d06f588e0949b1117bb53d9c39f7 /test/463-checker-boolean-simplifier/src/Main.java
parent3b9aee84472d9b45fef8654de875463c14c5fbcf (diff)
test: Fix 4 checker tests to pass with javac/dx
Acts as a partial revert of commit f02c3cf66c2c24533f6da43970e7b766b2ca9938. Revert only the failing javac/dx checker tests. Update files to match new checker syntax (e.g. constant_folding_after_inling -> constant_folding$after_inlining). Add build scripts to force these tests to use javac/dx even if the platform build was using jack. Fixes following tests: * 442-checker-constant-folding * 450-checker-types * 463-checker-boolean-simplifier * 537-checker-inline-and-unverified Bug: 62950048 Bug: 36902714 Change-Id: I89dc039e3746b4b9f7d3eced43d1e0113662e812
Diffstat (limited to 'test/463-checker-boolean-simplifier/src/Main.java')
-rw-r--r--test/463-checker-boolean-simplifier/src/Main.java64
1 files changed, 50 insertions, 14 deletions
diff --git a/test/463-checker-boolean-simplifier/src/Main.java b/test/463-checker-boolean-simplifier/src/Main.java
index 9368488056..d1d02cdfee 100644
--- a/test/463-checker-boolean-simplifier/src/Main.java
+++ b/test/463-checker-boolean-simplifier/src/Main.java
@@ -32,14 +32,42 @@ public class Main {
}
}
- // Invoke a method written in smali that implements the boolean ! operator. This method
- // uses the if/else pattern generated by dx (while Jack generates a different pattern).
- // Since this method is in a smali-generated class, we invoke it through reflection.
- public static boolean SmaliBooleanNot(boolean x) throws Exception {
- Class<?> c = Class.forName("BooleanNotSmali");
- java.lang.reflect.Method method = c.getMethod("BooleanNot", boolean.class);
- Object retValue = method.invoke(null, new Object[] { Boolean.valueOf(x) });
- return ((Boolean) retValue).booleanValue();
+ /*
+ * Elementary test negating a boolean. Verifies that blocks are merged and
+ * empty branches removed.
+ */
+
+ /// CHECK-START: boolean Main.BooleanNot(boolean) select_generator (before)
+ /// CHECK-DAG: <<Param:z\d+>> ParameterValue
+ /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
+ /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
+ /// CHECK-DAG: If [<<Param>>]
+ /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Const1>>,<<Const0>>]
+ /// CHECK-DAG: Return [<<Phi>>]
+
+ /// CHECK-START: boolean Main.BooleanNot(boolean) select_generator (before)
+ /// CHECK: Goto
+ /// CHECK: Goto
+ /// CHECK: Goto
+ /// CHECK-NOT: Goto
+
+ /// CHECK-START: boolean Main.BooleanNot(boolean) select_generator (after)
+ /// CHECK-DAG: <<Param:z\d+>> ParameterValue
+ /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
+ /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
+ /// CHECK-DAG: <<NotParam:i\d+>> Select [<<Const1>>,<<Const0>>,<<Param>>]
+ /// CHECK-DAG: Return [<<NotParam>>]
+
+ /// CHECK-START: boolean Main.BooleanNot(boolean) select_generator (after)
+ /// CHECK-NOT: If
+ /// CHECK-NOT: Phi
+
+ /// CHECK-START: boolean Main.BooleanNot(boolean) select_generator (after)
+ /// CHECK: Goto
+ /// CHECK-NOT: Goto
+
+ public static boolean BooleanNot(boolean x) {
+ return !x;
}
/*
@@ -157,7 +185,11 @@ public class Main {
/// CHECK-NOT: BooleanNot
public static int NegatedCondition(boolean x) {
- return (x != false) ? 42 : 43;
+ if (x != false) {
+ return 42;
+ } else {
+ return 43;
+ }
}
/// CHECK-START: int Main.SimpleTrueBlock(boolean, int) select_generator (after)
@@ -221,7 +253,13 @@ public class Main {
/// CHECK-DAG: Return [<<Select123>>]
public static int ThreeBlocks(boolean x, boolean y) {
- return x ? 1 : (y ? 2 : 3);
+ if (x) {
+ return 1;
+ } else if (y) {
+ return 2;
+ } else {
+ return 3;
+ }
}
/// CHECK-START: int Main.MultiplePhis() select_generator (before)
@@ -254,10 +292,8 @@ public class Main {
while (y++ < 10) {
if (y > 1) {
x = 13;
- continue;
} else {
x = 42;
- continue;
}
}
return x;
@@ -330,8 +366,8 @@ public class Main {
}
public static void main(String[] args) throws Exception {
- assertBoolEquals(false, SmaliBooleanNot(true));
- assertBoolEquals(true, SmaliBooleanNot(false));
+ assertBoolEquals(false, BooleanNot(true));
+ assertBoolEquals(true, BooleanNot(false));
assertBoolEquals(true, GreaterThan(10, 5));
assertBoolEquals(false, GreaterThan(10, 10));
assertBoolEquals(false, GreaterThan(5, 10));