Home | History | Annotate | Download | only in sput_byte
      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.sput_byte;
     18 
     19 import dot.junit.DxTestCase;
     20 import dot.junit.DxUtil;
     21 import dot.junit.opcodes.sput_byte.d.T_sput_byte_1;
     22 import dot.junit.opcodes.sput_byte.d.T_sput_byte_10;
     23 import dot.junit.opcodes.sput_byte.d.T_sput_byte_11;
     24 import dot.junit.opcodes.sput_byte.d.T_sput_byte_12;
     25 import dot.junit.opcodes.sput_byte.d.T_sput_byte_13;
     26 import dot.junit.opcodes.sput_byte.d.T_sput_byte_14;
     27 import dot.junit.opcodes.sput_byte.d.T_sput_byte_15;
     28 import dot.junit.opcodes.sput_byte.d.T_sput_byte_17;
     29 import dot.junit.opcodes.sput_byte.d.T_sput_byte_7;
     30 import dot.junit.opcodes.sput_byte.d.T_sput_byte_8;
     31 import dot.junit.opcodes.sput_byte.d.T_sput_byte_9;
     32 
     33 public class Test_sput_byte extends DxTestCase {
     34     /**
     35      * @title put byte into static field
     36      */
     37     public void testN1() {
     38         T_sput_byte_1 t = new T_sput_byte_1();
     39         assertEquals(0, T_sput_byte_1.st_i1);
     40         t.run();
     41         assertEquals(77, T_sput_byte_1.st_i1);
     42     }
     43 
     44 
     45     /**
     46      * @title modification of final field
     47      */
     48     public void testN2() {
     49         T_sput_byte_12 t = new T_sput_byte_12();
     50         assertEquals(0, T_sput_byte_12.st_i1);
     51         t.run();
     52         assertEquals(77, T_sput_byte_12.st_i1);
     53     }
     54 
     55     /**
     56      * @title modification of protected field from subclass
     57      */
     58     public void testN4() {
     59         //@uses dot.junit.opcodes.sput_byte.d.T_sput_byte_1
     60         //@uses dot.junit.opcodes.sput_byte.d.T_sput_byte_14
     61         T_sput_byte_14 t = new T_sput_byte_14();
     62         assertEquals(0, T_sput_byte_14.getProtectedField());
     63         t.run();
     64         assertEquals(77, T_sput_byte_14.getProtectedField());
     65     }
     66 
     67 
     68     /**
     69      * @title initialization of referenced class throws exception
     70      */
     71     public void testE6() {
     72         loadAndRun("dot.junit.opcodes.sput_byte.d.T_sput_byte_13",
     73                    ExceptionInInitializerError.class);
     74     }
     75 
     76     /**
     77      * @constraint A12
     78      * @title constant pool index
     79      */
     80     public void testVFE1() {
     81         load("dot.junit.opcodes.sput_byte.d.T_sput_byte_3", VerifyError.class);
     82     }
     83 
     84     /**
     85      *
     86      * @constraint A23
     87      * @title number of registers
     88      */
     89     public void testVFE2() {
     90         load("dot.junit.opcodes.sput_byte.d.T_sput_byte_4", VerifyError.class);
     91     }
     92 
     93 
     94     /**
     95      *
     96      * @constraint B13
     97      * @title put byte into long field - only field with same name but
     98      * different type exists
     99      */
    100     public void testVFE5() {
    101         loadAndRun("dot.junit.opcodes.sput_byte.d.T_sput_byte_17", NoSuchFieldError.class);
    102     }
    103 
    104     /**
    105      *
    106      * @constraint B13
    107      * @title type of field doesn't match opcode - attempt to modify double
    108      * field with single-width register
    109      */
    110     public void testVFE7() {
    111         load("dot.junit.opcodes.sput_byte.d.T_sput_byte_18", VerifyError.class);
    112     }
    113 
    114     /**
    115      *
    116      * @constraint A12
    117      * @title Attempt to set non-static field.
    118      */
    119     public void testVFE8() {
    120         loadAndRun("dot.junit.opcodes.sput_byte.d.T_sput_byte_7",
    121                    IncompatibleClassChangeError.class);
    122     }
    123 
    124     /**
    125      * @constraint n/a
    126      * @title Attempt to modify inaccessible field.
    127      */
    128     public void testVFE9() {
    129         //@uses dot.junit.opcodes.sput_byte.TestStubs
    130         loadAndRun("dot.junit.opcodes.sput_byte.d.T_sput_byte_8", IllegalAccessError.class);
    131     }
    132 
    133     /**
    134      * @constraint n/a
    135      * @title Attempt to modify field of undefined class.
    136      */
    137     public void testVFE10() {
    138         loadAndRun("dot.junit.opcodes.sput_byte.d.T_sput_byte_9", NoClassDefFoundError.class);
    139     }
    140 
    141     /**
    142      * @constraint n/a
    143      * @title Attempt to modify undefined field.
    144      */
    145     public void testVFE11() {
    146         loadAndRun("dot.junit.opcodes.sput_byte.d.T_sput_byte_10", NoSuchFieldError.class);
    147     }
    148 
    149 
    150 
    151     /**
    152      * @constraint n/a
    153      * @title Attempt to modify superclass' private field from subclass.
    154      */
    155     public void testVFE12() {
    156         //@uses dot.junit.opcodes.sput_byte.d.T_sput_byte_1
    157         loadAndRun("dot.junit.opcodes.sput_byte.d.T_sput_byte_15", IllegalAccessError.class);
    158     }
    159 
    160 
    161     /**
    162      * @constraint B1
    163      * @title sput-byte shall not work for wide numbers
    164      */
    165     public void testVFE13() {
    166         load("dot.junit.opcodes.sput_byte.d.T_sput_byte_2", VerifyError.class);
    167     }
    168 
    169     /**
    170      *
    171      * @constraint B1
    172      * @title sput-byte shall not work for reference fields
    173      */
    174     public void testVFE14() {
    175         load("dot.junit.opcodes.sput_byte.d.T_sput_byte_20", VerifyError.class);
    176     }
    177 
    178     /**
    179      *
    180      * @constraint B1
    181      * @title sput-byte shall not work for short fields
    182      */
    183     public void testVFE15() {
    184         load("dot.junit.opcodes.sput_byte.d.T_sput_byte_21", VerifyError.class);
    185     }
    186 
    187     /**
    188      *
    189      * @constraint B1
    190      * @title sput-byte shall not work for int fields
    191      */
    192     public void testVFE16() {
    193         load("dot.junit.opcodes.sput_byte.d.T_sput_byte_22", VerifyError.class);
    194     }
    195 
    196     /**
    197      *
    198      * @constraint B1
    199      * @title sput-byte shall not work for char fields
    200      */
    201     public void testVFE17() {
    202         load("dot.junit.opcodes.sput_byte.d.T_sput_byte_23", VerifyError.class);
    203     }
    204 
    205     /**
    206      * @constraint B1
    207      * @title sput-byte shall not work for boolean fields
    208      */
    209     public void testVFE18() {
    210         load("dot.junit.opcodes.sput_byte.d.T_sput_byte_24", VerifyError.class);
    211     }
    212 
    213     /**
    214      * @constraint n/a
    215      * @title Modification of final field in other class
    216      */
    217     public void testVFE19() {
    218         //@uses dot.junit.opcodes.sput_byte.TestStubs
    219         loadAndRun("dot.junit.opcodes.sput_byte.d.T_sput_byte_11", IllegalAccessError.class);
    220     }
    221 
    222 }
    223