David Brazdil | 2846b68 | 2015-03-31 09:59:27 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | import java.lang.reflect.*; |
| 18 | |
| 19 | public class Main { |
David Brazdil | 3d23357 | 2015-04-16 16:37:01 +0100 | [diff] [blame^] | 20 | |
David Brazdil | 66d126e | 2015-04-03 16:02:44 +0100 | [diff] [blame] | 21 | // CHECK-START: boolean TestCase.testCase() boolean_simplifier (before) |
| 22 | // CHECK-DAG: [[Const0:i\d+]] IntConstant 0 |
| 23 | // CHECK-DAG: [[Const1:i\d+]] IntConstant 1 |
| 24 | // CHECK-DAG: [[Value:z\d+]] StaticFieldGet |
| 25 | // CHECK-DAG: If [ [[Value]] ] |
| 26 | // CHECK-DAG: [[Phi:i\d+]] Phi [ [[Const1]] [[Const0]] ] |
| 27 | // CHECK-DAG: Return [ [[Phi]] ] |
| 28 | |
| 29 | // CHECK-START: boolean TestCase.testCase() boolean_simplifier (after) |
| 30 | // CHECK-DAG: [[Value:z\d+]] StaticFieldGet |
| 31 | // CHECK-DAG: [[Not:z\d+]] BooleanNot [ [[Value]] ] |
| 32 | // CHECK-DAG: Return [ [[Not]] ] |
David Brazdil | 3d23357 | 2015-04-16 16:37:01 +0100 | [diff] [blame^] | 33 | |
David Brazdil | 2846b68 | 2015-03-31 09:59:27 +0100 | [diff] [blame] | 34 | public static boolean runTest(boolean input) throws Exception { |
| 35 | Class<?> c = Class.forName("TestCase"); |
| 36 | Method m = c.getMethod("testCase"); |
| 37 | Field f = c.getField("value"); |
| 38 | f.set(null, (Boolean) input); |
| 39 | return (Boolean) m.invoke(null); |
| 40 | } |
| 41 | |
| 42 | public static void main(String[] args) throws Exception { |
| 43 | if (runTest(true) != false) { |
| 44 | throw new Error("Expected false, got true"); |
| 45 | } |
| 46 | |
| 47 | if (runTest(false) != true) { |
| 48 | throw new Error("Expected true, got false"); |
| 49 | } |
| 50 | } |
| 51 | } |