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.opc_goto; 18 19 import dxc.junit.DxTestCase; 20 import dxc.junit.DxUtil; 21 import dxc.junit.opcodes.opc_goto.jm.T_opc_goto_1; 22 import dxc.junit.opcodes.opc_goto.jm.T_opc_goto_5; 23 24 public class Test_opc_goto extends DxTestCase { 25 26 /** 27 * @title normal test 28 */ 29 public void testN1() { 30 T_opc_goto_1 t = new T_opc_goto_1(); 31 assertEquals(0, t.run(20)); 32 } 33 34 /** 35 * @title normal test 36 */ 37 public void testN2() { 38 T_opc_goto_1 t = new T_opc_goto_1(); 39 assertEquals(-20, t.run(-20)); 40 } 41 42 /** 43 * @title negative offset 44 */ 45 public void testN3() { 46 T_opc_goto_5 t = new T_opc_goto_5(); 47 assertTrue(t.run()); 48 } 49 50 /** 51 * @constraint 4.8.1.7 52 * @title branch target is inside instruction 53 */ 54 public void testVFE1() { 55 try { 56 Class.forName("dxc.junit.opcodes.opc_goto.jm.T_opc_goto_2"); 57 fail("expected a verification exception"); 58 } catch (Throwable t) { 59 DxUtil.checkVerifyException(t); 60 } 61 } 62 63 /** 64 * @constraint 4.8.1.7 65 * @title branch target shall be inside the 66 * method 67 */ 68 public void testVFE2() { 69 try { 70 Class.forName("dxc.junit.opcodes.opc_goto.jm.T_opc_goto_3"); 71 fail("expected a verification exception"); 72 } catch (Throwable t) { 73 DxUtil.checkVerifyException(t); 74 } 75 } 76 77 /** 78 * @constraint 4.8.1.7 79 * @title branch target shall not be "inside" wide 80 * instruction 81 */ 82 public void testVFE3() { 83 try { 84 Class.forName("dxc.junit.opcodes.opc_goto.jm.T_opc_goto_4"); 85 fail("expected a verification exception"); 86 } catch (Throwable t) { 87 DxUtil.checkVerifyException(t); 88 } 89 } 90 91 } 92