Home | History | Annotate | Download | only in aload
      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.aload;
     18 
     19 import dxc.junit.DxTestCase;
     20 import dxc.junit.DxUtil;
     21 import dxc.junit.opcodes.aload.jm.T_aload_1;
     22 import dxc.junit.opcodes.aload.jm.T_aload_1_w;
     23 import dxc.junit.opcodes.aload.jm.T_aload_2;
     24 import dxc.junit.opcodes.aload.jm.T_aload_2_w;
     25 
     26 /**
     27  * NORMAL aload VERSION
     28  */
     29 public class Test_aload extends DxTestCase {
     30 
     31     /**
     32      * @title  Test aload 1
     33      */
     34     public void testN1() {
     35         T_aload_1 t = new T_aload_1();
     36         assertEquals("hello", t.run());
     37     }
     38 
     39     /**
     40      * @title  Test aload 255
     41      */
     42     public void testN2() {
     43         T_aload_2 t = new T_aload_2();
     44         assertEquals("hello", t.run());
     45     }
     46 
     47     /**
     48      * @constraint 4.8.1.21
     49      * @title index must be no greater than the value
     50      * of max_locals-1
     51      */
     52     public void testVFE1() {
     53         try {
     54             Class.forName("dxc.junit.opcodes.aload.jm.T_aload_3");
     55             fail("expected a verification exception");
     56         } catch (Throwable t) {
     57             DxUtil.checkVerifyException(t);
     58         }
     59     }
     60 
     61 
     62     /**
     63      * @constraint 4.8.2.1
     64      * @title types of argument - float
     65      */
     66     public void testVFE2() {
     67         try {
     68             Class.forName("dxc.junit.opcodes.aload.jm.T_aload_4");
     69             fail("expected a verification exception");
     70         } catch (Throwable t) {
     71             DxUtil.checkVerifyException(t);
     72         }
     73     }
     74 
     75     /**
     76      * @constraint 4.8.2.1
     77      * @title types of argument - long
     78      */
     79     public void testVFE3() {
     80         try {
     81             Class.forName("dxc.junit.opcodes.aload.jm.T_aload_5");
     82             fail("expected a verification exception");
     83         } catch (Throwable t) {
     84             DxUtil.checkVerifyException(t);
     85         }
     86     }
     87 
     88     /**
     89      * @constraint 4.8.2.5
     90      * @title stack size
     91      */
     92     public void testVFE4() {
     93         try {
     94             Class.forName("dxc.junit.opcodes.aload.jm.T_aload_6");
     95             fail("expected a verification exception");
     96         } catch (Throwable t) {
     97             DxUtil.checkVerifyException(t);
     98         }
     99     }
    100 
    101     /**
    102      * @constraint 4.8.2.21
    103      * @title returnAddress may not be loaded from
    104      * local variable
    105      */
    106     public void testVFE5() {
    107         try {
    108             Class.forName("dxc.junit.opcodes.aload.jm.T_aload_7");
    109             fail("expected a verification exception");
    110         } catch (Throwable t) {
    111             DxUtil.checkVerifyException(t);
    112         }
    113     }
    114 
    115     /*
    116      * WIDE aload VERSION
    117      */
    118 
    119     /**
    120      * @title  Test aload 257
    121      */
    122     public void testN3() {
    123         T_aload_1_w t = new T_aload_1_w();
    124         assertEquals("hello", t.run());
    125     }
    126 
    127     /**
    128      * @title  Test aload_w 1
    129      */
    130     public void testN4() {
    131         T_aload_2_w t = new T_aload_2_w();
    132         assertEquals("hello", t.run());
    133     }
    134 
    135     /**
    136      * @constraint 4.8.1.25
    137      * @title index must be no greater than the value
    138      * of max_locals-1
    139      */
    140     public void testVFE6() {
    141         try {
    142             Class.forName("dxc.junit.opcodes.aload.jm.T_aload_3_w");
    143             fail("expected a verification exception");
    144         } catch (Throwable t) {
    145             DxUtil.checkVerifyException(t);
    146         }
    147     }
    148 
    149 
    150     /**
    151      * @constraint 4.8.2.1
    152      * @title types of argument - int
    153      */
    154     public void testVFE7() {
    155         try {
    156             Class.forName("dxc.junit.opcodes.aload.jm.T_aload_4_w");
    157             fail("expected a verification exception");
    158         } catch (Throwable t) {
    159             DxUtil.checkVerifyException(t);
    160         }
    161     }
    162 
    163     /**
    164      * @constraint 4.8.2.1
    165      * @title types of argument - double
    166      */
    167     public void testVFE8() {
    168         try {
    169             Class.forName("dxc.junit.opcodes.aload.jm.T_aload_5_w");
    170             fail("expected a verification exception");
    171         } catch (Throwable t) {
    172             DxUtil.checkVerifyException(t);
    173         }
    174     }
    175 
    176     /**
    177      * @constraint 4.8.2.5
    178      * @title stack size
    179      */
    180     public void testVFE9() {
    181         try {
    182             Class.forName("dxc.junit.opcodes.aload.jm.T_aload_6_w");
    183             fail("expected a verification exception");
    184         } catch (Throwable t) {
    185             DxUtil.checkVerifyException(t);
    186         }
    187     }
    188 
    189     /**
    190      * @constraint 4.8.2.21
    191      * @title returnAddress may not be loaded from
    192      * local variable
    193      */
    194     public void testVFE10() {
    195         try {
    196             Class.forName("dxc.junit.opcodes.aload.jm.T_aload_7_w");
    197             fail("expected a verification exception");
    198         } catch (Throwable t) {
    199             DxUtil.checkVerifyException(t);
    200         }
    201     }
    202 }
    203