diff options
author | Philipe Mulet | 2005-02-10 10:18:22 +0000 |
---|---|---|
committer | Philipe Mulet | 2005-02-10 10:18:22 +0000 |
commit | 71af1339250e9bbfcdc32b243ce0a3939731748f (patch) | |
tree | 775c9c8e06ca5c37daccd9138381d2557ccea5d0 /org.eclipse.jdt.core.tests.compiler | |
parent | 20ba2adddd9acb8b30c82e8f2340c23092f7b231 (diff) | |
download | eclipse.jdt.core-71af1339250e9bbfcdc32b243ce0a3939731748f.tar.gz eclipse.jdt.core-71af1339250e9bbfcdc32b243ce0a3939731748f.tar.xz eclipse.jdt.core-71af1339250e9bbfcdc32b243ce0a3939731748f.zip |
*** empty log message ***
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler')
-rw-r--r-- | org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java | 83 |
1 files changed, 82 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java index 98eacf6536..f4794d25ac 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java @@ -2778,4 +2778,85 @@ public class AutoBoxingTest extends AbstractComparableTest { "----------\n" ); } -}
\ No newline at end of file + // conditional operator: bool ? Integer : Integer --> Integer (identical operand types) + // but bool ? Integer : Short --> unboxed int + public void test097() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String args[]) {\n" + + " Integer i = 1;\n" + + " Integer j = 2;\n" + + " Short s = 3;\n" + + " foo(args != null ? i : j);\n" + + " foo(args != null ? i : s);\n" + + " }\n" + + " static void foo(int i) {\n" + + " System.out.print(\"[int:\"+i+\"]\");\n" + + " }\n" + + " static void foo(Integer i) {\n" + + " System.out.print(\"[Integer:\"+i+\"]\");\n" + + " }\n" + + "}\n" + }, + "[Integer:1][int:1]" + ); + } + // conditional operator: bool ? Integer : Integer --> Integer (identical operand types) + // but bool ? Integer : Short --> unboxed int + // check autoboxing warnings + public void test098() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String args[]) {\n" + + " Integer i = 1;\n" + + " Integer j = 2;\n" + + " Short s = 3;\n" + + " foo(args != null ? i : j);\n" + + " foo(args != null ? i : s);\n" + + " Zork z;\n" + + " }\n" + + " static void foo(int i) {\n" + + " System.out.print(\"[int:\"+i+\"]\");\n" + + " }\n" + + " static void foo(Integer i) {\n" + + " System.out.print(\"[Integer:\"+i+\"]\");\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " Integer i = 1;\n" + + " ^\n" + + "The expression of type int is boxed into Integer\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " Integer j = 2;\n" + + " ^\n" + + "The expression of type int is boxed into Integer\n" + + "----------\n" + + "3. WARNING in X.java (at line 5)\n" + + " Short s = 3;\n" + + " ^\n" + + "The expression of type int is boxed into Short\n" + + "----------\n" + + "4. WARNING in X.java (at line 7)\n" + + " foo(args != null ? i : s);\n" + + " ^\n" + + "The expression of type Integer is unboxed into int\n" + + "----------\n" + + "5. WARNING in X.java (at line 7)\n" + + " foo(args != null ? i : s);\n" + + " ^\n" + + "The expression of type Short is unboxed into int\n" + + "----------\n" + + "6. ERROR in X.java (at line 8)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n" + ); + }}
\ No newline at end of file |