1 /*
2  * Copyright (C) 2008 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 package dot.junit.opcodes.const_class;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.const_class.d.T_const_class_1;
22 import dot.junit.opcodes.const_class.d.T_const_class_2;
23 import dot.junit.opcodes.const_class.d.T_const_class_6;
24 import dot.junit.opcodes.const_class.d.T_const_class_7;
25 
26 public class Test_const_class extends DxTestCase {
27     /**
28      * @title const-class v254, java/lang/String
29      */
testN1()30     public void testN1() {
31         T_const_class_1 t = new T_const_class_1();
32         Class c = t.run();
33         assertEquals(0, c.getCanonicalName().compareTo("java.lang.String"));
34     }
35 
36     /**
37      * @title const-class v254, I
38      */
testN2()39     public void testN2() {
40         T_const_class_2 t = new T_const_class_2();
41         Class c = t.run();
42         assertEquals(c.getCanonicalName(), "int");
43     }
44 
45     /**
46      * @title Class definition not found
47      */
testE1()48     public void testE1() {
49         loadAndRun("dot.junit.opcodes.const_class.d.T_const_class_6", NoClassDefFoundError.class);
50     }
51 
52     /**
53      * @title Class is not accessible
54      */
testE2()55     public void testE2() {
56         //@uses dot.junit.opcodes.const_class.TestStubs
57         loadAndRun("dot.junit.opcodes.const_class.d.T_const_class_7", IllegalAccessError.class);
58     }
59 
60     /**
61      * @constraint A23
62      * @title  number of registers
63      */
testVFE1()64     public void testVFE1() {
65         load("dot.junit.opcodes.const_class.d.T_const_class_3", VerifyError.class);
66     }
67 
68     /**
69      * @constraint B11
70      * @title  When writing to a register that is one half of a register
71      * pair, but not touching the other half, the old register pair gets broken up, and the
72      * other register involved in it becomes undefined
73      */
testVFE2()74     public void testVFE2() {
75         load("dot.junit.opcodes.const_class.d.T_const_class_4", VerifyError.class);
76     }
77 
78     /**
79      * @constraint A18
80      * @title  constant pool index
81      */
testVFE3()82     public void testVFE3() {
83         load("dot.junit.opcodes.const_class.d.T_const_class_5", VerifyError.class);
84     }
85 
86 }
87