Home | History | Annotate | Download | only in opc_instanceof
      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_instanceof;
     18 
     19 import dxc.junit.DxTestCase;
     20 import dxc.junit.DxUtil;
     21 import dxc.junit.opcodes.opc_instanceof.jm.T_opc_instanceof_1;
     22 import dxc.junit.opcodes.opc_instanceof.jm.T_opc_instanceof_2;
     23 import dxc.junit.opcodes.opc_instanceof.jm.T_opc_instanceof_3;
     24 import dxc.junit.opcodes.opc_instanceof.jm.T_opc_instanceof_7;
     25 
     26 public class Test_opc_instanceof extends DxTestCase {
     27 
     28     /**
     29      * @title normal test
     30      */
     31     public void testN1() {
     32         T_opc_instanceof_1 t = new T_opc_instanceof_1();
     33         assertTrue(t.run(""));
     34     }
     35 
     36     /**
     37      * @title check null value
     38      */
     39     public void testN2() {
     40         T_opc_instanceof_1 t = new T_opc_instanceof_1();
     41         assertFalse(t.run(null));
     42     }
     43 
     44     /**
     45      * @title normal test
     46      */
     47     public void testN3() {
     48         T_opc_instanceof_1 t = new T_opc_instanceof_1();
     49         assertFalse(t.run(this));
     50     }
     51 
     52     /**
     53      * @title normal test
     54      */
     55     public void testN4() {
     56         // @uses dxc.junit.opcodes.opc_instanceof.jm.SubClass
     57         // @uses dxc.junit.opcodes.opc_instanceof.jm.SuperClass
     58         // @uses dxc.junit.opcodes.opc_instanceof.jm.SuperInterface
     59         // @uses dxc.junit.opcodes.opc_instanceof.jm.SuperInterface2
     60         T_opc_instanceof_2 t = new T_opc_instanceof_2();
     61         assertEquals(0, t.run());
     62     }
     63 
     64     /**
     65      * @title expected IllegalAccessError
     66      */
     67     public void testE1() {
     68         // @uses dxc.junit.opcodes.opc_instanceof.jm.TestStubs$TestStub
     69         T_opc_instanceof_3 t = new T_opc_instanceof_3();
     70         try {
     71             t.run();
     72             fail("expected IllegalAccessError");
     73         } catch (IllegalAccessError e) {
     74             // expected
     75         } catch (VerifyError vfe) {
     76             // ok for dalvikvm;
     77             System.out.print("dvmvfe:");
     78         }
     79     }
     80 
     81     /**
     82      * @title expected NoClassDefFoundError
     83      */
     84     public void testE2() {
     85         T_opc_instanceof_7 t = new T_opc_instanceof_7();
     86         try {
     87             t.run();
     88             fail("expected NoClassDefFoundError");
     89         } catch (NoClassDefFoundError e) {
     90             // expected
     91         } catch (VerifyError vfe) {
     92             // ok for dalvikvm;
     93             System.out.print("dvmvfe:");
     94         }
     95     }
     96 
     97     /**
     98      * @constraint 4.8.1.16
     99      * @title constant pool index
    100      */
    101     public void testVFE1() {
    102         try {
    103             Class
    104                     .forName("dxc.junit.opcodes.opc_instanceof.jm.T_opc_instanceof_4");
    105             fail("expected a verification exception");
    106         } catch (Throwable t) {
    107             DxUtil.checkVerifyException(t);
    108         }
    109     }
    110 
    111     /**
    112      * @constraint 4.8.2.1
    113      * @title type of argument - float
    114      */
    115     public void testVFE2() {
    116         try {
    117             Class
    118                     .forName("dxc.junit.opcodes.opc_instanceof.jm.T_opc_instanceof_5");
    119             fail("expected a verification exception");
    120         } catch (Throwable t) {
    121             DxUtil.checkVerifyException(t);
    122         }
    123     }
    124 
    125     /**
    126      * @constraint 4.8.2.1
    127      * @title number of arguments
    128      */
    129     public void testVFE3() {
    130         try {
    131             Class
    132                     .forName("dxc.junit.opcodes.opc_instanceof.jm.T_opc_instanceof_6");
    133             fail("expected a verification exception");
    134         } catch (Throwable t) {
    135             DxUtil.checkVerifyException(t);
    136         }
    137     }
    138 
    139     /**
    140      * @constraint 4.8.1.16
    141      * @title constant pool type
    142      */
    143     public void testVFE4() {
    144         try {
    145             Class
    146                     .forName("dxc.junit.opcodes.opc_instanceof.jm.T_opc_instanceof_8");
    147             fail("expected a verification exception");
    148         } catch (Throwable t) {
    149             DxUtil.checkVerifyException(t);
    150         }
    151     }
    152 
    153 }
    154