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.ret; 18 19 import dxc.junit.DxTestCase; 20 import dxc.junit.DxUtil; 21 import dxc.junit.opcodes.ret.jm.T_ret_1; 22 import dxc.junit.opcodes.ret.jm.T_ret_1_w; 23 24 public class Test_ret extends DxTestCase { 25 26 /** 27 * NORMAL RET VERSION 28 */ 29 30 /** 31 * @title normal test 32 */ 33 public void testN1() { 34 T_ret_1 t = new T_ret_1(); 35 assertTrue(t.run()); 36 } 37 38 /** 39 * @constraint 4.8.1.21 40 * @title index operand 41 */ 42 public void testVFE1() { 43 try { 44 Class.forName("dxc.junit.opcodes.ret.jm.T_ret_2"); 45 fail("expected a verification exception"); 46 } catch (Throwable t) { 47 DxUtil.checkVerifyException(t); 48 } 49 } 50 51 /** 52 * @constraint 4.8.2.1 53 * @title variable referenced by index shall 54 * contain returnAddress 55 */ 56 public void testVFE2() { 57 try { 58 Class.forName("dxc.junit.opcodes.ret.jm.T_ret_3"); 59 fail("expected a verification exception"); 60 } catch (Throwable t) { 61 DxUtil.checkVerifyException(t); 62 } 63 } 64 65 /** 66 * @constraint 4.8.2.24 67 * @title each returnAddress can be returned only 68 * once 69 */ 70 public void testVFE5() { 71 try { 72 Class.forName("dxc.junit.opcodes.ret.jm.T_ret_4"); 73 fail("expected a verification exception"); 74 } catch (Throwable t) { 75 DxUtil.checkVerifyException(t); 76 } 77 } 78 79 /** 80 * @constraint 4.8.2.22 81 * @title single ret instruction 82 */ 83 public void testVFE7() { 84 try { 85 Class.forName("dxc.junit.opcodes.ret.jm.T_ret_5"); 86 fail("expected a verification exception"); 87 } catch (Throwable t) { 88 DxUtil.checkVerifyException(t); 89 } 90 } 91 92 /** 93 * WIDE RET VERSION 94 */ 95 96 /** 97 * @title 98 */ 99 public void testN2() { 100 T_ret_1_w t = new T_ret_1_w(); 101 assertTrue(t.run()); 102 } 103 104 /** 105 * @constraint 4.8.1.21 106 * @title index operand 107 */ 108 public void testVFE3() { 109 try { 110 Class.forName("dxc.junit.opcodes.ret.jm.T_ret_2_w"); 111 fail("expected a verification exception"); 112 } catch (Throwable t) { 113 DxUtil.checkVerifyException(t); 114 } 115 } 116 117 /** 118 * @constraint 4.8.2.1 119 * @title variable referenced by index shall 120 * contain returnAddress 121 */ 122 public void testVFE4() { 123 try { 124 Class.forName("dxc.junit.opcodes.ret.jm.T_ret_3_w"); 125 fail("expected a verification exception"); 126 } catch (Throwable t) { 127 DxUtil.checkVerifyException(t); 128 } 129 } 130 131 /** 132 * @constraint 4.8.2.24 133 * @title each returnAddress can be returned only 134 * once 135 */ 136 public void testVFE6() { 137 try { 138 Class.forName("dxc.junit.opcodes.ret.jm.T_ret_4_w"); 139 fail("expected a verification exception"); 140 } catch (Throwable t) { 141 DxUtil.checkVerifyException(t); 142 } 143 } 144 145 /** 146 * @constraint 4.8.2.22 147 * @title single ret instruction 148 */ 149 public void testVFE8() { 150 try { 151 Class.forName("dxc.junit.opcodes.ret.jm.T_ret_5_w"); 152 fail("expected a verification exception"); 153 } catch (Throwable t) { 154 DxUtil.checkVerifyException(t); 155 } 156 } 157 } 158