• 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.invoke_static_range;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_1;
22 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_13;
23 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_14;
24 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_15;
25 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_17;
26 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_18;
27 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_19;
28 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_2;
29 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_24;
30 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_4;
31 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_5;
32 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_6;
33 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_7;
34 import dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_8;
35 
36 
37 
38 public class Test_invoke_static_range extends DxTestCase {
39 
40     /**
41      * @title Static method from library class Math
42      */
testN1()43     public void testN1() {
44         T_invoke_static_range_1 t = new T_invoke_static_range_1();
45         assertEquals(1234567, t.run());
46     }
47 
48     /**
49      * @title Static method from user class
50      */
testN2()51     public void testN2() {
52         //@uses dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_2
53         //@uses dot.junit.opcodes.invoke_static_range.TestClass
54         T_invoke_static_range_2 t = new T_invoke_static_range_2();
55         assertEquals(777, t.run());
56     }
57 
58     /**
59      * @title Big number of registers
60      */
testN3()61     public void testN3() {
62         assertEquals(1, T_invoke_static_range_4.run());
63     }
64 
65 
66     /**
67      * @title Check that new frame is created by invoke_static_range and
68      * arguments are passed to method
69      */
testN5()70     public void testN5() {
71         //@uses dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_15
72         //@uses dot.junit.opcodes.invoke_static_range.TestClass
73         T_invoke_static_range_15 t = new T_invoke_static_range_15();
74         assertTrue(t.run());
75     }
76 
77     /**
78      * @title Static protected method from other class in the same package
79      */
testN6()80     public void testN6() {
81         T_invoke_static_range_18 t = new T_invoke_static_range_18();
82         assertEquals(888, t.run());
83     }
84 
85     /**
86      * @title Native method can't be linked
87      *
88      */
testE2()89     public void testE2() {
90         loadAndRun("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_6",
91                    UnsatisfiedLinkError.class);
92     }
93 
94 
95     /**
96      * @title initialization of referenced class throws exception
97      */
testE7()98     public void testE7() {
99         loadAndRun("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_14",
100                    ExceptionInInitializerError.class);
101     }
102 
103     /**
104      * @constraint A14
105      * @title invalid constant pool index
106      */
testVFE1()107     public void testVFE1() {
108         load("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_3", VerifyError.class);
109     }
110 
111     /**
112      * @constraint A15
113      * @title <clinit> may not be called using invoke_static_range
114      */
testVFE3()115     public void testVFE3() {
116         load("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_10", VerifyError.class);
117     }
118 
119     /**
120      * @constraint B1
121      * @title number of arguments passed to method
122      */
testVFE4()123     public void testVFE4() {
124         load("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_11", VerifyError.class);
125     }
126 
127     /**
128      * @constraint A15
129      * @title <init> may not be called using invoke_static_range
130      */
testVFE5()131     public void testVFE5() {
132         load("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_19", VerifyError.class);
133     }
134 
135     /**
136      * @constraint B9
137      * @title types of arguments passed to method
138      */
testVFE6()139     public void testVFE6() {
140         load("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_20", VerifyError.class);
141     }
142 
143 
144     /**
145      * @constraint n/a
146      * @title Attempt to call non-static method.
147      */
testVFE7()148     public void testVFE7() {
149         loadAndRun("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_5",
150                    IncompatibleClassChangeError.class);
151     }
152 
153     /**
154      * @constraint n/a
155      * @title Attempt to call undefined method.
156      */
testVFE8()157     public void testVFE8() {
158         loadAndRun("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_7",
159                    NoSuchMethodError.class);
160     }
161 
162     /**
163      * @constraint n/a
164      * @title Attempt to call private method of other class.
165      */
testVFE9()166     public void testVFE9() {
167         //@uses dot.junit.opcodes.invoke_static_range.TestClass
168         loadAndRun("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_8",
169                    IllegalAccessError.class);
170     }
171 
172     /**
173      * @constraint n/a
174      * @title Method has different signature.
175      */
testVFE10()176     public void testVFE10() {
177         //@uses dot.junit.opcodes.invoke_static_range.TestClass
178         loadAndRun("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_13",
179                    NoSuchMethodError.class);
180     }
181 
182 
183     /**
184      * @constraint B12
185      * @title Attempt to call protected method of unrelated class.
186      */
testVFE12()187     public void testVFE12() {
188         //@uses dot.junit.opcodes.invoke_static_range.TestClass
189         loadAndRun("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_17",
190                    IllegalAccessError.class);
191     }
192 
193     /**
194      * @constraint A23
195      * @title number of registers
196      */
testVFE13()197     public void testVFE13() {
198         load("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_16", VerifyError.class);
199     }
200 
201     /**
202      * @constraint A14
203      * @title attempt to invoke interface method
204      */
testVFE18()205     public void testVFE18() {
206         load("dot.junit.opcodes.invoke_static_range.d.T_invoke_static_range_24", VerifyError.class);
207     }
208 }
209