diff --git a/org.eclipse.xtext.xbase.tests/.classpath b/org.eclipse.xtext.xbase.tests/.classpath
index 208e191b577..87c648da44f 100644
--- a/org.eclipse.xtext.xbase.tests/.classpath
+++ b/org.eclipse.xtext.xbase.tests/.classpath
@@ -20,7 +20,7 @@
-
+
diff --git a/org.eclipse.xtext.xbase.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.xtext.xbase.tests/.settings/org.eclipse.jdt.core.prefs
index cb7cea341a0..d552ac6e151 100644
--- a/org.eclipse.xtext.xbase.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.xtext.xbase.tests/.settings/org.eclipse.jdt.core.prefs
@@ -24,9 +24,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -132,7 +132,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+org.eclipse.jdt.core.compiler.source=17
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
diff --git a/org.eclipse.xtext.xbase.tests/META-INF/MANIFEST.MF b/org.eclipse.xtext.xbase.tests/META-INF/MANIFEST.MF
index 0fda0e00b46..801365a50f4 100644
--- a/org.eclipse.xtext.xbase.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.xtext.xbase.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Xbase Runtime Tests
Bundle-SymbolicName: org.eclipse.xtext.xbase.tests;singleton:=true
Bundle-Version: 2.35.0.qualifier
-Bundle-RequiredExecutionEnvironment: JavaSE-11
+Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.xtext.xbase;bundle-version="2.35.0",
org.eclipse.xtext;bundle-version="2.35.0",
org.eclipse.xtext.testing;bundle-version="2.35.0",
diff --git a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/Compiler2Tests.java b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/Compiler2Tests.java
index ecbb8d09f51..9af6d971b18 100644
--- a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/Compiler2Tests.java
+++ b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/compiler/Compiler2Tests.java
@@ -3,7 +3,7 @@
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
- *
+ *
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.xtext.xbase.tests.compiler;
@@ -27,982 +27,1034 @@ protected FakeTreeAppendable createAppendable() {
*/
@Test
public void testBug_424279() throws Exception {
- compilesTo(
- "{\n" +
- " val treeIt = newArrayList.iterator;\n" +
- " while (treeIt.hasNext) {\n" +
- " val o = treeIt.next;\n" +
- " if (o instanceof java.util.List>) {\n" +
- " return o;\n" +
- " } else {\n" +
- " return o;\n" +
- " }\n" +
- " }\n" +
- " return null;\n" +
- "}\n",
- "\n" +
- "final java.util.Iterator treeIt = org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList().iterator();\n" +
- "while (treeIt.hasNext()) {\n" +
- " {\n" +
- " final CharSequence o = treeIt.next();\n" +
- " if ((o instanceof java.util.List>)) {\n" +
- " return o;\n" +
- " } else {\n" +
- " return o;\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "return null;\n");
+ compilesTo("""
+ {
+ val treeIt = newArrayList.iterator;
+ while (treeIt.hasNext) {
+ val o = treeIt.next;
+ if (o instanceof java.util.List>) {
+ return o;
+ } else {
+ return o;
+ }
+ }
+ return null;
+ }
+ """,
+ """
+ final java.util.Iterator treeIt = org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList().iterator();
+ while (treeIt.hasNext()) {
+ {
+ final CharSequence o = treeIt.next();
+ if ((o instanceof java.util.List>)) {
+ return o;
+ } else {
+ return o;
+ }
+ }
+ }
+ return null;
+ """);
}
@Test
public void testAbstractIterator() throws Exception {
- compilesTo(
- "{\n" +
- " var com.google.common.collect.AbstractIterator iter = [| return self.endOfData ]\n" +
- " return iter\n" +
- "}\n",
- "\n" +
- "final com.google.common.collect.AbstractIterator _function = new com.google.common.collect.AbstractIterator() {\n" +
- " @Override\n" +
- " protected String computeNext() {\n" +
- " return this.endOfData();\n" +
- " }\n" +
- "};\n" +
- "com.google.common.collect.AbstractIterator iter = _function;\n" +
- "return iter;\n");
+ compilesTo("""
+ {
+ var com.google.common.collect.AbstractIterator iter = [| return self.endOfData ]
+ return iter
+ }
+ """,
+ """
+ final com.google.common.collect.AbstractIterator _function = new com.google.common.collect.AbstractIterator() {
+ @Override
+ protected String computeNext() {
+ return this.endOfData();
+ }
+ };
+ com.google.common.collect.AbstractIterator iter = _function;
+ return iter;
+ """);
}
@Test
public void testVariableDeclaration() throws Exception {
- compilesTo(
- "{\n" +
- " val x = 42\n" +
- "}\n", "\n" +
- "final int x = 42;\n");
+ compilesTo("""
+ {
+ val x = 42
+ }
+ """, "final int x = 42;");
}
@Test
public void testVariableDeclaration1() throws Exception {
- compilesTo(
- "{\n" +
- " val a = 'foo'\n" +
- " val x = a\n" +
- "}\n", "\n" +
- "final String a = \"foo\";\n" +
- "final String x = a;\n");
+ compilesTo("""
+ {
+ val a = 'foo'
+ val x = a
+ }
+ """, """
+ final String a = "foo";
+ final String x = a;
+ """);
}
@Test
public void testVariableDeclaration2() throws Exception {
- compilesTo(
- "{\n" +
- " val x = 'foo'.toUpperCase\n" +
- "}\n", "\n" +
- "final String x = \"foo\".toUpperCase();\n");
+ compilesTo("""
+ {
+ val x = 'foo'.toUpperCase
+ }
+ """, """
+ final String x = "foo".toUpperCase();
+ """);
}
@Test
public void testBug367144() throws Exception {
- compilesTo(
- "foo::bar::SubOfClassWithStatics::MY_STATIC_FIELD\n", "\n" +
- "return foo.bar.SubOfClassWithStatics.MY_STATIC_FIELD;\n");
+ compilesTo("foo::bar::SubOfClassWithStatics::MY_STATIC_FIELD", "return foo.bar.SubOfClassWithStatics.MY_STATIC_FIELD;");
}
@Test
public void testBug367144_1() throws Exception {
- compilesTo(
- "foo::bar::SubOfClassWithStatics::MY_STATIC_METHOD\n",
- "\n" +
- "String _MY_STATIC_METHOD = foo.bar.SubOfClassWithStatics.MY_STATIC_METHOD();\n" +
- "return _MY_STATIC_METHOD;\n");
+ compilesTo("foo::bar::SubOfClassWithStatics::MY_STATIC_METHOD", """
+ String _MY_STATIC_METHOD = foo.bar.SubOfClassWithStatics.MY_STATIC_METHOD();
+ return _MY_STATIC_METHOD;
+ """);
}
@Test
public void testBug371321_1() throws Exception {
- compilesTo(
- "try {\n" +
- " 'foo'.length\n" +
- "} catch (RuntimeException assert) {\n" +
- " assert.printStackTrace\n" +
- "}\n",
- "\n" +
- "int _xtrycatchfinallyexpression = (int) 0;\n" +
- "try {\n" +
- " _xtrycatchfinallyexpression = \"foo\".length();\n" +
- "} catch (final Throwable _t) {\n" +
- " if (_t instanceof RuntimeException) {\n" +
- " final RuntimeException assert_ = (RuntimeException)_t;\n" +
- " assert_.printStackTrace();\n" +
- " } else {\n" +
- " throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_t);\n" +
- " }\n" +
- "}\n" +
- "return Integer.valueOf(_xtrycatchfinallyexpression);\n");
+ compilesTo("""
+ try {
+ 'foo'.length
+ } catch (RuntimeException assert) {
+ assert.printStackTrace
+ }
+ """, """
+ int _xtrycatchfinallyexpression = (int) 0;
+ try {
+ _xtrycatchfinallyexpression = "foo".length();
+ } catch (final Throwable _t) {
+ if (_t instanceof RuntimeException) {
+ final RuntimeException assert_ = (RuntimeException)_t;
+ assert_.printStackTrace();
+ } else {
+ throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_t);
+ }
+ }
+ return Integer.valueOf(_xtrycatchfinallyexpression);
+ """);
}
@Test
public void testBug420984_EmptyCatch() throws Exception {
- compilesTo(
- "try {\n" +
- " println(\"\")\n" +
- "} catch (RuntimeException e) {\n" +
- "}\n",
- "\n" +
- "String _xtrycatchfinallyexpression = null;\n" +
- "try {\n" +
- " _xtrycatchfinallyexpression = org.eclipse.xtext.xbase.lib.InputOutput.println(\"\");\n" +
- "} catch (final Throwable _t) {\n" +
- " if (_t instanceof RuntimeException) {\n" +
- " _xtrycatchfinallyexpression = null;\n" +
- " } else {\n" +
- " throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_t);\n" +
- " }\n" +
- "}\n" +
- "return _xtrycatchfinallyexpression;\n");
+ compilesTo("""
+ try {
+ println("")
+ } catch (RuntimeException e) {
+ }
+ """, """
+ String _xtrycatchfinallyexpression = null;
+ try {
+ _xtrycatchfinallyexpression = org.eclipse.xtext.xbase.lib.InputOutput.println("");
+ } catch (final Throwable _t) {
+ if (_t instanceof RuntimeException) {
+ _xtrycatchfinallyexpression = null;
+ } else {
+ throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_t);
+ }
+ }
+ return _xtrycatchfinallyexpression;
+ """);
}
@Test
public void testBug420984_EmptyCatchWithoutReturnType() throws Exception {
- compilesToStatement(
- "try {\n" +
- " println(\"\")\n" +
- "} catch (RuntimeException e) {\n" +
- "}\n",
- "try {\n" +
- " org.eclipse.xtext.xbase.lib.InputOutput.println(\"\");\n" +
- "} catch (final Throwable _t) {\n" +
- " if (_t instanceof RuntimeException) {\n" +
- " } else {\n" +
- " throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_t);\n" +
- " }\n" +
- "}");
+ compilesToStatement("""
+ try {
+ println("")
+ } catch (RuntimeException e) {
+ }
+ """, """
+ try {
+ org.eclipse.xtext.xbase.lib.InputOutput.println("");
+ } catch (final Throwable _t) {
+ if (_t instanceof RuntimeException) {
+ } else {
+ throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_t);
+ }
+ }""");
}
@Test
public void testBug420984_CatchWithoutReference() throws Exception {
- compilesTo(
- "try {\n" +
- " println(\"\")\n" +
- "} catch (RuntimeException e) {\n" +
- " println(\"\")\n" +
- "}\n",
- "\n" +
- "String _xtrycatchfinallyexpression = null;\n" +
- "try {\n" +
- " _xtrycatchfinallyexpression = org.eclipse.xtext.xbase.lib.InputOutput.println(\"\");\n" +
- "} catch (final Throwable _t) {\n" +
- " if (_t instanceof RuntimeException) {\n" +
- " _xtrycatchfinallyexpression = org.eclipse.xtext.xbase.lib.InputOutput.println(\"\");\n" +
- " } else {\n" +
- " throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_t);\n" +
- " }\n" +
- "}\n" +
- "return _xtrycatchfinallyexpression;\n");
+ compilesTo("""
+ try {
+ println("")
+ } catch (RuntimeException e) {
+ println("")
+ }
+ """, """
+ String _xtrycatchfinallyexpression = null;
+ try {
+ _xtrycatchfinallyexpression = org.eclipse.xtext.xbase.lib.InputOutput.println("");
+ } catch (final Throwable _t) {
+ if (_t instanceof RuntimeException) {
+ _xtrycatchfinallyexpression = org.eclipse.xtext.xbase.lib.InputOutput.println("");
+ } else {
+ throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_t);
+ }
+ }
+ return _xtrycatchfinallyexpression;
+ """);
}
@Test
public void testBug420984_CatchWithReference() throws Exception {
- compilesTo(
- "try {\n" +
- " println(\"\")\n" +
- "} catch (RuntimeException e) {\n" +
- " println(e)\n" +
- "}\n",
- "\n" +
- "java.io.Serializable _xtrycatchfinallyexpression = null;\n" +
- "try {\n" +
- " _xtrycatchfinallyexpression = org.eclipse.xtext.xbase.lib.InputOutput.println(\"\");\n" +
- "} catch (final Throwable _t) {\n" +
- " if (_t instanceof RuntimeException) {\n" +
- " final RuntimeException e = (RuntimeException)_t;\n" +
- " _xtrycatchfinallyexpression = org.eclipse.xtext.xbase.lib.InputOutput.println(e);\n" +
- " } else {\n" +
- " throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_t);\n" +
- " }\n" +
- "}\n" +
- "return _xtrycatchfinallyexpression;\n");
+ compilesTo("""
+ try {
+ println("")
+ } catch (RuntimeException e) {
+ println(e)
+ }
+ """, """
+ java.io.Serializable _xtrycatchfinallyexpression = null;
+ try {
+ _xtrycatchfinallyexpression = org.eclipse.xtext.xbase.lib.InputOutput.println("");
+ } catch (final Throwable _t) {
+ if (_t instanceof RuntimeException) {
+ final RuntimeException e = (RuntimeException)_t;
+ _xtrycatchfinallyexpression = org.eclipse.xtext.xbase.lib.InputOutput.println(e);
+ } else {
+ throw org.eclipse.xtext.xbase.lib.Exceptions.sneakyThrow(_t);
+ }
+ }
+ return _xtrycatchfinallyexpression;
+ """);
}
@Test
public void testBug371321_2() throws Exception {
- compilesTo(
- "for (assert : 'foo'.toCharArray) {\n" +
- " println(assert)\n" +
- "}\n",
- "\n" +
- "char[] _charArray = \"foo\".toCharArray();\n" +
- "for (final char assert_ : _charArray) {\n" +
- " org.eclipse.xtext.xbase.lib.InputOutput.println(Character.valueOf(assert_));\n" +
- "}\n");
+ compilesTo("""
+ for (assert : 'foo'.toCharArray) {
+ println(assert)
+ }
+ """, """
+ char[] _charArray = "foo".toCharArray();
+ for (final char assert_ : _charArray) {
+ org.eclipse.xtext.xbase.lib.InputOutput.println(Character.valueOf(assert_));
+ }
+ """);
}
@Test
public void testNewThread() throws Exception {
- compilesTo(
- "new Thread [| ]\n",
- "\n" +
- "final Runnable _function = new Runnable() {\n" +
- " public void run() {\n" +
- " }\n" +
- "};\n" +
- "Thread _thread = new Thread(_function);\n" +
- "return _thread;\n");
+ compilesTo("new Thread [| ]", """
+ final Runnable _function = new Runnable() {
+ public void run() {
+ }
+ };
+ Thread _thread = new Thread(_function);
+ return _thread;
+ """);
}
@Test
public void testForLoop_01() throws Exception {
- compilesTo(
- "for(int i: 1..2) { i.toString }\n",
- "\n" +
- "org.eclipse.xtext.xbase.lib.IntegerRange _upTo = new org.eclipse.xtext.xbase.lib.IntegerRange(1, 2);\n" +
- "for (final int i : _upTo) {\n" +
- " Integer.valueOf(i).toString();\n" +
- "}\n");
+ compilesTo("""
+ for(int i: 1..2) { i.toString }
+ """, """
+ org.eclipse.xtext.xbase.lib.IntegerRange _upTo = new org.eclipse.xtext.xbase.lib.IntegerRange(1, 2);
+ for (final int i : _upTo) {
+ Integer.valueOf(i).toString();
+ }
+ """);
}
@Test
public void testForLoop_02() throws Exception {
- compilesTo(
- "for(Integer i: 1..2) { i.toString }\n",
- "\n" +
- "org.eclipse.xtext.xbase.lib.IntegerRange _upTo = new org.eclipse.xtext.xbase.lib.IntegerRange(1, 2);\n" +
- "for (final Integer i : _upTo) {\n" +
- " i.toString();\n" +
- "}\n");
+ compilesTo("""
+ for(Integer i: 1..2) { i.toString }
+ """, """
+ org.eclipse.xtext.xbase.lib.IntegerRange _upTo = new org.eclipse.xtext.xbase.lib.IntegerRange(1, 2);
+ for (final Integer i : _upTo) {
+ i.toString();
+ }
+ """);
}
@Test
public void testForLoop_03() throws Exception {
- compilesTo(
- "for(i: 1..2) { i.toString }\n",
- "\n" +
- "org.eclipse.xtext.xbase.lib.IntegerRange _upTo = new org.eclipse.xtext.xbase.lib.IntegerRange(1, 2);\n" +
- "for (final Integer i : _upTo) {\n" +
- " i.toString();\n" +
- "}\n");
+ compilesTo("""
+ for(i: 1..2) { i.toString }
+ """, """
+ org.eclipse.xtext.xbase.lib.IntegerRange _upTo = new org.eclipse.xtext.xbase.lib.IntegerRange(1, 2);
+ for (final Integer i : _upTo) {
+ i.toString();
+ }
+ """);
}
@Test
public void testForLoop_04() throws Exception {
- compilesTo(
- "for(i: null as int[]) { i.toString }\n",
- "\n" +
- "for (final int i : ((int[]) null)) {\n" +
- " Integer.valueOf(i).toString();\n" +
- "}\n");
+ compilesTo("""
+ for(i: null as int[]) { i.toString }
+ """, """
+ for (final int i : ((int[]) null)) {
+ Integer.valueOf(i).toString();
+ }
+ """);
}
@Test
public void testForLoop_05() throws Exception {
- compilesTo(
- "for(i: null as Integer[]) { i.toString }\n", "\n" +
- "for (final Integer i : ((Integer[]) null)) {\n" +
- " i.toString();\n" +
- "}\n");
+ compilesTo("""
+ for(i: null as Integer[]) { i.toString }
+ """, """
+ for (final Integer i : ((Integer[]) null)) {
+ i.toString();
+ }
+ """);
}
@Test
public void testForLoop_06() throws Exception {
- compilesTo(
- "for(Integer i: null as int[]) { i.toString }\n", "\n" +
- "for (final Integer i : ((int[]) null)) {\n" +
- " i.toString();\n" +
- "}\n");
+ compilesTo("""
+ for(Integer i: null as int[]) { i.toString }
+ """, """
+ for (final Integer i : ((int[]) null)) {
+ i.toString();
+ }
+ """);
}
@Test
public void testForLoop_07() throws Exception {
- compilesTo(
- "for(int i: null as Integer[]) { i.toString }\n",
- "\n" +
- "for (final int i : ((Integer[]) null)) {\n" +
- " Integer.valueOf(i).toString();\n" +
- "}\n");
+ compilesTo("""
+ for(int i: null as Integer[]) { i.toString }
+ """, """
+ for (final int i : ((Integer[]) null)) {
+ Integer.valueOf(i).toString();
+ }
+ """);
}
@Test
public void testForLoop_08() throws Exception {
- compilesTo(
- "for(Integer i: null as int[]) { i.toString }\n", "\n" +
- "for (final Integer i : ((int[]) null)) {\n" +
- " i.toString();\n" +
- "}\n");
+ compilesTo("""
+ for(Integer i: null as int[]) { i.toString }
+ """, """
+ for (final Integer i : ((int[]) null)) {
+ i.toString();
+ }
+ """);
}
@Test
public void testForLoop_09() throws Exception {
- compilesTo(
- "for(int i: null as Integer[]) { i.toString }\n",
- "\n" +
- "for (final int i : ((Integer[]) null)) {\n" +
- " Integer.valueOf(i).toString();\n" +
- "}\n");
+ compilesTo("""
+ for(int i: null as Integer[]) { i.toString }
+ """, """
+ for (final int i : ((Integer[]) null)) {
+ Integer.valueOf(i).toString();
+ }
+ """);
}
@Test
public void testForLoop_10() throws Exception {
- compilesTo(
- "for(int i: newArrayList) { i.toString }\n",
- "\n" +
- "java.util.ArrayList _newArrayList = org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList();\n" +
- "for (final int i : _newArrayList) {\n" +
- " Integer.valueOf(i).toString();\n" +
- "}\n");
+ compilesTo("""
+ for(int i: newArrayList) { i.toString }
+ """, """
+ java.util.ArrayList _newArrayList = org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList();
+ for (final int i : _newArrayList) {
+ Integer.valueOf(i).toString();
+ }
+ """);
}
@Test
public void testForLoop_11() throws Exception {
- compilesTo(
- "for(Integer i: newArrayList) { i.toString }\n",
- "\n" +
- "java.util.ArrayList _newArrayList = org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList();\n" +
- "for (final Integer i : _newArrayList) {\n" +
- " i.toString();\n" +
- "}\n");
+ compilesTo("""
+ for(Integer i: newArrayList) { i.toString }
+ """, """
+ java.util.ArrayList _newArrayList = org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList();
+ for (final Integer i : _newArrayList) {
+ i.toString();
+ }
+ """);
}
@Test
public void testForLoop_12() throws Exception {
- compilesTo(
- "for(double d: newArrayList) { d.toString }\n",
- "\n" +
- "java.util.ArrayList _newArrayList = org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList();\n" +
- "for (final double d : _newArrayList) {\n" +
- " Double.valueOf(d).toString();\n" +
- "}\n");
+ compilesTo("""
+ for(double d: newArrayList) { d.toString }
+ """, """
+ java.util.ArrayList _newArrayList = org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList();
+ for (final double d : _newArrayList) {
+ Double.valueOf(d).toString();
+ }
+ """);
}
@Test
public void testForLoop_13() throws Exception {
- compilesTo(
- "for(double d: null as int[]) { d.toString }\n",
- "\n" +
- "for (final double d : ((int[]) null)) {\n" +
- " Double.valueOf(d).toString();\n" +
- "}\n");
+ compilesTo("""
+ for(double d: null as int[]) { d.toString }
+ """, """
+ for (final double d : ((int[]) null)) {
+ Double.valueOf(d).toString();
+ }
+ """);
}
@Test
public void testForLoop_14() throws Exception {
- compilesTo(
- "for(double d: null as Integer[]) { d.toString }\n",
- "\n" +
- "for (final double d : ((Integer[]) null)) {\n" +
- " Double.valueOf(d).toString();\n" +
- "}\n");
+ compilesTo("""
+ for(double d: null as Integer[]) { d.toString }
+ """, """
+ for (final double d : ((Integer[]) null)) {
+ Double.valueOf(d).toString();
+ }
+ """);
}
@Test
public void testNullSafe_01() throws Exception {
- compilesTo(
- "('foo'.toUpperCase as CharSequence)?.subSequence(0,2)\n",
- "\n" +
- "String _upperCase = \"foo\".toUpperCase();\n" +
- "CharSequence _subSequence = null;\n" +
- "if (((CharSequence) _upperCase)!=null) {\n" +
- " _subSequence=((CharSequence) _upperCase).subSequence(0, 2);\n" +
- "}\n" +
- "return _subSequence;\n");
+ compilesTo("""
+ ('foo'.toUpperCase as CharSequence)?.subSequence(0,2)
+ """, """
+ String _upperCase = "foo".toUpperCase();
+ CharSequence _subSequence = null;
+ if (((CharSequence) _upperCase)!=null) {
+ _subSequence=((CharSequence) _upperCase).subSequence(0, 2);
+ }
+ return _subSequence;
+ """);
}
@Test
public void testSwitch() throws Exception {
- compilesTo(
- "{\n" +
- " val it = String\n" +
- " switch name {\n" +
- " CharSequence : name\n" +
- " default : 'noname'\n" +
- " }\n" +
- "}\n",
- "\n" +
- "String _xblockexpression = null;\n" +
- "{\n" +
- " final Class it = String.class;\n" +
- " String _switchResult = null;\n" +
- " String _name = it.getName();\n" +
- " boolean _matched = false;\n" +
- " if (_name instanceof CharSequence) {\n" +
- " _matched=true;\n" +
- " _switchResult = it.getName();\n" +
- " }\n" +
- " if (!_matched) {\n" +
- " _switchResult = \"noname\";\n" +
- " }\n" +
- " _xblockexpression = _switchResult;\n" +
- "}\n" +
- "return _xblockexpression;\n");
+ compilesTo("""
+ {
+ val it = String
+ switch name {
+ CharSequence : name
+ default : 'noname'
+ }
+ }
+ """, """
+ String _xblockexpression = null;
+ {
+ final Class it = String.class;
+ String _switchResult = null;
+ String _name = it.getName();
+ boolean _matched = false;
+ if (_name instanceof CharSequence) {
+ _matched=true;
+ _switchResult = it.getName();
+ }
+ if (!_matched) {
+ _switchResult = "noname";
+ }
+ _xblockexpression = _switchResult;
+ }
+ return _xblockexpression;
+ """);
}
@Test
public void testSwitchScopes_Bug470586_01() throws Exception {
- compilesTo(
- "\n" +
- "{\n" +
- " val list = #[\"1\", \"2\"]\n" +
- " list.forEach[\n" +
- " val res = switch it {\n" +
- " CharSequence : it\n" +
- " }\n" +
- " ]\n" +
- " list.forEach[\n" +
- " println(it)\n" +
- " ]\n" +
- "}\n",
- "\n" +
- "final java.util.List list = java.util.Collections.unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList(\"1\", \"2\"));\n" +
- "final java.util.function.Consumer _function = new java.util.function.Consumer() {\n" +
- " public void accept(final String it) {\n" +
- " String _switchResult = null;\n" +
- " boolean _matched = false;\n" +
- " if (it instanceof CharSequence) {\n" +
- " _matched=true;\n" +
- " _switchResult = it;\n" +
- " }\n" +
- " final String res = _switchResult;\n" +
- " }\n" +
- "};\n" +
- "list.forEach(_function);\n" +
- "final java.util.function.Consumer _function_1 = new java.util.function.Consumer() {\n" +
- " public void accept(final String it) {\n" +
- " org.eclipse.xtext.xbase.lib.InputOutput.println(it);\n" +
- " }\n" +
- "};\n" +
- "list.forEach(_function_1);\n");
+ compilesTo("""
+ {
+ val list = #["1", "2"]
+ list.forEach[
+ val res = switch it {
+ CharSequence : it
+ }
+ ]
+ list.forEach[
+ println(it)
+ ]
+ }
+ """,
+ """
+ final java.util.List list = java.util.Collections.unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList("1", "2"));
+ final java.util.function.Consumer _function = new java.util.function.Consumer() {
+ public void accept(final String it) {
+ String _switchResult = null;
+ boolean _matched = false;
+ if (it instanceof CharSequence) {
+ _matched=true;
+ _switchResult = it;
+ }
+ final String res = _switchResult;
+ }
+ };
+ list.forEach(_function);
+ final java.util.function.Consumer _function_1 = new java.util.function.Consumer() {
+ public void accept(final String it) {
+ org.eclipse.xtext.xbase.lib.InputOutput.println(it);
+ }
+ };
+ list.forEach(_function_1);
+ """);
}
@Test
public void testSwitchScopes_Bug470586_02() throws Exception {
- compilesTo(
- "{\n" +
- " val list = #[\"1\", \"2\"]\n" +
- " list.forEach[\n" +
- " val res = switch it {\n" +
- " CharSequence : it\n" +
- " default : ''\n" +
- " }\n" +
- " ]\n" +
- " list.forEach[\n" +
- " println(it)\n" +
- " ]\n" +
- "}\n",
- "\n" +
- "final java.util.List list = java.util.Collections.unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList(\"1\", \"2\"));\n" +
- "final java.util.function.Consumer _function = new java.util.function.Consumer() {\n" +
- " public void accept(final String it) {\n" +
- " String _switchResult = null;\n" +
- " boolean _matched = false;\n" +
- " if (it instanceof CharSequence) {\n" +
- " _matched=true;\n" +
- " _switchResult = it;\n" +
- " }\n" +
- " if (!_matched) {\n" +
- " _switchResult = \"\";\n" +
- " }\n" +
- " final String res = _switchResult;\n" +
- " }\n" +
- "};\n" +
- "list.forEach(_function);\n" +
- "final java.util.function.Consumer _function_1 = new java.util.function.Consumer() {\n" +
- " public void accept(final String it) {\n" +
- " org.eclipse.xtext.xbase.lib.InputOutput.println(it);\n" +
- " }\n" +
- "};\n" +
- "list.forEach(_function_1);\n");
+ compilesTo("""
+ {
+ val list = #["1", "2"]
+ list.forEach[
+ val res = switch it {
+ CharSequence : it
+ default : ''
+ }
+ ]
+ list.forEach[
+ println(it)
+ ]
+ }
+ """,
+ """
+ final java.util.List list = java.util.Collections.unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList("1", "2"));
+ final java.util.function.Consumer _function = new java.util.function.Consumer() {
+ public void accept(final String it) {
+ String _switchResult = null;
+ boolean _matched = false;
+ if (it instanceof CharSequence) {
+ _matched=true;
+ _switchResult = it;
+ }
+ if (!_matched) {
+ _switchResult = "";
+ }
+ final String res = _switchResult;
+ }
+ };
+ list.forEach(_function);
+ final java.util.function.Consumer _function_1 = new java.util.function.Consumer() {
+ public void accept(final String it) {
+ org.eclipse.xtext.xbase.lib.InputOutput.println(it);
+ }
+ };
+ list.forEach(_function_1);
+ """);
}
@Test
public void testSwitchScopes_Bug470586_03() throws Exception {
- compilesTo(
- "{\n" +
- " val list = #[\"1\", \"2\"]\n" +
- " list.forEach[\n" +
- " val res = switch it {\n" +
- " String, CharSequence : it\n" +
- " default : ''\n" +
- " }\n" +
- " ]\n" +
- " list.forEach[\n" +
- " println(it)\n" +
- " ]\n" +
- "}\n",
- "\n" +
- "final java.util.List list = java.util.Collections.unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList(\"1\", \"2\"));\n" +
- "final java.util.function.Consumer _function = new java.util.function.Consumer() {\n" +
- " public void accept(final String it) {\n" +
- " String _switchResult = null;\n" +
- " boolean _matched = false;\n" +
- " if (it instanceof String) {\n" +
- " _matched=true;\n" +
- " }\n" +
- " if (!_matched) {\n" +
- " if (it instanceof CharSequence) {\n" +
- " _matched=true;\n" +
- " }\n" +
- " }\n" +
- " if (_matched) {\n" +
- " _switchResult = it;\n" +
- " }\n" +
- " if (!_matched) {\n" +
- " _switchResult = \"\";\n" +
- " }\n" +
- " final String res = _switchResult;\n" +
- " }\n" +
- "};\n" +
- "list.forEach(_function);\n" +
- "final java.util.function.Consumer _function_1 = new java.util.function.Consumer() {\n" +
- " public void accept(final String it) {\n" +
- " org.eclipse.xtext.xbase.lib.InputOutput.println(it);\n" +
- " }\n" +
- "};\n" +
- "list.forEach(_function_1);\n");
+ compilesTo("""
+ {
+ val list = #["1", "2"]
+ list.forEach[
+ val res = switch it {
+ String, CharSequence : it
+ default : ''
+ }
+ ]
+ list.forEach[
+ println(it)
+ ]
+ }
+ """,
+ """
+ final java.util.List list = java.util.Collections.unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList("1", "2"));
+ final java.util.function.Consumer _function = new java.util.function.Consumer() {
+ public void accept(final String it) {
+ String _switchResult = null;
+ boolean _matched = false;
+ if (it instanceof String) {
+ _matched=true;
+ }
+ if (!_matched) {
+ if (it instanceof CharSequence) {
+ _matched=true;
+ }
+ }
+ if (_matched) {
+ _switchResult = it;
+ }
+ if (!_matched) {
+ _switchResult = "";
+ }
+ final String res = _switchResult;
+ }
+ };
+ list.forEach(_function);
+ final java.util.function.Consumer _function_1 = new java.util.function.Consumer() {
+ public void accept(final String it) {
+ org.eclipse.xtext.xbase.lib.InputOutput.println(it);
+ }
+ };
+ list.forEach(_function_1);
+ """);
}
@Test
public void testFallThroughSwitch() throws Exception {
- compilesTo(
- "{\n" +
- " switch x : 1 {\n" +
- " case 1,\n" +
- " case 2:\n" +
- " 'lalala'\n" +
- " }\n" +
- "}\n",
- "\n" +
- "String _switchResult = null;\n" +
- "final int x = 1;\n" +
- "switch (x) {\n" +
- " case 1:\n" +
- " case 2:\n" +
- " _switchResult = \"lalala\";\n" +
- " break;\n" +
- "}\n" +
- "return _switchResult;\n");
+ compilesTo("""
+ {
+ switch x : 1 {
+ case 1,
+ case 2:
+ 'lalala'
+ }
+ }
+ """, """
+ String _switchResult = null;
+ final int x = 1;
+ switch (x) {
+ case 1:
+ case 2:
+ _switchResult = "lalala";
+ break;
+ }
+ return _switchResult;
+ """);
}
@Test
public void testFallThroughSwitch_2() throws Exception {
- compilesTo(
- "{\n" +
- " switch x : 'lalala' {\n" +
- " case 'a',\n" +
- " case 'b',\n" +
- " case 'c':\n" +
- " 'lalala'\n" +
- " }\n" +
- "}\n",
- "\n" +
- "String _switchResult = null;\n" +
- "final String x = \"lalala\";\n" +
- "boolean _matched = false;\n" +
- "if (com.google.common.base.Objects.equal(x, \"a\")) {\n" +
- " _matched=true;\n" +
- "}\n" +
- "if (!_matched) {\n" +
- " if (com.google.common.base.Objects.equal(x, \"b\")) {\n" +
- " _matched=true;\n" +
- " }\n" +
- "}\n" +
- "if (!_matched) {\n" +
- " if (com.google.common.base.Objects.equal(x, \"c\")) {\n" +
- " _matched=true;\n" +
- " }\n" +
- "}\n" +
- "if (_matched) {\n" +
- " _switchResult = \"lalala\";\n" +
- "}\n" +
- "return _switchResult;\n");
+ compilesTo("""
+ {
+ switch x : 'lalala' {
+ case 'a',
+ case 'b',
+ case 'c':
+ 'lalala'
+ }
+ }
+ """, """
+ String _switchResult = null;
+ final String x = "lalala";
+ boolean _matched = false;
+ if (com.google.common.base.Objects.equal(x, "a")) {
+ _matched=true;
+ }
+ if (!_matched) {
+ if (com.google.common.base.Objects.equal(x, "b")) {
+ _matched=true;
+ }
+ }
+ if (!_matched) {
+ if (com.google.common.base.Objects.equal(x, "c")) {
+ _matched=true;
+ }
+ }
+ if (_matched) {
+ _switchResult = "lalala";
+ }
+ return _switchResult;
+ """);
}
@Test
public void testFallThroughSwitch_3() throws Exception {
- compilesTo(
- "{\n" +
- " switch x : 1 {\n" +
- " case 1,\n" +
- " case 2,\n" +
- " default:\n" +
- " 'lalala'\n" +
- " }\n" +
- "}\n",
- "\n" +
- "String _switchResult = null;\n" +
- "final int x = 1;\n" +
- "switch (x) {\n" +
- " case 1:\n" +
- " case 2:\n" +
- " default:\n" +
- " _switchResult = \"lalala\";\n" +
- " break;\n" +
- "}\n" +
- "return _switchResult;\n");
+ compilesTo("""
+ {
+ switch x : 1 {
+ case 1,
+ case 2,
+ default:
+ 'lalala'
+ }
+ }
+ """, """
+ String _switchResult = null;
+ final int x = 1;
+ switch (x) {
+ case 1:
+ case 2:
+ default:
+ _switchResult = "lalala";
+ break;
+ }
+ return _switchResult;
+ """);
}
@Test
public void testFallThroughSwitch_4() throws Exception {
- compilesTo(
- "{\n" +
- " switch x : 'lalala' {\n" +
- " case 'a',\n" +
- " case 'b',\n" +
- " default:\n" +
- " 'lalala'\n" +
- " }\n" +
- "}\n",
- "\n" +
- "String _switchResult = null;\n" +
- "final String x = \"lalala\";\n" +
- "boolean _matched = false;\n" +
- "if (com.google.common.base.Objects.equal(x, \"a\")) {\n" +
- " _matched=true;\n" +
- "}\n" +
- "if (!_matched) {\n" +
- " if (com.google.common.base.Objects.equal(x, \"b\")) {\n" +
- " _matched=true;\n" +
- " }\n" +
- "}\n" +
- "if (_matched) {\n" +
- " _switchResult = \"lalala\";\n" +
- "}\n" +
- "if (!_matched) {\n" +
- " _switchResult = \"lalala\";\n" +
- "}\n" +
- "return _switchResult;\n");
+ compilesTo("""
+ {
+ switch x : 'lalala' {
+ case 'a',
+ case 'b',
+ default:
+ 'lalala'
+ }
+ }
+ """, """
+ String _switchResult = null;
+ final String x = "lalala";
+ boolean _matched = false;
+ if (com.google.common.base.Objects.equal(x, "a")) {
+ _matched=true;
+ }
+ if (!_matched) {
+ if (com.google.common.base.Objects.equal(x, "b")) {
+ _matched=true;
+ }
+ }
+ if (_matched) {
+ _switchResult = "lalala";
+ }
+ if (!_matched) {
+ _switchResult = "lalala";
+ }
+ return _switchResult;
+ """);
}
@Test
public void testFallThroughSwitch_5() throws Exception {
- compilesTo(
- "{\n" +
- " switch x : 1 {\n" +
- " case 1:\n" +
- " 'blabla'\n" +
- " case 2,\n" +
- " default:\n" +
- " 'lalala'\n" +
- " }\n" +
- "}\n",
- "\n" +
- "String _switchResult = null;\n" +
- "final int x = 1;\n" +
- "switch (x) {\n" +
- " case 1:\n" +
- " _switchResult = \"blabla\";\n" +
- " break;\n" +
- " case 2:\n" +
- " default:\n" +
- " _switchResult = \"lalala\";\n" +
- " break;\n" +
- "}\n" +
- "return _switchResult;\n");
+ compilesTo("""
+ {
+ switch x : 1 {
+ case 1:
+ 'blabla'
+ case 2,
+ default:
+ 'lalala'
+ }
+ }
+ """, """
+ String _switchResult = null;
+ final int x = 1;
+ switch (x) {
+ case 1:
+ _switchResult = "blabla";
+ break;
+ case 2:
+ default:
+ _switchResult = "lalala";
+ break;
+ }
+ return _switchResult;
+ """);
}
@Test
public void testFallThroughSwitch_6() throws Exception {
- compilesTo(
- "{\n" +
- " switch x : new Object {\n" +
- " String case 'a':\n" +
- " 'blabla'\n" +
- " Integer case 1,\n" +
- " case 2,\n" +
- " default:\n" +
- " 'lalala'\n" +
- " }\n" +
- "}\n",
- "\n" +
- "String _switchResult = null;\n" +
- "Object _object = new Object();\n" +
- "final Object x = _object;\n" +
- "boolean _matched = false;\n" +
- "if (x instanceof String) {\n" +
- " if (com.google.common.base.Objects.equal(x, \"a\")) {\n" +
- " _matched=true;\n" +
- " _switchResult = \"blabla\";\n" +
- " }\n" +
- "}\n" +
- "if (!_matched) {\n" +
- " if (x instanceof Integer) {\n" +
- " if (com.google.common.base.Objects.equal(x, 1)) {\n" +
- " _matched=true;\n" +
- " }\n" +
- " }\n" +
- " if (!_matched) {\n" +
- " if (com.google.common.base.Objects.equal(x, 2)) {\n" +
- " _matched=true;\n" +
- " }\n" +
- " }\n" +
- " if (_matched) {\n" +
- " _switchResult = \"lalala\";\n" +
- " }\n" +
- "}\n" +
- "if (!_matched) {\n" +
- " _switchResult = \"lalala\";\n" +
- "}\n" +
- "return _switchResult;\n");
+ compilesTo("""
+ {
+ switch x : new Object {
+ String case 'a':
+ 'blabla'
+ Integer case 1,
+ case 2,
+ default:
+ 'lalala'
+ }
+ }
+ """, """
+ String _switchResult = null;
+ Object _object = new Object();
+ final Object x = _object;
+ boolean _matched = false;
+ if (x instanceof String) {
+ if (com.google.common.base.Objects.equal(x, "a")) {
+ _matched=true;
+ _switchResult = "blabla";
+ }
+ }
+ if (!_matched) {
+ if (x instanceof Integer) {
+ if (com.google.common.base.Objects.equal(x, 1)) {
+ _matched=true;
+ }
+ }
+ if (!_matched) {
+ if (com.google.common.base.Objects.equal(x, 2)) {
+ _matched=true;
+ }
+ }
+ if (_matched) {
+ _switchResult = "lalala";
+ }
+ }
+ if (!_matched) {
+ _switchResult = "lalala";
+ }
+ return _switchResult;
+ """);
}
@Test
public void testFallThroughSwitch_7() throws Exception {
- compilesTo(
- "{\n" +
- " switch x : 'lalala' as Object { \n" +
- " String, Integer case 1: 0\n" +
- " Integer, default: 1\n" +
- " }\n" +
- "}\n",
- "\n" +
- "int _switchResult = (int) 0;\n" +
- "final Object x = ((Object) \"lalala\");\n" +
- "boolean _matched = false;\n" +
- "if (x instanceof String) {\n" +
- " _matched=true;\n" +
- "}\n" +
- "if (!_matched) {\n" +
- " if (x instanceof Integer) {\n" +
- " if (com.google.common.base.Objects.equal(x, 1)) {\n" +
- " _matched=true;\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "if (_matched) {\n" +
- " _switchResult = 0;\n" +
- "}\n" +
- "if (!_matched) {\n" +
- " if (x instanceof Integer) {\n" +
- " _matched=true;\n" +
- " _switchResult = 1;\n" +
- " }\n" +
- "}\n" +
- "if (!_matched) {\n" +
- " _switchResult = 1;\n" +
- "}\n" +
- "return _switchResult;\n");
+ compilesTo("""
+ {
+ switch x : 'lalala' as Object {
+ String, Integer case 1: 0
+ Integer, default: 1
+ }
+ }
+ """, """
+ int _switchResult = (int) 0;
+ final Object x = ((Object) "lalala");
+ boolean _matched = false;
+ if (x instanceof String) {
+ _matched=true;
+ }
+ if (!_matched) {
+ if (x instanceof Integer) {
+ if (com.google.common.base.Objects.equal(x, 1)) {
+ _matched=true;
+ }
+ }
+ }
+ if (_matched) {
+ _switchResult = 0;
+ }
+ if (!_matched) {
+ if (x instanceof Integer) {
+ _matched=true;
+ _switchResult = 1;
+ }
+ }
+ if (!_matched) {
+ _switchResult = 1;
+ }
+ return _switchResult;
+ """);
}
@Test
public void testFallThroughSwitch_8() throws Exception {
- compilesTo(
- "{\n" +
- " switch x : 1 as Object {\n" +
- " Integer,\n" +
- " Double: x\n" +
- " }\n" +
- "}\n",
- "\n" +
- "Number _switchResult = null;\n" +
- "final Object x = ((Object) Integer.valueOf(1));\n" +
- "boolean _matched = false;\n" +
- "if (x instanceof Integer) {\n" +
- " _matched=true;\n" +
- "}\n" +
- "if (!_matched) {\n" +
- " if (x instanceof Double) {\n" +
- " _matched=true;\n" +
- " }\n" +
- "}\n" +
- "if (_matched) {\n" +
- " _switchResult = ((Number)x);\n" +
- "}\n" +
- "return ((Number)_switchResult);\n");
+ compilesTo("""
+ {
+ switch x : 1 as Object {
+ Integer,
+ Double: x
+ }
+ }
+ """, """
+ Number _switchResult = null;
+ final Object x = ((Object) Integer.valueOf(1));
+ boolean _matched = false;
+ if (x instanceof Integer) {
+ _matched=true;
+ }
+ if (!_matched) {
+ if (x instanceof Double) {
+ _matched=true;
+ }
+ }
+ if (_matched) {
+ _switchResult = ((Number)x);
+ }
+ return ((Number)_switchResult);
+ """);
}
@Test
public void testEmptySwitch() throws Exception {
- compilesTo(
- "{\n" +
- " switch 1 {\n" +
- " }\n" +
- "}\n",
- "\n" +
- "Object _switchResult = null;\n" +
- "final int _switchValue = 1;\n" +
- "switch (_switchValue) {\n" +
- "}\n" +
- "return _switchResult;\n");
+ compilesTo("""
+ {
+ switch 1 {
+ }
+ }
+ """, """
+ Object _switchResult = null;
+ final int _switchValue = 1;
+ switch (_switchValue) {
+ }
+ return _switchResult;
+ """);
}
@Test
public void testEmptySwitch_2() throws Exception {
- compilesTo(
- "{\n" +
- " switch 1 {\n" +
- " default: {\n" +
- " }\n" +
- " }\n" +
- "}\n",
- "\n" +
- "Object _switchResult = null;\n" +
- "final int _switchValue = 1;\n" +
- "switch (_switchValue) {\n" +
- " default:\n" +
- " _switchResult = null;\n" +
- " break;\n" +
- "}\n" +
- "return _switchResult;\n");
+ compilesTo("""
+ {
+ switch 1 {
+ default: {
+ }
+ }
+ }
+ """, """
+ Object _switchResult = null;
+ final int _switchValue = 1;
+ switch (_switchValue) {
+ default:
+ _switchResult = null;
+ break;
+ }
+ return _switchResult;
+ """);
}
@Test
public void testEmptySwitch_3() throws Exception {
- compilesTo(
- "{\n" +
- " switch Object {\n" +
- " }\n" +
- "}\n",
- "\n" +
- "Object _switchResult = null;\n" +
- "final Class