• 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.new_instance;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.new_instance.d.T_new_instance_1;
22 import dot.junit.opcodes.new_instance.d.T_new_instance_3;
23 import dot.junit.opcodes.new_instance.d.T_new_instance_4;
24 import dot.junit.opcodes.new_instance.d.T_new_instance_5;
25 import dot.junit.opcodes.new_instance.d.T_new_instance_8;
26 import dot.junit.opcodes.new_instance.d.T_new_instance_9;
27 
28 
29 public class Test_new_instance extends DxTestCase {
30 
31     /**
32      * @title new String
33      */
testN1()34     public void testN1() {
35         T_new_instance_1 t = new T_new_instance_1();
36         String s = t.run();
37         assertNotNull(s);
38         assertEquals(0, s.compareTo("abc"));
39     }
40 
41     /**
42      * @title class initialization throws exception
43      */
testE1()44     public void testE1() {
45         load("dot.junit.opcodes.new_instance.d.T_new_instance_3",
46              ExceptionInInitializerError.class);
47     }
48 
49     /**
50      * @constraint A21
51      * @title  attempt to instantiate interface
52      */
testE4()53     public void testE4() {
54         //@uses dot.junit.opcodes.new_instance.d.TestAbstractClass
55         loadAndRun("dot.junit.opcodes.new_instance.d.T_new_instance_8", InstantiationError.class);
56     }
57 
58     /**
59      * @constraint A21
60      * @title  attempt to instantiate abstract
61      * class
62      */
testE5()63     public void testE5() {
64         //@uses dot.junit.opcodes.new_instance.d.TestAbstractClass
65         loadAndRun("dot.junit.opcodes.new_instance.d.T_new_instance_9", InstantiationError.class);
66     }
67 
68     /**
69      * @constraint A18
70      * @title  constant pool index
71      */
testVFE1()72     public void testVFE1() {
73         load("dot.junit.opcodes.new_instance.d.T_new_instance_6", VerifyError.class);
74     }
75 
76     /**
77      *
78      * @constraint A21
79      * @title  attempt to create array using new
80      */
testVFE2()81     public void testVFE2() {
82         load("dot.junit.opcodes.new_instance.d.T_new_instance_7", VerifyError.class);
83     }
84 
85     /**
86      * @constraint B6
87      * @title Attempt to access uninitialized class (before <init> is
88      * called
89      */
testVFE3()90     public void testVFE3() {
91         load("dot.junit.opcodes.new_instance.d.T_new_instance_2", VerifyError.class);
92     }
93 
94     /**
95      * @constraint A23
96      * @title number of registers
97      */
testVFE4()98     public void testVFE4() {
99         load("dot.junit.opcodes.new_instance.d.T_new_instance_10", VerifyError.class);
100     }
101 
102     /**
103      * @constraint n/a
104      * @title Attempt to instantiate array of inaccessible class.
105      */
testVFE5()106     public void testVFE5() {
107         //@uses dot.junit.opcodes.new_instance.TestStubs
108         loadAndRun("dot.junit.opcodes.new_instance.d.T_new_instance_4", IllegalAccessError.class);
109     }
110 
111     /**
112      * @constraint n/a
113      * @title Attempt to instantiate array of non-existent class.
114      */
testVFE6()115     public void testVFE6() {
116         loadAndRun("dot.junit.opcodes.new_instance.d.T_new_instance_5", NoClassDefFoundError.class);
117     }
118 
119     /**
120      * @constraint B7
121      * @title A register which holds the result of a new-instance instruction must not be used
122      * if the same new-instance  instruction is again executed before the instance is initialized
123      */
testVFE7()124     public void testVFE7() {
125         load("dot.junit.opcodes.new_instance.d.T_new_instance_11", VerifyError.class);
126     }
127 
128     /**
129      * @constraint B7
130      * @title A register which holds the result of a new-instance instruction must not be used
131      * if the same new-instance  instruction is again executed before the instance is initialized
132      */
testVFE8()133     public void testVFE8() {
134         load("dot.junit.opcodes.new_instance.d.T_new_instance_12", VerifyError.class);
135     }
136 }
137