diff options
author | Yohann Roussel <yroussel@google.com> | 2014-09-05 09:25:18 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-09-05 09:25:18 +0000 |
commit | 790c57a7d299fafada7ed2e8b17f3df11048a698 (patch) | |
tree | 5ad9d03bf3c13441c94839ba4cb49b09059eda1f /jack-tests/tests/com/android | |
parent | ad341e852a71e707a773ad13cf6829fe620351fe (diff) | |
parent | 7046aa756d190db93381a74d1fabc8650132b0f3 (diff) | |
download | toolchain_jack-790c57a7d299fafada7ed2e8b17f3df11048a698.zip toolchain_jack-790c57a7d299fafada7ed2e8b17f3df11048a698.tar.gz toolchain_jack-790c57a7d299fafada7ed2e8b17f3df11048a698.tar.bz2 |
Merge "A test unboxing an Object to int." into ub-jack
Diffstat (limited to 'jack-tests/tests/com/android')
-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 |
2 files changed, 74 insertions, 0 deletions
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); + } +} |