Home | History | Annotate | Download | only in shl_int
      1 package dot.junit.opcodes.shl_int;
      2 
      3 import dot.junit.DxTestCase;
      4 import dot.junit.DxUtil;
      5 import dot.junit.opcodes.shl_int.d.T_shl_int_1;
      6 import dot.junit.opcodes.shl_int.d.T_shl_int_6;
      7 
      8 public class Test_shl_int extends DxTestCase {
      9 
     10     /**
     11      * @title 15 << 1
     12      */
     13     public void testN1() {
     14         T_shl_int_1 t = new T_shl_int_1();
     15         assertEquals(30, t.run(15, 1));
     16     }
     17 
     18     /**
     19      * @title 33 << 2
     20      */
     21     public void testN2() {
     22         T_shl_int_1 t = new T_shl_int_1();
     23         assertEquals(132, t.run(33, 2));
     24     }
     25 
     26     /**
     27      * @title -15 << 1
     28      */
     29     public void testN3() {
     30         T_shl_int_1 t = new T_shl_int_1();
     31         assertEquals(-30, t.run(-15, 1));
     32     }
     33 
     34     /**
     35      * @title Arguments = 1 & -1
     36      */
     37     public void testN4() {
     38         T_shl_int_1 t = new T_shl_int_1();
     39         assertEquals(0x80000000, t.run(1, -1));
     40     }
     41 
     42     /**
     43      * @title Verify that shift distance is actually in range 0 to 32.
     44      */
     45     public void testN5() {
     46         T_shl_int_1 t = new T_shl_int_1();
     47         assertEquals(66, t.run(33, 33));
     48     }
     49 
     50 
     51     /**
     52      * @title Arguments = 0 & -1
     53      */
     54     public void testB1() {
     55         T_shl_int_1 t = new T_shl_int_1();
     56         assertEquals(0, t.run(0, -1));
     57     }
     58 
     59     /**
     60      * @title Arguments = Integer.MAX_VALUE & 1
     61      */
     62     public void testB2() {
     63         T_shl_int_1 t = new T_shl_int_1();
     64         assertEquals(0xfffffffe, t.run(Integer.MAX_VALUE, 1));
     65     }
     66 
     67     /**
     68      * @title Arguments = Integer.MIN_VALUE & 1
     69      */
     70     public void testB3() {
     71         T_shl_int_1 t = new T_shl_int_1();
     72         assertEquals(0, t.run(Integer.MIN_VALUE, 1));
     73     }
     74 
     75     /**
     76      * @title Arguments = 1 & 0
     77      */
     78     public void testB4() {
     79         T_shl_int_1 t = new T_shl_int_1();
     80         assertEquals(1, t.run(1, 0));
     81     }
     82 
     83     /**
     84      * @constraint A23
     85      * @title number of registers
     86      */
     87     public void testVFE1() {
     88         try {
     89             Class.forName("dot.junit.opcodes.shl_int.d.T_shl_int_2");
     90             fail("expected a verification exception");
     91         } catch (Throwable t) {
     92             DxUtil.checkVerifyException(t);
     93         }
     94     }
     95 
     96 
     97 
     98     /**
     99      * @constraint B1
    100      * @title types of arguments - double & int
    101      */
    102     public void testVFE2() {
    103         try {
    104             Class.forName("dot.junit.opcodes.shl_int.d.T_shl_int_3");
    105             fail("expected a verification exception");
    106         } catch (Throwable t) {
    107             DxUtil.checkVerifyException(t);
    108         }
    109     }
    110 
    111     /**
    112      * @constraint B1
    113      * @title types of arguments - long & int
    114      */
    115     public void testVFE3() {
    116         try {
    117             Class.forName("dot.junit.opcodes.shl_int.d.T_shl_int_4");
    118             fail("expected a verification exception");
    119         } catch (Throwable t) {
    120             DxUtil.checkVerifyException(t);
    121         }
    122     }
    123 
    124     /**
    125      * @constraint B1
    126      * @title types of arguments - reference & int
    127      */
    128     public void testVFE4() {
    129         try {
    130             Class.forName("dot.junit.opcodes.shl_int.d.T_shl_int_5");
    131             fail("expected a verification exception");
    132         } catch (Throwable t) {
    133             DxUtil.checkVerifyException(t);
    134         }
    135     }
    136 
    137     /**
    138      * @constraint B1
    139      * @title Types of arguments - float, float. The verifier checks that ints
    140      * and floats are not used interchangeably.
    141      */
    142     public void testVFE5() {
    143         try {
    144             Class.forName("dot.junit.opcodes.shl_int.d.T_shl_int_6");
    145             fail("expected a verification exception");
    146         } catch (Throwable t) {
    147             DxUtil.checkVerifyException(t);
    148         }
    149     }
    150 
    151 }
    152