diff options
Diffstat (limited to 'jack-tests')
-rw-r--r-- | jack-tests/.classpath | 2 | ||||
-rw-r--r-- | jack-tests/Android.mk | 2 | ||||
-rw-r--r-- | jack-tests/tests/com/android/jack/java7/boxing/test001/dx/Tests.java | 45 | ||||
-rw-r--r-- | jack-tests/tests/com/android/jack/java7/boxing/test001/jack/UnBoxObject.java | 29 |
4 files changed, 77 insertions, 1 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); + } +} |