• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.sget_boolean;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.sget_boolean.d.T_sget_boolean_1;
22 import dot.junit.opcodes.sget_boolean.d.T_sget_boolean_11;
23 import dot.junit.opcodes.sget_boolean.d.T_sget_boolean_12;
24 import dot.junit.opcodes.sget_boolean.d.T_sget_boolean_13;
25 import dot.junit.opcodes.sget_boolean.d.T_sget_boolean_5;
26 import dot.junit.opcodes.sget_boolean.d.T_sget_boolean_6;
27 import dot.junit.opcodes.sget_boolean.d.T_sget_boolean_7;
28 import dot.junit.opcodes.sget_boolean.d.T_sget_boolean_8;
29 import dot.junit.opcodes.sget_boolean.d.T_sget_boolean_9;
30 
31 public class Test_sget_boolean extends DxTestCase {
32 
33     /**
34      * @title get boolean from static field
35      */
testN1()36     public void testN1() {
37         T_sget_boolean_1 t = new T_sget_boolean_1();
38         assertEquals(true, t.run());
39     }
40 
41 
42     /**
43      * @title access protected field from subclass
44      */
testN3()45     public void testN3() {
46         //@uses dot.junit.opcodes.sget_boolean.d.T_sget_boolean_1
47         //@uses dot.junit.opcodes.sget_boolean.d.T_sget_boolean_11
48         T_sget_boolean_11 t = new T_sget_boolean_11();
49         assertEquals(true, t.run());
50     }
51 
52     /**
53      * @constraint A12
54      * @title attempt to access non-static field
55      */
testE1()56     public void testE1() {
57         loadAndRun("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_5",
58                    IncompatibleClassChangeError.class);
59     }
60 
61     /**
62      * @title initialization of referenced class throws exception
63      */
testE6()64     public void testE6() {
65         loadAndRun("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_9",
66                    ExceptionInInitializerError.class);
67     }
68 
69     /**
70      * @constraint A12
71      * @title constant pool index
72      */
testVFE1()73     public void testVFE1() {
74         load("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_4", VerifyError.class);
75     }
76 
77     /**
78      *
79      * @constraint A23
80      * @title number of registers
81      */
testVFE2()82     public void testVFE2() {
83         load("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_3", VerifyError.class);
84     }
85 
86     /**
87      *
88      * @constraint B13
89      * @title read boolean from long field - only field with same name but
90      * different type exists
91      */
testVFE3()92     public void testVFE3() {
93         loadAndRun("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_13", NoSuchFieldError.class);
94     }
95 
96     /**
97      * @constraint n/a
98      * @title Attempt to read inaccessible field.
99      */
testVFE4()100     public void testVFE4() {
101         //@uses dot.junit.opcodes.sget_boolean.TestStubs
102         loadAndRun("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_6", IllegalAccessError.class);
103     }
104 
105     /**
106      * @constraint n/a
107      * @title Attempt to read field of undefined class.
108      */
testVFE5()109     public void testVFE5() {
110         loadAndRun("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_7", NoClassDefFoundError.class);
111     }
112 
113     /**
114      * @constraint n/a
115      * @title Attempt to read undefined field.
116      */
testVFE6()117     public void testVFE6() {
118         loadAndRun("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_8", NoSuchFieldError.class);
119     }
120 
121     /**
122      * @constraint n/a
123      * @title Attempt to read superclass' private field from subclass.
124      */
testVFE7()125     public void testVFE7() {
126         //@uses dot.junit.opcodes.sget_boolean.d.T_sget_boolean_1
127         loadAndRun("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_12", IllegalAccessError.class);
128     }
129 
130     /**
131      * @constraint B1
132      * @title sget_boolean shall not work for reference fields
133      */
testVFE8()134     public void testVFE8() {
135         load("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_14", VerifyError.class);
136     }
137 
138     /**
139      *
140      * @constraint B1
141      * @title sget_boolean shall not work for short fields
142      */
testVFE9()143     public void testVFE9() {
144         load("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_15", VerifyError.class);
145     }
146 
147     /**
148      *
149      * @constraint B1
150      * @title sget_boolean shall not work for int fields
151      */
testVFE10()152     public void testVFE10() {
153         load("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_16", VerifyError.class);
154     }
155 
156     /**
157      *
158      * @constraint B1
159      * @title sget_boolean shall not work for char fields
160      */
testVFE11()161     public void testVFE11() {
162         load("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_17", VerifyError.class);
163     }
164 
165     /**
166      *
167      * @constraint B1
168      * @title sget_boolean shall not work for byte fields
169      */
testVFE12()170     public void testVFE12() {
171         load("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_18", VerifyError.class);
172     }
173 
174     /**
175      *
176      * @constraint B1
177      * @title sget_boolean shall not work for double fields
178      */
testVFE13()179     public void testVFE13() {
180         load("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_19", VerifyError.class);
181     }
182 
183     /**
184      *
185      * @constraint B1
186      * @title sget_boolean shall not work for long fields
187      */
testVFE14()188     public void testVFE14() {
189         load("dot.junit.opcodes.sget_boolean.d.T_sget_boolean_20", VerifyError.class);
190     }
191 }
192