1 /*
2  * Copyright (C) 2016 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.Field;
18 import java.lang.reflect.Method;
19 import java.lang.reflect.InvocationTargetException;
20 
21 public class Main {
22   public static boolean field0;
23   public static boolean field1;
24   public static boolean field2;
25 
assertTrue(boolean result)26   public static void assertTrue(boolean result) {
27     if (!result) {
28       throw new Error("Expected true");
29     }
30   }
31 
assertFalse(boolean result)32   public static void assertFalse(boolean result) {
33     if (result) {
34       throw new Error("Expected false");
35     }
36   }
37 
main(String[] args)38   public static void main(String[] args) throws Throwable {
39     Class<?> c = Class.forName("TestCase");
40     Method m = c.getMethod("testCase");
41 
42     try {
43       field0 = true;
44       field1 = false;
45       assertTrue((Boolean) m.invoke(null, null));
46 
47       field0 = true;
48       field1 = true;
49       assertTrue((Boolean) m.invoke(null, null));
50 
51       field0 = false;
52       field1 = false;
53       assertFalse((Boolean) m.invoke(null, null));
54     } catch (Exception e) {
55       throw new Error(e);
56     }
57   }
58 }
59