blob: 0955be64397608f466154bfaeeed0c8efb6fe116 [file] [log] [blame]
David Brazdil11edec72016-03-24 12:40:52 +00001/*
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
17import java.lang.reflect.Field;
18import java.lang.reflect.Method;
19import java.lang.reflect.InvocationTargetException;
20
21public class Main {
David Brazdil11edec72016-03-24 12:40:52 +000022 public static boolean field0;
23 public static boolean field1;
24 public static boolean field2;
25
26 public static void assertTrue(boolean result) {
27 if (!result) {
28 throw new Error("Expected true");
29 }
30 }
31
32 public static void assertFalse(boolean result) {
33 if (result) {
34 throw new Error("Expected false");
35 }
36 }
37
38 public static void main(String[] args) throws Throwable {
David Brazdil11edec72016-03-24 12:40:52 +000039 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}