• 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.move_exception;
18 
19 import dot.junit.DxTestCase;
20 import dot.junit.DxUtil;
21 import dot.junit.opcodes.move_exception.d.T_move_exception_1;
22 import dot.junit.opcodes.move_exception.d.T_move_exception_2;
23 
24 public class Test_move_exception extends DxTestCase {
25 
26     /**
27      * @title tests move-exception functionality
28      */
testN1()29     public void testN1() {
30         T_move_exception_1 t = new T_move_exception_1();
31         try {
32             t.run();
33             fail("ArithmeticException was not thrown");
34         } catch (ArithmeticException ae) {
35             //expected
36         } catch (Exception ex) {
37             fail("Exception " + ex + " was thrown instead off ArithmeticException");
38         }
39     }
40 
41     /**
42      * @title tests move-exception functionality
43      */
testN2()44     public void testN2() {
45         T_move_exception_2 t = new T_move_exception_2();
46         assertTrue(t.run());
47     }
48 
49     /**
50      * @constraint A23
51      * @title number of registers
52      */
testVFE1()53     public void testVFE1() {
54         try {
55             Class.forName("dot.junit.opcodes.move_exception.d.T_move_exception_3");
56             fail("expected a verification exception");
57         } catch (Throwable t) {
58             DxUtil.checkVerifyException(t);
59         }
60     }
61 
62     /**
63      * @constraint B21
64      * @title  move-exception is not first instruction in an exception handler
65      */
testVFE3()66     public void testVFE3() {
67         try {
68             Class.forName("dot.junit.opcodes.move_exception.d.T_move_exception_5");
69             fail("expected a verification exception");
70         } catch (Throwable t) {
71             DxUtil.checkVerifyException(t);
72         }
73     }
74 
75 }
76