summaryrefslogtreecommitdiffstats
path: root/jack-tests/tests/com/android/jack/box/test001
diff options
context:
space:
mode:
Diffstat (limited to 'jack-tests/tests/com/android/jack/box/test001')
-rw-r--r--jack-tests/tests/com/android/jack/box/test001/dx/Tests.java286
-rw-r--r--jack-tests/tests/com/android/jack/box/test001/jack/Box001.java338
2 files changed, 624 insertions, 0 deletions
diff --git a/jack-tests/tests/com/android/jack/box/test001/dx/Tests.java b/jack-tests/tests/com/android/jack/box/test001/dx/Tests.java
new file mode 100644
index 0000000..73edcd2
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/box/test001/dx/Tests.java
@@ -0,0 +1,286 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.jack.box.test001.dx;
+
+import com.android.jack.box.test001.jack.Box001;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Tests {
+
+ @Test
+ public void test1() {
+ Assert.assertEquals(Long.valueOf(15), Box001.get1(Long.valueOf(11), 4));
+ }
+
+ @Test
+ public void test2() {
+ Assert.assertEquals(Long.valueOf(15), Box001.get2(Long.valueOf(11), 4));
+ }
+
+ @Test
+ public void test3() {
+ Assert.assertTrue(Box001.get3(new Boolean(true), new Boolean(true)).booleanValue());
+ Assert.assertFalse(Box001.get3(new Boolean(true), new Boolean(false)).booleanValue());
+ }
+
+ @Test
+ public void test4() {
+ Assert.assertTrue(Box001.get4(new Boolean(true), new Boolean(true)).booleanValue());
+ Assert.assertFalse(Box001.get4(new Boolean(true), new Boolean(false)).booleanValue());
+ }
+
+ @Test
+ public void test5() {
+ Assert.assertTrue(Box001.get5(new Boolean(true)));
+ Assert.assertFalse(Box001.get5(new Boolean(false)));
+ }
+
+ @Test
+ public void test6() {
+ Assert.assertEquals(2L << 2, Box001.get6(new Long(2), 2).longValue());
+ }
+
+ @Test
+ public void test7() {
+ Assert.assertTrue(Box001.get7(new Boolean(true), new Boolean(true)).booleanValue());
+ Assert.assertFalse(Box001.get7(new Boolean(true), new Boolean(false)).booleanValue());
+ }
+
+ @Test
+ public void test8() {
+ Assert.assertTrue(Box001.get8());
+ }
+
+ @Test
+ public void test9() {
+ Assert.assertTrue(Box001.get9().booleanValue());
+ }
+
+ @Test
+ public void test10() {
+ Assert.assertTrue(Box001.get10());
+ }
+
+ @Test
+ public void test11() {
+ int[] a = new int[]{1,2,3};
+ Assert.assertEquals(1, Box001.get11(a).intValue());
+ }
+
+ @Test
+ public void test12() {
+ Integer[] a = new Integer[] {new Integer(1), new Integer(2), new Integer(3)};
+ Assert.assertEquals(1, Box001.get12(a));
+ }
+
+ @Test
+ public void test13() {
+ int[] a = new int[]{1,2,3};
+ Assert.assertEquals(3, Box001.get13(a, new Integer(2)));
+ }
+
+ @Test
+ public void test14() {
+ Assert.assertEquals(1, Box001.get14(new Integer(1), new Integer(2)).length);
+ Assert.assertEquals(2, Box001.get14(new Integer(1), new Integer(2))[0].length);
+ }
+
+ @Test
+ public void test15() {
+ Assert.assertEquals(3, Box001.get15(1,2.0f));
+ }
+
+ @Test
+ public void test16() {
+ Assert.assertEquals(3, Box001.get16(new Integer(1), new Float(2.0f)));
+ }
+
+ @Test
+ public void test17() {
+ Assert.assertEquals(-1, Box001.get17(new Integer(1)));
+ }
+
+ @Test
+ public void test18() {
+ Assert.assertEquals(1, Box001.get18(new Integer(2)));
+ }
+
+ @Test
+ public void test19() {
+ Assert.assertFalse(Box001.get19(new Boolean(true)));
+ }
+
+ @Test
+ public void test20() {
+ Assert.assertEquals(2, Box001.get20(new Integer(2)));
+ }
+
+ @Test
+ public void test21() {
+ short val = 2;
+ Assert.assertEquals(2, Box001.get21(new Short(val)));
+ }
+
+ @Test
+ public void test22() {
+ Assert.assertEquals(~16, Box001.get22(new Integer(16)));
+ }
+
+ @Test
+ public void test23() {
+ Assert.assertTrue(Box001.get23(new Integer(16)));
+ }
+
+ @Test
+ public void test24() {
+ Assert.assertTrue(Box001.get24(new Boolean(true)));
+ Assert.assertFalse(Box001.get24(new Boolean(false)));
+ }
+
+ @Test
+ public void test25() {
+ Assert.assertTrue(Box001.get25(new Boolean(true)));
+ Assert.assertFalse(Box001.get25(new Boolean(false)));
+ }
+
+ @Test
+ public void test26() {
+ Assert.assertEquals(16, ((Integer)Box001.get26(16l)).intValue());
+ }
+
+ @Test
+ public void test27() {
+ Assert.assertEquals(16, Box001.get27(new Integer(16)));
+ }
+
+ @Test
+ public void test28() {
+ Assert.assertEquals("2", Box001.get28(new short[]{1,2,3}, true));
+ }
+
+ @Test
+ public void test29() {
+ Assert.assertEquals("1,true", Box001.get29(1,true));
+ }
+
+ @Test
+ public void test30() {
+ Assert.assertEquals(1, Box001.get30()[0].intValue());
+ Assert.assertEquals(2, Box001.get30()[1].intValue());
+ }
+
+ @Test
+ public void test31() {
+ Assert.assertEquals(1, Box001.get31()[0]);
+ Assert.assertEquals(2, Box001.get31()[1]);
+ }
+
+ @Test
+ public void test32() {
+ Assert.assertEquals(1, Box001.get32(new Integer(1)));
+ Assert.assertEquals(2, Box001.get32(new Integer(2)));
+ }
+
+ @Test
+ public void test33() {
+ Assert.assertEquals(1, Box001.get33(new Integer(1)));
+ Assert.assertEquals(0, Box001.get33(new Integer(2)));
+ }
+
+ @Test
+ public void test34() {
+ Assert.assertEquals(1, Box001.get34(new Boolean(true)));
+ Assert.assertEquals(0, Box001.get34(new Boolean(false)));
+ }
+
+ @Test
+ public void test35() {
+ Assert.assertEquals(1, Box001.get35(new Boolean(true)));
+ Assert.assertEquals(0, Box001.get35(new Boolean(false)));
+ }
+
+ @Test
+ public void test36() {
+ Assert.assertEquals(1, Box001.get36(new Boolean(true)));
+ Assert.assertEquals(0, Box001.get36(new Boolean(false)));
+ }
+
+ @Test
+ public void test37() {
+ Assert.assertEquals(2, Box001.get37(new Boolean(true)));
+ Assert.assertEquals(1, Box001.get37(new Boolean(false)));
+ }
+
+ @Test
+ public void test38() {
+ Assert.assertEquals(2, Box001.get38(new Boolean(true)));
+ Assert.assertEquals(0, Box001.get38(new Boolean(false)));
+ }
+
+ @Test
+ public void test39() {
+ Assert.assertFalse(Box001.get39("ab"));
+ }
+
+ @Test
+ public void test41() {
+ Assert.assertEquals(16 + 16, Box001.get41(new Integer(16), new Integer(16)));
+ }
+
+ @Test
+ public void test42() {
+ Assert.assertTrue(Box001.get42(new Double(0.5), new Double(0.5)) == (0.5 + 0.5));
+ }
+
+ @Test
+ public void test43() {
+ Assert.assertEquals(1, Box001.get43());
+ }
+
+ @Test
+ public void test44() {
+ Assert.assertEquals(10, Box001.get44());
+ }
+
+ @Test
+ public void test45() {
+ Assert.assertEquals(2 & 4, Box001.get45(new Integer(2), new Integer(4)).intValue());
+ }
+
+ @Test
+ public void test46() {
+ Assert.assertEquals(1, Box001.get46(true, new Boolean(true)));
+ Assert.assertEquals(0, Box001.get46(false, new Boolean(true)));
+ }
+
+ @Test
+ public void test47() {
+ Assert.assertEquals(2, Box001.get47(1));
+ }
+
+ @Test
+ public void test48() {
+ try {
+ Box001.get48();
+ Assert.fail();
+ } catch (NullPointerException e) {
+ // expected
+ }
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/box/test001/jack/Box001.java b/jack-tests/tests/com/android/jack/box/test001/jack/Box001.java
new file mode 100644
index 0000000..4693ce3
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/box/test001/jack/Box001.java
@@ -0,0 +1,338 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.jack.box.test001.jack;
+
+public class Box001 {
+
+ @SuppressWarnings("boxing")
+ public static Long get1(Long initial, int inc) {
+ initial += inc;
+ return initial;
+ }
+
+ @SuppressWarnings("boxing")
+ public static Long get2(Long initial, int inc) {
+ initial = inc + initial;
+ return initial;
+ }
+
+ @SuppressWarnings("boxing")
+ public static Boolean get3(Boolean b1, Boolean b2) {
+ Boolean b = null;
+ b = b1 & b2;
+ return b;
+ }
+
+ @SuppressWarnings("boxing")
+ public static Boolean get4(Boolean b1, Boolean b2) {
+ Boolean b = null;
+ b = b1 && b2;
+ return b;
+ }
+
+ @SuppressWarnings("boxing")
+ public static boolean get5(Boolean b1) {
+ boolean b;
+ b = b1;
+ return b;
+ }
+
+ @SuppressWarnings("boxing")
+ public static Long get6(Long initial, int inc) {
+ initial = initial << inc;
+ return initial;
+ }
+
+ @SuppressWarnings("boxing")
+ public static Boolean get7(Boolean b1, Boolean b2) {
+ Boolean b = b1 && b2;
+ return b;
+ }
+
+ @SuppressWarnings("boxing")
+ public static boolean get8() {
+ boolean b = new Boolean(true);
+ return b;
+ }
+
+ @SuppressWarnings("boxing")
+ public static Boolean get9() {
+ return true;
+ }
+
+ @SuppressWarnings("boxing")
+ public static boolean get10() {
+ return new Boolean(true);
+ }
+
+ @SuppressWarnings("boxing")
+ public static Integer get11(int[] a) {
+ return a[0];
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get12(Integer[] a) {
+ return a[0];
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get13(int[] a, Integer index) {
+ return a[index];
+ }
+
+ @SuppressWarnings("boxing")
+ public static int[][] get14(Integer size1, Integer size2) {
+ return new int[size1][size2];
+ }
+
+ @SuppressWarnings("boxing")
+ private static int getP0(Integer a, Float b, Boolean c) {
+ if (c) {
+ return a + b.intValue();
+ }
+ return 0;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get15(int a, float b) {
+ return Box001.getP0(a, b, true);
+ }
+
+ private static int getP1(int a, float b, boolean c) {
+ if (c) {
+ return a + (int) b;
+ }
+ return 0;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get16(Integer a, Float b) {
+ return Box001.getP1(a, b, new Boolean(true));
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get17(Integer a) {
+ return -a;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get18(Integer a) {
+ return --a;
+ }
+
+ @SuppressWarnings("boxing")
+ public static boolean get19(Boolean a) {
+ return !a;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get20(Integer a) {
+ int b = 0;
+ return b += a ;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get21(Short a) {
+ int b = 0;
+ return b += a ;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get22(Integer a) {
+ return ~a;
+ }
+
+ public static boolean get23(Integer a) {
+ return a != null;
+ }
+
+ @SuppressWarnings("boxing")
+ public static boolean get24(Boolean result) {
+ return result != null ? result : false;
+ }
+
+ @SuppressWarnings("boxing")
+ public static boolean get25(Boolean result) {
+ return result == null ? false : result;
+ }
+
+ @SuppressWarnings("boxing")
+ public static Object get26(long longValue) {
+ return (int) longValue;
+ }
+
+ @SuppressWarnings({"boxing", "cast"})
+ public static int get27(Integer longValue) {
+ return (int) longValue;
+ }
+
+ @SuppressWarnings("boxing")
+ public static String get28(short[] types, boolean value) {
+ StringBuilder result = new StringBuilder();
+ result.append(value ? "" : types[0]);
+ result.append(!value ? "" : types[1]);
+ return result.toString();
+ }
+
+ @SuppressWarnings("boxing")
+ public static String get29(int a, boolean b) {
+ return String.format("%d,%b", a, b);
+ }
+
+ @SuppressWarnings("boxing")
+ public static Integer[] get30() {
+ return new Integer[]{1, 2, 3};
+ }
+
+ @SuppressWarnings("boxing")
+ public static int[] get31() {
+ return new int[]{new Integer(1), new Integer(2), new Integer(3)};
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get32(Integer i) {
+ switch (i) {
+ case 1:
+ return 1;
+ case 2:
+ return 2;
+ default:
+ return 3;
+ }
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get33(Integer i) {
+ if (i == 1) {
+ return 1;
+ }
+ return 0;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get34(Boolean b) {
+ if (b) {
+ return 1;
+ }
+ return 0;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get35(Boolean b) {
+ return (b ? 1 : 0);
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get36(Boolean b) {
+ int result = 0;
+ while (b) {
+ result++;
+ break;
+ }
+ return result;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get37(Boolean b) {
+ int result = 0;
+ do {
+ if (result == 1) {
+ return 2;
+ }
+ result++;
+ } while (b);
+ return result;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get38(Boolean b) {
+ int result = 0;
+ for (int i =0; b; i++) {
+ if (result == 1) {
+ return 2;
+ }
+ result++;
+ }
+ return result;
+ }
+
+ public static boolean get39(String a) {
+ return "aa" == a;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get41(Integer a, Integer b) {
+ return a + b ;
+ }
+
+ @SuppressWarnings("boxing")
+ public static double get42(Double a, Double b) {
+ return a + b ;
+ }
+
+ public static final int NONE = 4;
+ @SuppressWarnings({"boxing", "unused"})
+ public static byte get43() {
+ byte val = 1;
+ Byte b = new Byte(val);
+ if (b == null) {
+ b = NONE;
+ }
+ return b;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int getValueFromObject(Object values) {
+ return (Integer)values;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get44() {
+ int i = 10;
+ return getValueFromObject(i == 10 ? i : "N/A");
+ }
+
+ @SuppressWarnings("boxing")
+ public static Integer get45(Integer i1, Integer i2) {
+ Integer i = null;
+ i = i1 & i2;
+ return i;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get46(boolean b1, Boolean b2) {
+ if (b1 == b2) {
+ return 1;
+ }
+ return 0;
+ }
+
+ public static int get47(int val) {
+ Integer val1 = new Integer(val);
+ Integer val2 = new Integer(val);
+ if (val1 == val2) {
+ return 1;
+ }
+ return 2;
+ }
+
+ @SuppressWarnings({"boxing", "null"})
+ public static int get48() {
+ Integer integer = null;
+ return integer;
+ }
+}