diff options
author | 2016-08-01 11:09:50 +0200 | |
---|---|---|
committer | 2016-09-21 13:45:08 +0200 | |
commit | 9837caff9cbfb61e3dabc6fbecb398d4d659c017 (patch) | |
tree | b8101227d3987cebbc1c9d13f5d5f23a037a9f9a /test/463-checker-boolean-simplifier/src/Main.java | |
parent | 80eb0bc2757274816a014a2997848d288c9ee553 (diff) |
Update art tests
Jack generates different code compared to the previous release so
some tests need to be updated. For instance, Jack transform '!cond'
into 'cond xor 1'.
The test 463-checker-boolean-simplifier still tests the if/else
pattern using smali.
(cherry picked from commit e4d28c502486afe58a0e156b8fefb621a622cec2)
Bug: 29493697
Test: lunch aosp_bullhead-userdebug && make -j32
Test: make -j32 test-art-host && make -j32 test-art-target
Test: art/tools/run-jdwp-tests.sh --mode=host
Change-Id: Ief8ac3e9a4bcaa35c99e57161961d630333d3b3c
Diffstat (limited to 'test/463-checker-boolean-simplifier/src/Main.java')
-rw-r--r-- | test/463-checker-boolean-simplifier/src/Main.java | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/test/463-checker-boolean-simplifier/src/Main.java b/test/463-checker-boolean-simplifier/src/Main.java index f0fe1b172f..9368488056 100644 --- a/test/463-checker-boolean-simplifier/src/Main.java +++ b/test/463-checker-boolean-simplifier/src/Main.java @@ -32,42 +32,14 @@ public class Main { } } - /* - * 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 [<<Const0>>,<<Const1>>] - /// 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; + // 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(); } /* @@ -357,9 +329,9 @@ public class Main { return x ? 42 : (write_field = 43); } - public static void main(String[] args) { - assertBoolEquals(false, BooleanNot(true)); - assertBoolEquals(true, BooleanNot(false)); + public static void main(String[] args) throws Exception { + assertBoolEquals(false, SmaliBooleanNot(true)); + assertBoolEquals(true, SmaliBooleanNot(false)); assertBoolEquals(true, GreaterThan(10, 5)); assertBoolEquals(false, GreaterThan(10, 10)); assertBoolEquals(false, GreaterThan(5, 10)); |