summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYohann Roussel <yroussel@google.com>2014-09-03 16:46:46 +0200
committerYohann Roussel <yroussel@google.com>2014-09-05 10:48:49 +0200
commit7046aa756d190db93381a74d1fabc8650132b0f3 (patch)
tree3d49c56f73bc8f782edd352df9c718ba993e9e0f
parentcc96a39b68e815af03c5fdb9aa3adc57721f94fa (diff)
downloadtoolchain_jack-7046aa756d190db93381a74d1fabc8650132b0f3.zip
toolchain_jack-7046aa756d190db93381a74d1fabc8650132b0f3.tar.gz
toolchain_jack-7046aa756d190db93381a74d1fabc8650132b0f3.tar.bz2
A test unboxing an Object to int.
This is legal as of java7 but not yet supported by jack. Change-Id: If23bc190f7c4fc9e4c12b1bc9c01773a934d199c
-rw-r--r--jack-tests/.classpath2
-rw-r--r--jack-tests/Android.mk2
-rw-r--r--jack-tests/tests/com/android/jack/java7/boxing/test001/dx/Tests.java45
-rw-r--r--jack-tests/tests/com/android/jack/java7/boxing/test001/jack/UnBoxObject.java29
-rw-r--r--jack/tests/com/android/jack/java7/AllTest.java2
-rw-r--r--jack/tests/com/android/jack/java7/BoxingTest.java46
6 files changed, 124 insertions, 2 deletions
diff --git a/jack-tests/.classpath b/jack-tests/.classpath
index 639ea83..2d628b0 100644
--- a/jack-tests/.classpath
+++ b/jack-tests/.classpath
@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry excluding="com/android/jack/classpath/test002/lib1override/|com/android/jack/enums/test003/link/Other.java|com/android/jack/enums/test003/link/Values.java|com/android/jack/error/test001/jack/A.java|com/android/jack/error/test002/jack/A.java|com/android/jack/nopackage/jack/|com/android/jack/java7/switches/|com/android/jack/java7/exceptions/|com/android/jack/java7/trywithresources/|com/android/jack/java7/parser/|com/android/jack/compiletime/" kind="src" path="tests"/>
+ <classpathentry excluding="com/android/jack/classpath/test002/lib1override/|com/android/jack/compiletime/|com/android/jack/enums/test003/link/Other.java|com/android/jack/enums/test003/link/Values.java|com/android/jack/error/test001/jack/A.java|com/android/jack/error/test002/jack/A.java|com/android/jack/java7/boxing/|com/android/jack/java7/exceptions/|com/android/jack/java7/parser/|com/android/jack/java7/switches/|com/android/jack/java7/trywithresources/|com/android/jack/nopackage/jack/" kind="src" path="tests"/>
<classpathentry kind="lib" path="libs/junit4.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/jack-tests/Android.mk b/jack-tests/Android.mk
index ece3a8a..c982592 100644
--- a/jack-tests/Android.mk
+++ b/jack-tests/Android.mk
@@ -292,6 +292,8 @@ $(call declare-java7-test-with-name,java7/trywithresources/test001)
$(call declare-java7-test-with-name,java7/trywithresources/test002)
$(call declare-java7-test-with-name,java7/parser/literals/test001)
$(call declare-java7-test-with-name,java7/parser/literals/test002)
+# Known bug
+#$(call declare-java7-test-with-name,java7/boxing/test001)
# define global regression test
include $(JACK_CLEAR_VARS)
diff --git a/jack-tests/tests/com/android/jack/java7/boxing/test001/dx/Tests.java b/jack-tests/tests/com/android/jack/java7/boxing/test001/dx/Tests.java
new file mode 100644
index 0000000..0872bc8
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/java7/boxing/test001/dx/Tests.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2014 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.java7.boxing.test001.dx;
+
+import com.android.jack.java7.boxing.test001.jack.UnBoxObject;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class Tests {
+
+ @Test
+ public void testInt() {
+ try {
+ UnBoxObject.getInt(null);
+ Assert.fail();
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ UnBoxObject.getInt(new Object());
+ Assert.fail();
+ } catch (ClassCastException e) {
+ // expected
+ }
+
+ UnBoxObject.getInt(Integer.valueOf(34));
+ }
+
+}
diff --git a/jack-tests/tests/com/android/jack/java7/boxing/test001/jack/UnBoxObject.java b/jack-tests/tests/com/android/jack/java7/boxing/test001/jack/UnBoxObject.java
new file mode 100644
index 0000000..9615d1d
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/java7/boxing/test001/jack/UnBoxObject.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014 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.java7.boxing.test001.jack;
+
+
+public class UnBoxObject {
+
+ public static Object getObject(Object obj) {
+ return obj;
+ }
+
+ public static int getInt(Object obj) {
+ return (int) getObject(obj);
+ }
+}
diff --git a/jack/tests/com/android/jack/java7/AllTest.java b/jack/tests/com/android/jack/java7/AllTest.java
index 704dadb..a865c94 100644
--- a/jack/tests/com/android/jack/java7/AllTest.java
+++ b/jack/tests/com/android/jack/java7/AllTest.java
@@ -25,6 +25,6 @@ import org.junit.runners.Suite.SuiteClasses;
* JUnit test for compilation of Java 7 features
*/
@RunWith(Suite.class)
-@SuiteClasses(value = {SwitchesTest.class, ExceptionsTest.class})
+@SuiteClasses(value = {SwitchesTest.class, ExceptionsTest.class, BoxingTest.class})
public class AllTest {
}
diff --git a/jack/tests/com/android/jack/java7/BoxingTest.java b/jack/tests/com/android/jack/java7/BoxingTest.java
new file mode 100644
index 0000000..160a17a
--- /dev/null
+++ b/jack/tests/com/android/jack/java7/BoxingTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014 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.java7;
+
+import com.android.jack.Main;
+import com.android.jack.Options;
+import com.android.jack.TestTools;
+import com.android.jack.category.KnownBugs;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * JUnit test for compilation of Java 7 features
+ */
+public class BoxingTest {
+
+ @BeforeClass
+ public static void setUpClass() {
+ Main.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ @Category(KnownBugs.class)
+ @Test
+ public void java7Boxing001() throws Exception {
+ Options options = TestTools.buildCommandLineArgs(TestTools
+ .getJackTestsWithJackFolder("java7/boxing/test001"));
+ options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7");
+ TestTools.runCompilation(options);
+ }
+}