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