Home | History | Annotate | Download | only in iget_wide
      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.iget_wide;
     18 
     19 import dot.junit.DxTestCase;
     20 import dot.junit.DxUtil;
     21 import dot.junit.opcodes.iget_wide.d.T_iget_wide_1;
     22 import dot.junit.opcodes.iget_wide.d.T_iget_wide_11;
     23 import dot.junit.opcodes.iget_wide.d.T_iget_wide_12;
     24 import dot.junit.opcodes.iget_wide.d.T_iget_wide_13;
     25 import dot.junit.opcodes.iget_wide.d.T_iget_wide_2;
     26 import dot.junit.opcodes.iget_wide.d.T_iget_wide_21;
     27 import dot.junit.opcodes.iget_wide.d.T_iget_wide_5;
     28 import dot.junit.opcodes.iget_wide.d.T_iget_wide_6;
     29 import dot.junit.opcodes.iget_wide.d.T_iget_wide_7;
     30 import dot.junit.opcodes.iget_wide.d.T_iget_wide_8;
     31 import dot.junit.opcodes.iget_wide.d.T_iget_wide_9;
     32 
     33 public class Test_iget_wide extends DxTestCase {
     34 
     35     /**
     36      * @title type - long
     37      */
     38     public void testN1() {
     39         T_iget_wide_1 t = new T_iget_wide_1();
     40         assertEquals(12345679890123l, t.run());
     41     }
     42 
     43     /**
     44      * @title type - double
     45      */
     46     public void testN2() {
     47         T_iget_wide_2 t = new T_iget_wide_2();
     48         assertEquals(123.0, t.run());
     49     }
     50 
     51     /**
     52      * @title access protected field from subclass
     53      */
     54     public void testN3() {
     55         //@uses dot.junit.opcodes.iget_wide.d.T_iget_wide_1
     56         //@uses dot.junit.opcodes.iget_wide.d.T_iget_wide_11
     57         T_iget_wide_11 t = new T_iget_wide_11();
     58         assertEquals(10, t.run());
     59     }
     60 
     61     /**
     62      * @title expected NullPointerException
     63      */
     64     public void testE2() {
     65         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_9", NullPointerException.class);
     66     }
     67 
     68     /**
     69      * @constraint A11
     70      * @title constant pool index
     71      */
     72     public void testVFE1() {
     73         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_4", VerifyError.class);
     74     }
     75 
     76     /**
     77      * @constraint A23
     78      * @title number of registers
     79      */
     80     public void testVFE2() {
     81         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_3", VerifyError.class);
     82     }
     83 
     84     /**
     85      * @constraint B13
     86      * @title read long from integer field - only field with same name but
     87      * different type exists
     88      */
     89     public void testVFE3() {
     90         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_13", NoSuchFieldError.class);
     91     }
     92 
     93     /**
     94      * @constraint n/a
     95      * @title Attempt to read inaccessible field.
     96      */
     97     public void testVFE4() {
     98         //@uses dot.junit.opcodes.iget_wide.TestStubs
     99         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_6", IllegalAccessError.class);
    100     }
    101 
    102     /**
    103      * @constraint n/a
    104      * @title Attempt to read field of undefined class.
    105      */
    106     public void testVFE5() {
    107         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_7", NoClassDefFoundError.class);
    108     }
    109 
    110     /**
    111      * @constraint n/a
    112      * @title Attempt to read undefined field.
    113      */
    114     public void testVFE6() {
    115         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_8", NoSuchFieldError.class);
    116     }
    117 
    118     /**
    119      * @constraint n/a
    120      * @title Attempt to read superclass' private field from subclass.
    121      */
    122     public void testVFE7() {
    123         //@uses dot.junit.opcodes.iget_wide.d.T_iget_wide_1
    124         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_12", IllegalAccessError.class);
    125     }
    126 
    127     /**
    128      * @constraint B1
    129      * @title iget-wide shall not work for reference fields
    130      */
    131     public void testVFE8() {
    132         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_14", VerifyError.class);
    133     }
    134 
    135     /**
    136      * @constraint B1
    137      * @title iget-wide shall not work for short fields
    138      */
    139     public void testVFE9() {
    140         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_15", VerifyError.class);
    141     }
    142 
    143     /**
    144      * @constraint B1
    145      * @title iget-wide shall not work for boolean fields
    146      */
    147     public void testVFE10() {
    148         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_16", VerifyError.class);
    149     }
    150 
    151     /**
    152      * @constraint B1
    153      * @title iget-wide shall not work for char fields
    154      */
    155     public void testVFE11() {
    156         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_17", VerifyError.class);
    157     }
    158 
    159     /**
    160      * @constraint B1
    161      * @title iget-wide shall not work for byte fields
    162      */
    163     public void testVFE12() {
    164         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_18", VerifyError.class);
    165     }
    166 
    167     /**
    168      * @constraint B1
    169      * @title iget-wide shall not work for float fields
    170      */
    171     public void testVFE13() {
    172         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_19", VerifyError.class);
    173     }
    174 
    175     /**
    176      * @constraint B1
    177      * @title iget-wide shall not work for int fields
    178      */
    179     public void testVFE14() {
    180         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_20", VerifyError.class);
    181     }
    182 
    183     /**
    184      * @constraint B12
    185      * @title Attempt to read inaccessible protected field.
    186      */
    187     public void testVFE15() {
    188         //@uses dot.junit.opcodes.iget_wide.TestStubs
    189         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_21", IllegalAccessError.class);
    190     }
    191 
    192     /**
    193      * @constraint A11
    194      * @title Attempt to read static  field.
    195      */
    196     public void testVFE16() {
    197         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_5",
    198                    IncompatibleClassChangeError.class);
    199     }
    200 
    201     /**
    202      * @constraint B6
    203      * @title instance fields may only be accessed on already initialized instances.
    204      */
    205     public void testVFE30() {
    206         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_30", VerifyError.class);
    207     }
    208 
    209     /**
    210      * @constraint N/A
    211      * @title instance fields may only be accessed on already initialized instances.
    212      */
    213     public void testVFE31() {
    214         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_31", VerifyError.class);
    215     }
    216 
    217     /**
    218      * @constraint N/A
    219      * @title Attempt to read inaccessible protected field on uninitialized reference.
    220      */
    221     public void testVFE35() {
    222         //@uses dot.junit.opcodes.iget_wide.TestStubs
    223         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_35", VerifyError.class);
    224     }
    225 }
    226