• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package dot.junit.opcodes.shl_int_lit8;
2 
3 import dot.junit.DxTestCase;
4 import dot.junit.DxUtil;
5 import dot.junit.opcodes.shl_int_lit8.d.T_shl_int_lit8_1;
6 import dot.junit.opcodes.shl_int_lit8.d.T_shl_int_lit8_2;
7 import dot.junit.opcodes.shl_int_lit8.d.T_shl_int_lit8_3;
8 import dot.junit.opcodes.shl_int_lit8.d.T_shl_int_lit8_4;
9 import dot.junit.opcodes.shl_int_lit8.d.T_shl_int_lit8_5;
10 import dot.junit.opcodes.shl_int_lit8.d.T_shl_int_lit8_6;
11 
12 public class Test_shl_int_lit8 extends DxTestCase {
13 
14     /**
15      * @title 15 << 1
16      */
testN1()17     public void testN1() {
18         T_shl_int_lit8_1 t = new T_shl_int_lit8_1();
19         assertEquals(30, t.run(15));
20     }
21 
22     /**
23      * @title 33 << 2
24      */
testN2()25     public void testN2() {
26         T_shl_int_lit8_2 t = new T_shl_int_lit8_2();
27         assertEquals(132, t.run(33));
28     }
29 
30     /**
31      * @title -15 << 1
32      */
testN3()33     public void testN3() {
34         T_shl_int_lit8_1 t = new T_shl_int_lit8_1();
35         assertEquals(-30, t.run(-15));
36     }
37 
38     /**
39      * @title Arguments = 1 & -1
40      */
testN4()41     public void testN4() {
42         T_shl_int_lit8_3 t = new T_shl_int_lit8_3();
43         assertEquals(0x80000000, t.run(1));
44     }
45 
46     /**
47      * @title Verify that shift distance is actually in range 0 to 32.
48      */
testN5()49     public void testN5() {
50         T_shl_int_lit8_4 t = new T_shl_int_lit8_4();
51         assertEquals(66, t.run(33));
52     }
53 
54     /**
55      * @title Types of arguments - float. Dalvik doens't distinguish 32-bits types internally,
56      * so this operation of float makes no sense but shall not crash the VM.
57      */
testN6()58     public void testN6() {
59         T_shl_int_lit8_6 t = new T_shl_int_lit8_6();
60         try {
61             t.run(3.14f);
62         } catch (Throwable e) {
63         }
64     }
65 
66 
67 
68     /**
69      * @title Arguments = 0 & -1
70      */
testB1()71     public void testB1() {
72         T_shl_int_lit8_3 t = new T_shl_int_lit8_3();
73         assertEquals(0, t.run(0));
74     }
75 
76     /**
77      * @title Arguments = Integer.MAX_VALUE & 1
78      */
testB2()79     public void testB2() {
80         T_shl_int_lit8_1 t = new T_shl_int_lit8_1();
81         assertEquals(0xfffffffe, t.run(Integer.MAX_VALUE));
82     }
83 
84     /**
85      * @title Arguments = Integer.MIN_VALUE & 1
86      */
testB3()87     public void testB3() {
88         T_shl_int_lit8_1 t = new T_shl_int_lit8_1();
89         assertEquals(0, t.run(Integer.MIN_VALUE));
90     }
91 
92     /**
93      * @title Arguments = 1 & 0
94      */
testB4()95     public void testB4() {
96         T_shl_int_lit8_5 t = new T_shl_int_lit8_5();
97         assertEquals(1, t.run(1));
98     }
99 
100     /**
101      * @constraint A23
102      * @title number of registers
103      */
testVFE1()104     public void testVFE1() {
105         try {
106             Class.forName("dot.junit.opcodes.shl_int_lit8.d.T_shl_int_lit8_7");
107             fail("expected a verification exception");
108         } catch (Throwable t) {
109             DxUtil.checkVerifyException(t);
110         }
111     }
112 
113 
114 
115     /**
116      * @constraint B1
117      * @title types of arguments - double & int
118      */
testVFE2()119     public void testVFE2() {
120         try {
121             Class.forName("dot.junit.opcodes.shl_int_lit8.d.T_shl_int_lit8_8");
122             fail("expected a verification exception");
123         } catch (Throwable t) {
124             DxUtil.checkVerifyException(t);
125         }
126     }
127 
128     /**
129      * @constraint B1
130      * @title types of arguments - long & int
131      */
testVFE3()132     public void testVFE3() {
133         try {
134             Class.forName("dot.junit.opcodes.shl_int_lit8.d.T_shl_int_lit8_9");
135             fail("expected a verification exception");
136         } catch (Throwable t) {
137             DxUtil.checkVerifyException(t);
138         }
139     }
140 
141     /**
142      * @constraint B1
143      * @title types of arguments - reference & int
144      */
testVFE4()145     public void testVFE4() {
146         try {
147             Class.forName("dot.junit.opcodes.shl_int_lit8.d.T_shl_int_lit8_10");
148             fail("expected a verification exception");
149         } catch (Throwable t) {
150             DxUtil.checkVerifyException(t);
151         }
152     }
153 }
154