• 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.filled_new_array_range;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_1;
22 import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_10;
23 import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_11;
24 import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_2;
25 
26 public class Test_filled_new_array_range extends DxTestCase {
27     /**
28      * @title array of ints
29      */
testN1()30     public void testN1() {
31         T_filled_new_array_range_1 t = new T_filled_new_array_range_1();
32         int[] arr = t.run(1, 2, 3, 4, 5);
33         assertNotNull(arr);
34         assertEquals(5, arr.length);
35         for(int i = 0; i < 5; i++)
36             assertEquals(i + 1, arr[i]);
37      }
38 
39     /**
40      * @title array of objects
41      */
testN2()42     public void testN2() {
43         T_filled_new_array_range_2 t = new T_filled_new_array_range_2();
44         String s = "android";
45         Object[] arr = t.run(t, s);
46         assertNotNull(arr);
47         assertEquals(2, arr.length);
48         assertEquals(t, arr[0]);
49         assertEquals(s, arr[1]);
50     }
51 
52     /**
53      * @constraint A18
54      * @title invalid constant pool index
55      */
testVFE1()56     public void testVFE1() {
57         load("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_3",
58              VerifyError.class);
59     }
60 
61     /**
62      * @constraint A23
63      * @title  number of registers
64      */
testVFE2()65     public void testVFE2() {
66         load("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_4",
67              VerifyError.class);
68     }
69 
70     /**
71      * @constraint B1
72      * @title try to pass obj ref instead of int
73      */
testVFE3()74     public void testVFE3() {
75         load("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_5",
76              VerifyError.class);
77     }
78 
79     /**
80      * @constraint B1
81      * @title try to pass long instead of int
82      */
testVFE4()83     public void testVFE4() {
84         load("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_6",
85              VerifyError.class);
86     }
87 
88     /**
89      * @constraint B1
90      * @title try to create non-array type
91      */
testVFE5()92     public void testVFE5() {
93         load("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_7",
94              VerifyError.class);
95     }
96 
97     /**
98      * @constraint B1
99      * @title invalid arg count
100      */
testVFE6()101     public void testVFE6() {
102         load("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_8",
103              VerifyError.class);
104     }
105 
106     /**
107      * @constraint n/a
108      * @title attempt to instantiate String[] and fill it with reference to assignment-incompatible class
109      */
testVFE7()110     public void testVFE7() {
111         load("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_9",
112              VerifyError.class);
113     }
114 
115     /**
116      * @constraint n/a
117      * @title attempt to instantiate array of non-existent class
118      */
testVFE8()119     public void testVFE8() {
120         loadAndRun("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_10",
121                    NoClassDefFoundError.class);
122     }
123 
124     /**
125      * @constraint n/a
126      * @title attempt to instantiate array of inaccessible class
127      */
testVFE9()128     public void testVFE9() {
129         //@uses dot.junit.opcodes.filled_new_array_range.TestStubs
130         loadAndRun("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_11",
131                    IllegalAccessError.class);
132     }
133 }
134