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.instance_of; 18 19 import dot.junit.DxTestCase; 20 import dot.junit.DxUtil; 21 import dot.junit.opcodes.instance_of.d.T_instance_of_1; 22 import dot.junit.opcodes.instance_of.d.T_instance_of_2; 23 import dot.junit.opcodes.instance_of.d.T_instance_of_3; 24 import dot.junit.opcodes.instance_of.d.T_instance_of_7; 25 26 public class Test_instance_of extends DxTestCase { 27 28 29 /** 30 * @title (Object)String instanceof String 31 */ testN1()32 public void testN1() { 33 T_instance_of_1 t = new T_instance_of_1(); 34 String s = ""; 35 assertTrue(t.run(s)); 36 } 37 38 /** 39 * @title null instanceof String 40 */ testN2()41 public void testN2() { 42 T_instance_of_1 t = new T_instance_of_1(); 43 assertFalse(t.run(null)); 44 } 45 46 /** 47 * @title check assignment compatibility rules 48 */ testN4()49 public void testN4() { 50 T_instance_of_2 t = new T_instance_of_2(); 51 assertTrue(t.run()); 52 } 53 54 /** 55 * @title T_instance_of_1 instanceof String 56 */ testE1()57 public void testE1() { 58 T_instance_of_1 t = new T_instance_of_1(); 59 assertFalse(t.run(t)); 60 } 61 62 /** 63 * @title Attempt to access inaccessible class. 64 */ testE2()65 public void testE2() { 66 //@uses dot.junit.opcodes.instance_of.TestStubs 67 loadAndRun("dot.junit.opcodes.instance_of.d.T_instance_of_3", IllegalAccessError.class); 68 } 69 70 /** 71 * @title Attempt to access undefined class. 72 */ testE3()73 public void testE3() { 74 loadAndRun("dot.junit.opcodes.instance_of.d.T_instance_of_7", NoClassDefFoundError.class); 75 } 76 77 /** 78 * @constraint A19 79 * @title constant pool index 80 */ testVFE1()81 public void testVFE1() { 82 load("dot.junit.opcodes.instance_of.d.T_instance_of_4", VerifyError.class); 83 } 84 85 /** 86 * 87 * @constraint B1 88 * @title type of argument - int 89 */ testVFE2()90 public void testVFE2() { 91 load("dot.junit.opcodes.instance_of.d.T_instance_of_5", VerifyError.class); 92 } 93 94 /** 95 * 96 * @constraint B1 97 * @title type of argument - long 98 */ testVFE3()99 public void testVFE3() { 100 load("dot.junit.opcodes.instance_of.d.T_instance_of_8", VerifyError.class); 101 } 102 103 /** 104 * 105 * @constraint B1 106 * @title number of registers 107 */ testVFE4()108 public void testVFE4() { 109 load("dot.junit.opcodes.instance_of.d.T_instance_of_6", VerifyError.class); 110 } 111 112 113 } 114