summaryrefslogtreecommitdiffstats
path: root/jack-tests/tests/com/android/jack/conditional/test007
diff options
context:
space:
mode:
Diffstat (limited to 'jack-tests/tests/com/android/jack/conditional/test007')
-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
2 files changed, 163 insertions, 0 deletions
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;
+ }
+
+}