• 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 dxc.junit.opcodes.dload;
18 
19 import dxc.junit.DxTestCase;
20 import dxc.junit.DxUtil;
21 import dxc.junit.opcodes.dload.jm.T_dload_1;
22 import dxc.junit.opcodes.dload.jm.T_dload_1_w;
23 import dxc.junit.opcodes.dload.jm.T_dload_2;
24 import dxc.junit.opcodes.dload.jm.T_dload_2_w;
25 
26 public class Test_dload extends DxTestCase {
27 
28     /*
29      * NORMAL dload VERSION
30      */
31 
32     /**
33      * @title  Test dload 1
34      */
testN1()35     public void testN1() {
36         T_dload_1 t = new T_dload_1();
37         assertEquals(1d, t.run());
38     }
39 
40     /**
41      * @title  Test dload 255
42      */
testN2()43     public void testN2() {
44         T_dload_2 t = new T_dload_2();
45         assertEquals(1d, t.run());
46     }
47 
48     /**
49      * @constraint 4.8.1.21
50      * @title index must be no greater than the value
51      * of max_locals-1
52      */
testVFE1()53     public void testVFE1() {
54         try {
55             Class.forName("dxc.junit.opcodes.dload.jm.T_dload_3");
56             fail("expected a verification exception");
57         } catch (Throwable t) {
58             DxUtil.checkVerifyException(t);
59         }
60     }
61 
62     /**
63      * @constraint 4.8.2.1
64      * @title types of argument - float
65      */
testVFE2()66     public void testVFE2() {
67         try {
68             Class.forName("dxc.junit.opcodes.dload.jm.T_dload_4");
69             fail("expected a verification exception");
70         } catch (Throwable t) {
71             DxUtil.checkVerifyException(t);
72         }
73     }
74 
75     /**
76      * @constraint 4.8.2.1
77      * @title types of argument - long
78      */
testVFE3()79     public void testVFE3() {
80         try {
81             Class.forName("dxc.junit.opcodes.dload.jm.T_dload_5");
82             fail("expected a verification exception");
83         } catch (Throwable t) {
84             DxUtil.checkVerifyException(t);
85         }
86     }
87 
88     /**
89      * @constraint 4.8.2.5
90      * @title stack size
91      */
testVFE4()92     public void testVFE4() {
93         try {
94             Class.forName("dxc.junit.opcodes.dload.jm.T_dload_6");
95             fail("expected a verification exception");
96         } catch (Throwable t) {
97             DxUtil.checkVerifyException(t);
98         }
99     }
100 
101     /*
102      * WIDE dload VERSION
103      */
104 
105     /**
106      * @title  Test dload 257
107      */
testN3()108     public void testN3() {
109         T_dload_1_w t = new T_dload_1_w();
110         assertEquals(1d, t.run());
111     }
112 
113     /**
114      * @title  Test dload_w 1
115      */
testN4()116     public void testN4() {
117         T_dload_2_w t = new T_dload_2_w();
118         assertEquals(1d, t.run());
119     }
120 
121     /**
122      * @constraint 4.8.1.25
123      * @title index must be no greater than the value
124      * of max_locals-1
125      */
testVFE5()126     public void testVFE5() {
127         try {
128             Class.forName("dxc.junit.opcodes.dload.jm.T_dload_3_w");
129             fail("expected a verification exception");
130         } catch (Throwable t) {
131             DxUtil.checkVerifyException(t);
132         }
133     }
134 
135     /**
136      * @constraint 4.8.2.1
137      * @title types of argument - double
138      */
testVFE6()139     public void testVFE6() {
140         try {
141             Class.forName("dxc.junit.opcodes.dload.jm.T_dload_4_w");
142             fail("expected a verification exception");
143         } catch (Throwable t) {
144             DxUtil.checkVerifyException(t);
145         }
146     }
147 
148     /**
149      * @constraint 4.8.2.1
150      * @title types of argument - long
151      */
testVFE7()152     public void testVFE7() {
153         try {
154             Class.forName("dxc.junit.opcodes.dload.jm.T_dload_5_w");
155             fail("expected a verification exception");
156         } catch (Throwable t) {
157             DxUtil.checkVerifyException(t);
158         }
159     }
160 
161     /**
162      * @constraint 4.8.2.5
163      * @title stack size
164      */
testVFE8()165     public void testVFE8() {
166         try {
167             Class.forName("dxc.junit.opcodes.dload.jm.T_dload_6_w");
168             fail("expected a verification exception");
169         } catch (Throwable t) {
170             DxUtil.checkVerifyException(t);
171         }
172     }
173 }
174