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.iget_boolean;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_1;
22 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_11;
23 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_12;
24 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_13;
25 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_21;
26 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_5;
27 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_6;
28 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_7;
29 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_8;
30 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_9;
31 
32 public class Test_iget_boolean extends DxTestCase {
33 
34     /**
35      * @title get boolean from field
36      */
testN1()37     public void testN1() {
38         T_iget_boolean_1 t = new T_iget_boolean_1();
39         assertEquals(true, t.run());
40     }
41 
42 
43     /**
44      * @title access protected field from subclass
45      */
testN3()46     public void testN3() {
47         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_1
48         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_11
49         T_iget_boolean_11 t = new T_iget_boolean_11();
50         assertEquals(true, t.run());
51     }
52 
53     /**
54      * @title expected NullPointerException
55      */
testE2()56     public void testE2() {
57         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_9",
58                    NullPointerException.class);
59     }
60 
61     /**
62      * @constraint A11
63      * @title constant pool index
64      */
testVFE1()65     public void testVFE1() {
66         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_4", VerifyError.class);
67     }
68 
69     /**
70      * @constraint A23
71      * @title number of registers
72      */
testVFE2()73     public void testVFE2() {
74         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_3", VerifyError.class);
75     }
76 
77     /**
78      * @constraint B13
79      * @title read boolean from long field - only field with same name but
80      * different type exists
81      */
testVFE3()82     public void testVFE3() {
83         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_13", NoSuchFieldError.class);
84     }
85 
86     /**
87      * @constraint n/a
88      * @title Attempt to read inaccessible field
89      */
testVFE4()90     public void testVFE4() {
91         //@uses dot.junit.opcodes.iget_boolean.TestStubs
92         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_6", IllegalAccessError.class);
93     }
94 
95     /**
96      * @constraint n/a
97      * @title Attempt to read field of undefined class.
98      */
testVFE5()99     public void testVFE5() {
100         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_7",
101                    NoClassDefFoundError.class);
102     }
103 
104     /**
105      * @constraint n/a
106      * @title Attempt to read undefined field.
107      */
testVFE6()108     public void testVFE6() {
109         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_8", NoSuchFieldError.class);
110     }
111 
112     /**
113      * @constraint n/a
114      * @title Attempt to read superclass' private field from subclass.
115      */
testVFE7()116     public void testVFE7() {
117         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_1
118         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_12
119         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_12", IllegalAccessError.class);
120     }
121 
122     /**
123      * @constraint B1
124      * @title iget_boolean shall not work for reference fields
125      */
testVFE8()126     public void testVFE8() {
127         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_14", VerifyError.class);
128     }
129 
130     /**
131      *
132      * @constraint B1
133      * @title iget_boolean shall not work for short fields
134      */
testVFE9()135     public void testVFE9() {
136         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_15", VerifyError.class);
137     }
138 
139     /**
140      * @constraint B1
141      * @title iget_boolean shall not work for int fields
142      */
testVFE10()143     public void testVFE10() {
144         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_16", VerifyError.class);
145     }
146 
147     /**
148      * @constraint B1
149      * @title iget_boolean shall not work for char fields
150      */
testVFE11()151     public void testVFE11() {
152         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_17", VerifyError.class);
153     }
154 
155     /**
156      * @constraint B1
157      * @title iget_boolean shall not work for byte fields
158      */
testVFE12()159     public void testVFE12() {
160         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_18", VerifyError.class);
161     }
162 
163     /**
164      * @constraint B1
165      * @title iget_boolean shall not work for double fields
166      */
testVFE13()167     public void testVFE13() {
168         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_19", VerifyError.class);
169     }
170 
171     /**
172      * @constraint B1
173      * @title iget_boolean shall not work for long fields
174      */
testVFE14()175     public void testVFE14() {
176         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_20", VerifyError.class);
177     }
178 
179     /**
180      * @constraint B12
181      * @title Attempt to read inaccessible protected field.
182      */
testVFE15()183     public void testVFE15() {
184         //@uses dot.junit.opcodes.iget_boolean.TestStubs
185         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_21", IllegalAccessError.class);
186     }
187 
188 
189     /**
190      * @constraint A11
191      * @title Attempt to read static field.
192      */
testVFE16()193     public void testVFE16() {
194         //@uses dot.junit.opcodes.iget_boolean.TestStubs
195         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_5",
196                    IncompatibleClassChangeError.class);
197     }
198 
199     /**
200      * @constraint B6
201      * @title instance fields may only be accessed on already initialized instances.
202      */
testVFE30()203     public void testVFE30() {
204         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_30", VerifyError.class);
205     }
206 
207     /**
208      * @constraint N/A
209      * @title instance fields may only be accessed on reference values.
210      */
testVFE31()211     public void testVFE31() {
212         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_31", VerifyError.class);
213     }
214 }
215