use of org.eclipse.xtend.core.xtend.XtendClass in project xtext-xtend by eclipse.
the class JavaConverterTest method testTryCatchCase_02.
@Test
public void testTryCatchCase_02() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("public void checkTryCatch() {");
_builder.newLine();
_builder.append("\t");
_builder.append("try {");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("} catch (IllegalArgumentException | IllegalStateException e) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("throw e;");
_builder.newLine();
_builder.append("\t");
_builder.append("} finally {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("System.out.println();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
final String javaBody = _builder.toString();
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class Test {");
_builder_1.append(javaBody);
_builder_1.append("}");
final XtendClass clazz = this.toValidXtendClass(_builder_1);
Assert.assertNotNull(clazz);
String body = this.toXtendClassBodyDeclr(javaBody);
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("def void checkTryCatch() {");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("try {");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("} catch (IllegalArgumentException | IllegalStateException e) {");
_builder_2.newLine();
_builder_2.append("\t\t");
_builder_2.append("throw e");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("} finally {");
_builder_2.newLine();
_builder_2.append("\t\t");
_builder_2.append("System.out.println() ");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("}");
Assert.assertEquals(_builder_2.toString(), body);
}
use of org.eclipse.xtend.core.xtend.XtendClass in project xtext-xtend by eclipse.
the class JavaConverterTest method testStaticAccessCase2.
@Test
public void testStaticAccessCase2() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("import java.util.Map;");
_builder.newLine();
_builder.append("import java.util.Map.Entry;");
_builder.newLine();
_builder.append("public abstract class Test implements Map.Entry<String,String>{}");
_builder.newLine();
XtendClass xtendClazz = this.toValidXtendClass(_builder);
Assert.assertNotNull(xtendClazz);
}
use of org.eclipse.xtend.core.xtend.XtendClass in project xtext-xtend by eclipse.
the class JavaConverterTest method testPrefixPlusMinusCase.
@Test
public void testPrefixPlusMinusCase() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("public class Clazz { ");
_builder.newLine();
_builder.append("\t");
_builder.append("public static main(String[] args) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("int i=3;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("System.out.print(\"4=\");");
_builder.newLine();
_builder.append("\t\t");
_builder.append("System.out.println(++i);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("System.out.print(\"3=\");");
_builder.newLine();
_builder.append("\t\t");
_builder.append("System.out.println(--i);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
XtendClass clazz = this.toValidXtendClass(_builder);
Assert.assertNotNull(clazz);
}
use of org.eclipse.xtend.core.xtend.XtendClass in project xtext-xtend by eclipse.
the class JavaConverterTest method testSimpleAssigmentCase.
@Test
public void testSimpleAssigmentCase() throws Exception {
XtendClass xtendClazz = this.toValidXtendClass("class TestAssiment { \n\t\t\t\tvoid doStuff() {\n\t\t\t\t\tString x = null;\n\t\t\t\t\tx = new String();\n\t\t\t\t}\n\t\t\t}");
Assert.assertNotNull(xtendClazz);
}
use of org.eclipse.xtend.core.xtend.XtendClass in project xtext-xtend by eclipse.
the class JavaConverterTest method testCastCase_02.
@Test
public void testCastCase_02() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("public class TestCast {");
_builder.newLine();
_builder.append("\t");
_builder.append("public void foo(long value) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("int x = (int) (value >>> 56) & 0xFF;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
XtendClass xtendClazz = this.toValidXtendClass(_builder);
Assert.assertNotNull(xtendClazz);
}
Aggregations