blob: d45f3bfa168e886e4ff3cb98ac0088b07d2c2b28 [file] [log] [blame]
David Brazdil2846b682015-03-31 09:59:27 +01001/*
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
17import java.lang.reflect.*;
18
19public class Main {
David Brazdil3d233572015-04-16 16:37:01 +010020
David Brazdil66d126e2015-04-03 16:02:44 +010021 // 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 Brazdil3d233572015-04-16 16:37:01 +010033
David Brazdil2846b682015-03-31 09:59:27 +010034 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}