summaryrefslogtreecommitdiffstats
path: root/jack-tests/tests/com/android/jack/conditional
diff options
context:
space:
mode:
authorYohann Roussel <yroussel@google.com>2014-03-19 16:25:37 +0100
committerYohann Roussel <yroussel@google.com>2014-03-20 15:13:33 +0100
commit4eceb95409e844fdc33c9c706e1dc307bfd40303 (patch)
treeee9f4f3fc79f757c79081c336bce4f1782c6ccd8 /jack-tests/tests/com/android/jack/conditional
parent3d2402901b1a6462e2cf47a6fd09711f327961c3 (diff)
downloadtoolchain_jack-4eceb95409e844fdc33c9c706e1dc307bfd40303.zip
toolchain_jack-4eceb95409e844fdc33c9c706e1dc307bfd40303.tar.gz
toolchain_jack-4eceb95409e844fdc33c9c706e1dc307bfd40303.tar.bz2
Initial Jack import.
Change-Id: I953cf0a520195a7187d791b2885848ad0d5a9b43
Diffstat (limited to 'jack-tests/tests/com/android/jack/conditional')
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test001/dx/Tests.java49
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test001/jack/Conditional.java135
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test002/dx/Tests.java34
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test002/jack/C.java21
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test002/jack/C1.java21
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test002/jack/C2.java21
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test002/jack/Conditional2.java40
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test002/jack/I1.java21
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test002/jack/I2.java21
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test003/dx/Tests.java30
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test003/jack/Data.java24
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test004/dx/Tests.java47
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test004/jack/Conditional004.java30
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test005/dx/Tests.java61
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test005/jack/Conditional005.java61
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test006/dx/Tests.java40
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test006/jack/ConditionalTest006.java34
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test007/dx/Tests.java64
-rw-r--r--jack-tests/tests/com/android/jack/conditional/test007/jack/ConditionalTest007.java99
19 files changed, 853 insertions, 0 deletions
diff --git a/jack-tests/tests/com/android/jack/conditional/test001/dx/Tests.java b/jack-tests/tests/com/android/jack/conditional/test001/dx/Tests.java
new file mode 100644
index 0000000..db9b9da
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test001/dx/Tests.java
@@ -0,0 +1,49 @@
+/*
+ * 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.conditional.test001.dx;
+
+import com.android.jack.conditional.test001.jack.Conditional;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class Tests {
+
+ @Test
+ public void test1() {
+ Assert.assertEquals(1, Conditional.test_conditionalCode001(15));
+ Assert.assertEquals(-1, Conditional.test_conditionalCode001(-15));
+ Assert.assertEquals(15, Conditional.test_conditionalCode002(15, -15));
+ Assert.assertEquals(1, Conditional.test_conditionalCode003(15, -15));
+ Assert.assertEquals(-1, Conditional.test_conditionalCode004(1, 2, 3, 3, 5, 8, 6));
+ Assert.assertEquals(1, Conditional.test_conditionalCode005(15, -15));
+ Assert.assertEquals(1, Conditional.test_conditionalCode006(true));
+ Assert.assertEquals(-1, Conditional.test_conditionalCode006(false));
+
+ Assert.assertEquals(4, Conditional.test_conditionalCode007(false));
+ Assert.assertEquals(5, Conditional.test_conditionalCode008(false));
+ Assert.assertEquals(5, Conditional.test_conditionalCode009(false));
+ Assert.assertEquals(3, Conditional.test_conditionalCode010(false));
+ Assert.assertEquals(4, Conditional.test_conditionalCode011(false));
+ Assert.assertEquals(1, Conditional.test_conditionalCode012(false));
+ Assert.assertEquals(2, Conditional.test_conditionalCode013(false));
+ Assert.assertEquals(4, Conditional.test_conditionalCode014(false));
+ Assert.assertEquals(3, Conditional.test_conditionalCode015(false));
+ Assert.assertEquals(4, Conditional.test_conditionalCode016(false));
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test001/jack/Conditional.java b/jack-tests/tests/com/android/jack/conditional/test001/jack/Conditional.java
new file mode 100644
index 0000000..c0912d0
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test001/jack/Conditional.java
@@ -0,0 +1,135 @@
+/*
+ * 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.conditional.test001.jack;
+
+public class Conditional {
+
+ public static int test_conditionalCode001(int a) {
+ int b = (a > 0) ? 1 : -1;
+ return b;
+ }
+
+ public static int test_conditionalCode002(int a, int b) {
+ int c = (a > 0) ? ((b > a) ? b : a) : -1;
+ return c;
+ }
+
+ public static int test_conditionalCode003(int a, int b) {
+ int c;
+ if (((a > 0) ? ((b > a) ? b : a) : -1) > 0) {
+ c = 1;
+ } else {
+ c = 3;
+ }
+ return c;
+ }
+
+ public static int test_conditionalCode004(int a, int b, int c, int d, int e, int f, int g) {
+ int i =
+ ((c > d) ? (e == f) : (g == a)) ? ((((b == f) ? e : g) > a) ? ((a < c) ? b : g) : a) : -1;
+ return i;
+ }
+
+ public static int test_conditionalCode005(int a, int b) {
+ int x = (a < b) ? (1) : (getValue((b > 0) ? 2 : 3 ));
+ return x;
+ }
+
+ public static int test_conditionalCode006(boolean a) {
+ int b;
+ b = a ? 1 : -1;
+ return b;
+ }
+
+
+ public static int test_conditionalCode007(boolean a) {
+ byte b = 1;
+ char c = 2;
+ return m(a ? b : c);
+ }
+
+ public static int test_conditionalCode008(boolean a) {
+ byte b = 1;
+ return m(a ? b : null);
+ }
+
+ public static int test_conditionalCode009(boolean a) {
+ byte b = 1;
+ return m(a ? null : b);
+ }
+
+ public static int test_conditionalCode010(boolean a) {
+ byte b = 1;
+ short c = 1;
+ return m(a ? c : b);
+ }
+
+ public static int test_conditionalCode011(boolean a) {
+ byte b = 1;
+ return m(a ? 256 : b);
+ }
+
+ public static int test_conditionalCode012(boolean a) {
+ byte b = 1;
+ return m(a ? 12 : b);
+ }
+
+ public static int test_conditionalCode013(boolean a) {
+ char b = 1;
+ return m(a ? 12 : b);
+ }
+
+ public static int test_conditionalCode014(boolean a) {
+ char b = 1;
+ return m(a ? -1 : b);
+ }
+
+ public static int test_conditionalCode015(boolean a) {
+ short b = 1;
+ return m(a ? -1 : b);
+ }
+
+ public static int test_conditionalCode016(boolean a) {
+ short b = 1;
+ return m(a ? 1234567890 : b);
+ }
+
+ public static int m(byte a) {
+ return 1;
+ }
+
+ public static int m(char a) {
+ return 2;
+ }
+
+ public static int m(short a) {
+ return 3;
+ }
+
+ public static int m(int a) {
+ return 4;
+ }
+
+ public static int m(Object a) {
+ return 5;
+ }
+
+ public static int getValue(int c) {
+ return 1;
+ }
+
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test002/dx/Tests.java b/jack-tests/tests/com/android/jack/conditional/test002/dx/Tests.java
new file mode 100644
index 0000000..b5d41cd
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test002/dx/Tests.java
@@ -0,0 +1,34 @@
+/*
+ * 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.conditional.test002.dx;
+
+import com.android.jack.conditional.test002.jack.Conditional2;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class Tests {
+
+ @Test
+ public void test1() {
+ Assert.assertEquals(1, Conditional2.test1(true));
+ Assert.assertEquals(2, Conditional2.test1(false));
+ Assert.assertEquals(2, Conditional2.test2(true));
+ Assert.assertEquals(0, Conditional2.test2(false));
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test002/jack/C.java b/jack-tests/tests/com/android/jack/conditional/test002/jack/C.java
new file mode 100644
index 0000000..2046e82
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test002/jack/C.java
@@ -0,0 +1,21 @@
+/*
+ * 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.conditional.test002.jack;
+
+public class C {
+
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test002/jack/C1.java b/jack-tests/tests/com/android/jack/conditional/test002/jack/C1.java
new file mode 100644
index 0000000..0829440
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test002/jack/C1.java
@@ -0,0 +1,21 @@
+/*
+ * 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.conditional.test002.jack;
+
+public class C1 extends C implements I1, I2 {
+
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test002/jack/C2.java b/jack-tests/tests/com/android/jack/conditional/test002/jack/C2.java
new file mode 100644
index 0000000..3f60f16
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test002/jack/C2.java
@@ -0,0 +1,21 @@
+/*
+ * 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.conditional.test002.jack;
+
+public class C2 extends C implements I1, I2 {
+
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test002/jack/Conditional2.java b/jack-tests/tests/com/android/jack/conditional/test002/jack/Conditional2.java
new file mode 100644
index 0000000..72e800b
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test002/jack/Conditional2.java
@@ -0,0 +1,40 @@
+/*
+ * 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.conditional.test002.jack;
+
+public class Conditional2 {
+ public static int test1(boolean cond) {
+ return m(cond ? new C1() : new C2());
+ }
+
+ private static int m(I1 i1) {
+ if (i1 instanceof C2) {
+ return 2;
+ } else if (i1 instanceof C1) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ public static int test2(boolean cond) {
+ return m2(cond ? new C1[2] : new C[0]);
+ }
+
+ private static int m2(C[] cs) {
+ return cs.length;
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test002/jack/I1.java b/jack-tests/tests/com/android/jack/conditional/test002/jack/I1.java
new file mode 100644
index 0000000..4d63321
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test002/jack/I1.java
@@ -0,0 +1,21 @@
+/*
+ * 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.conditional.test002.jack;
+
+public interface I1 {
+
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test002/jack/I2.java b/jack-tests/tests/com/android/jack/conditional/test002/jack/I2.java
new file mode 100644
index 0000000..2a357f4
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test002/jack/I2.java
@@ -0,0 +1,21 @@
+/*
+ * 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.conditional.test002.jack;
+
+public interface I2 {
+
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test003/dx/Tests.java b/jack-tests/tests/com/android/jack/conditional/test003/dx/Tests.java
new file mode 100644
index 0000000..81c79bc
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test003/dx/Tests.java
@@ -0,0 +1,30 @@
+/*
+ * 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.conditional.test003.dx;
+
+import com.android.jack.conditional.test003.jack.Data;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Tests {
+
+ @Test
+ public void test1() {
+ Assert.assertEquals("null", Data.m());
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test003/jack/Data.java b/jack-tests/tests/com/android/jack/conditional/test003/jack/Data.java
new file mode 100644
index 0000000..48d9ada
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test003/jack/Data.java
@@ -0,0 +1,24 @@
+/*
+ * 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.conditional.test003.jack;
+
+public class Data {
+ public static String m() {
+ String s = "" + (true ? null : null);
+ return s;
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test004/dx/Tests.java b/jack-tests/tests/com/android/jack/conditional/test004/dx/Tests.java
new file mode 100644
index 0000000..9307a30
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test004/dx/Tests.java
@@ -0,0 +1,47 @@
+/*
+ * 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.conditional.test004.dx;
+
+import com.android.jack.conditional.test004.jack.Conditional004;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Tests {
+
+ @Test
+ public void test1() {
+ Assert.assertEquals(2, Conditional004.get(false));
+ try {
+ Conditional004.get(true);
+ Assert.fail();
+ } catch (NullPointerException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void test2() {
+ Assert.assertEquals(2, Conditional004.get2(true));
+ try {
+ Conditional004.get2(false);
+ Assert.fail();
+ } catch (NullPointerException e) {
+ // expected
+ }
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test004/jack/Conditional004.java b/jack-tests/tests/com/android/jack/conditional/test004/jack/Conditional004.java
new file mode 100644
index 0000000..e93eb2c
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test004/jack/Conditional004.java
@@ -0,0 +1,30 @@
+/*
+ * 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.conditional.test004.jack;
+
+public class Conditional004 {
+
+ @SuppressWarnings("boxing")
+ public static int get(boolean cond) {
+ return cond ? null : 2;
+ }
+
+ @SuppressWarnings("boxing")
+ public static int get2(boolean cond) {
+ return cond ? 2 : null;
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test005/dx/Tests.java b/jack-tests/tests/com/android/jack/conditional/test005/dx/Tests.java
new file mode 100644
index 0000000..662f250
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test005/dx/Tests.java
@@ -0,0 +1,61 @@
+/*
+ * 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.conditional.test005.dx;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.android.jack.conditional.test005.jack.Conditional005;
+import com.android.jack.conditional.test005.jack.Conditional005.A;
+
+public class Tests {
+
+ @Test
+ public void test001() {
+ A[] i = new A[]{new A()};
+ Assert.assertEquals(1, Conditional005.test001(i));
+ Assert.assertEquals(-1, Conditional005.test001(null));
+ }
+
+ @Test
+ public void test002() {
+ A[][] i = new A[][]{{new A(), new A()}};
+ Assert.assertEquals(1, Conditional005.test002(i));
+ Assert.assertEquals(-1, Conditional005.test002(null));
+ }
+
+ @Test
+ public void test003() {
+ A[] i = new A[]{};
+ Assert.assertEquals(0, Conditional005.test003(i));
+ Assert.assertEquals(1, Conditional005.test003(null));
+ }
+
+ @Test
+ public void test004() {
+ int[] i = new int[]{2};
+ Assert.assertEquals(3, Conditional005.test004(i));
+ Assert.assertEquals(2, Conditional005.test004(null));
+ }
+
+ @Test
+ public void test005() {
+ int[] i = new int[]{2};
+ Assert.assertEquals(i, Conditional005.test005(i));
+ Assert.assertNotNull(Conditional005.test005(null));
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test005/jack/Conditional005.java b/jack-tests/tests/com/android/jack/conditional/test005/jack/Conditional005.java
new file mode 100644
index 0000000..01d47d3
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test005/jack/Conditional005.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 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.conditional.test005.jack;
+
+public class Conditional005 {
+
+ public static class A {
+ protected int i = 1;
+ }
+
+ public static class B extends A{
+ public B() {
+ super();
+ i = -1;
+ }
+ }
+
+ // Check that type of '?' expression is an array
+ public static int test001(A[] ai) {
+ B[] ai1 = new B[]{new B()};
+ return (ai == null ? ai1 : ai)[0].i;
+ }
+
+ // Check that type of '?' expression is an array
+ public static int test002(A[][] ai) {
+ B[][] ai1 = new B[][]{{new B(), new B()}};
+ return (ai == null ? ai1 : ai)[0][0].i;
+ }
+
+ // Check that type of '?' expression is an array
+ public static int test003(A[] ai) {
+ B[][] ai1 = new B[][]{{new B(), new B()}};
+ return (ai == null ? ai1 : ai).length;
+ }
+
+ // Check that type of '?' expression is an array
+ public static int test004(int[] ai) {
+ int[] ai1 = new int[]{1};
+ return (ai == null ? ai1 : ai)[0] + 1;
+ }
+
+ // Check that type of '?' expression is an array
+ public static Object test005(int[] ai) {
+ byte[] ai1 = new byte[]{1};
+ return (ai == null ? ai1 : ai);
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test006/dx/Tests.java b/jack-tests/tests/com/android/jack/conditional/test006/dx/Tests.java
new file mode 100644
index 0000000..0717be1
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test006/dx/Tests.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013 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.conditional.test006.dx;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.android.jack.conditional.test006.jack.ConditionalTest006;
+
+public class Tests {
+
+ @Test
+ public void test001() {
+ Assert.assertEquals(null, ConditionalTest006.test001());
+ }
+
+ @Test
+ public void test002() {
+ try {
+ ConditionalTest006.test002();
+ Assert.fail("Npe expected");
+ } catch (NullPointerException npe) {
+ // OK
+ }
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test006/jack/ConditionalTest006.java b/jack-tests/tests/com/android/jack/conditional/test006/jack/ConditionalTest006.java
new file mode 100644
index 0000000..63d33e2
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test006/jack/ConditionalTest006.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2013 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.conditional.test006.jack;
+
+public class ConditionalTest006 {
+
+ // Check that null is assigned to f1
+ public static Float test001() {
+ @SuppressWarnings({"boxing", "unused"})
+ Float f1 = false? 1.0f: null;
+ return f1;
+ }
+
+ // Check that null pointer exception is trigger due to unboxing of null
+ public static Float test002() {
+ @SuppressWarnings({"boxing", "unused"})
+ Float f2 = false? 1.0f: false? 1.0f: null;
+ return f2;
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test007/dx/Tests.java b/jack-tests/tests/com/android/jack/conditional/test007/dx/Tests.java
new file mode 100644
index 0000000..f23b9a2
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test007/dx/Tests.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 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.conditional.test007.dx;
+
+import com.android.jack.conditional.test007.jack.ConditionalTest007;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Tests {
+
+ @Test
+ public void test001() {
+ Assert.assertEquals((short) 1, ConditionalTest007.test001(1, true));
+ Assert.assertEquals((short) 2, ConditionalTest007.test001(1, false));
+
+ Assert.assertEquals((short) 1, ConditionalTest007.test001(2, true));
+ Assert.assertEquals((short) 2, ConditionalTest007.test001(2, false));
+
+ Assert.assertEquals((short) 1, ConditionalTest007.test001(3, true));
+ Assert.assertEquals((short) 2, ConditionalTest007.test001(3, false));
+
+ Assert.assertEquals((short) 1, ConditionalTest007.test001(4, true));
+ Assert.assertEquals((short) 2, ConditionalTest007.test001(4, false));
+ }
+
+ public void test002() {
+ Assert.assertEquals((byte) 1, ConditionalTest007.test002a(true));
+ Assert.assertEquals((byte) 4, ConditionalTest007.test002a(false));
+
+ Assert.assertEquals((short) 1, ConditionalTest007.test002b(true));
+ Assert.assertEquals((short) 4, ConditionalTest007.test002b(false));
+
+ Assert.assertEquals('a', ConditionalTest007.test002c(true));
+ Assert.assertEquals('a', ConditionalTest007.test002c(false));
+ }
+
+ public void test003() {
+ Assert.assertEquals((byte) 1, ConditionalTest007.test003a(true));
+ Assert.assertEquals((byte) 4, ConditionalTest007.test003a(false));
+
+ Assert.assertEquals((short) 1, ConditionalTest007.test003b(true));
+ Assert.assertEquals((short) 4, ConditionalTest007.test003b(false));
+
+ Assert.assertEquals('a', ConditionalTest007.test003c(true));
+ Assert.assertEquals('a', ConditionalTest007.test003c(false));
+ }
+
+
+}
diff --git a/jack-tests/tests/com/android/jack/conditional/test007/jack/ConditionalTest007.java b/jack-tests/tests/com/android/jack/conditional/test007/jack/ConditionalTest007.java
new file mode 100644
index 0000000..4b879db
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/conditional/test007/jack/ConditionalTest007.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2013 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.conditional.test007.jack;
+
+public class ConditionalTest007 {
+
+ @SuppressWarnings("boxing")
+ public static short test001(int test, boolean condition) {
+
+ Byte b1 = new Byte((byte) 1);
+ byte b2 = 1;
+
+ Short s1 = new Short((short) 2);
+ short s2 = 2;
+
+ switch (test) {
+ case 1:
+ return condition ? b1 : s1;
+ case 2:
+ return condition ? b2 : s1;
+ case 3:
+ return condition ? b1 : s2;
+ case 4:
+ return condition ? b2 : s2;
+ default:
+ throw new AssertionError();
+ }
+ }
+
+ public static byte test002a(boolean condition) {
+ byte b = 1;
+
+ byte resultByte = condition ? b : 2*2;
+
+ return resultByte;
+ }
+
+ public static short test002b(boolean condition) {
+ short s = 1;
+
+ short resultShort = condition ? s : 2*2;
+
+ return resultShort;
+ }
+
+ public static char test002c(boolean condition) {
+ char c = 'a';
+
+ char resultChar = condition ? c : 2*2;
+
+ return resultChar;
+ }
+
+
+ public static byte test003a(boolean condition) {
+ @SuppressWarnings("boxing")
+ Byte b = 1;
+
+ @SuppressWarnings("boxing")
+ byte resultByte = condition ? b : 2*2;
+
+ return resultByte;
+ }
+
+ public static short test003b(boolean condition) {
+ @SuppressWarnings("boxing")
+ Short s = 1;
+
+ @SuppressWarnings("boxing")
+ short resultShort = condition ? s : 2*2;
+
+ return resultShort;
+ }
+
+ public static char test003c(boolean condition) {
+ @SuppressWarnings("boxing")
+ Character c = 'a';
+
+ @SuppressWarnings("boxing")
+ char resultChar = condition ? c : 2*2;
+
+ return resultChar;
+ }
+
+}