use of org.eclipse.xtend.core.xtend.XtendClass in project xtext-xtend by eclipse.
the class JavaConverterTest method testXORExpressionCase.
@Test
public void testXORExpressionCase() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("public class XorCase {");
_builder.newLine();
_builder.append("\t");
_builder.append("public void doXorOperation() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("boolean b = true;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(true ^ b) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("return;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(b ^ b) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("return;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(b ^ false) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("return;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("int i = 1;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if (((1 ^ 2 ^ 4) + (i ^ 2) - (3 ^ i) ^ 2) > i) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("return;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("}");
final String java = _builder.toString();
XtendClass clazz = this.toValidXtendClass(java);
Assert.assertNotNull(clazz);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class XorCase {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def void doXorOperation() {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("var boolean b=true ");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("if (true.xor(b)) {");
_builder_1.newLine();
_builder_1.append("\t\t\t");
_builder_1.append("return;");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("if (b.xor(b)) {");
_builder_1.newLine();
_builder_1.append("\t\t\t");
_builder_1.append("return;");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("if (b.xor(false)) {");
_builder_1.newLine();
_builder_1.append("\t\t\t");
_builder_1.append("return;");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("var int i=1 ");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("if (((1.bitwiseXor(2).bitwiseXor(4)) + (i.bitwiseXor(2)) - (3.bitwiseXor(i)).bitwiseXor(2)) > i) {");
_builder_1.newLine();
_builder_1.append("\t\t\t");
_builder_1.append("return;");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("}");
Assert.assertEquals(_builder_1.toString(), this.toXtendCode(java));
}
use of org.eclipse.xtend.core.xtend.XtendClass in project xtext-xtend by eclipse.
the class JavaConverterTest method testEnumCase1.
@Test
public void testEnumCase1() throws Exception {
XtendClass enum_ = this.toValidXtendClass("public class MyClazz{\n\t \t\t\tenum MyEnum { NEW }\n\t\t\t}");
XtendMember _get = enum_.getMembers().get(0);
Assert.assertEquals(JvmVisibility.DEFAULT, ((XtendEnum) _get).getVisibility());
}
use of org.eclipse.xtend.core.xtend.XtendClass in project xtext-xtend by eclipse.
the class JavaConverterTest method testNumberLiteralCase.
@Test
public void testNumberLiteralCase() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class TestStringLiteral {");
_builder.newLine();
_builder.append("\t");
_builder.append("long l= 0x0000000000000000L;");
_builder.newLine();
_builder.append("\t");
_builder.append("double d= 2.5d;");
_builder.newLine();
_builder.append("\t");
_builder.append("long l2= 0x000000000000A;");
_builder.newLine();
_builder.append("\t");
_builder.append("long l3= 0x000000000000B;");
_builder.newLine();
_builder.append("\t");
_builder.append("long l4= 0x000000000000c;");
_builder.newLine();
_builder.append("\t");
_builder.append("long l5= 0x000000000000d;");
_builder.newLine();
_builder.append("\t");
_builder.append("long l6= 0x000000000000e;");
_builder.newLine();
_builder.append("\t");
_builder.append("long l7= 0x000000000000f;");
_builder.newLine();
_builder.append("}");
XtendClass xtendClazz = this.toValidXtendClass(_builder);
XtendField xtendMember = this.field(xtendClazz, 0);
Assert.assertEquals("l", xtendMember.getName());
XExpression _initialValue = xtendMember.getInitialValue();
Assert.assertEquals("0x0000000000000000#L", ((XNumberLiteral) _initialValue).getValue());
xtendMember = this.field(xtendClazz, 1);
Assert.assertEquals("d", xtendMember.getName());
XExpression _initialValue_1 = xtendMember.getInitialValue();
Assert.assertEquals("2.5d", ((XNumberLiteral) _initialValue_1).getValue());
}
use of org.eclipse.xtend.core.xtend.XtendClass in project xtext-xtend by eclipse.
the class JavaConverterTest method testArrayPrefixMinusCase.
@Test
public void testArrayPrefixMinusCase() 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("int[] ints = new int[]{1,2,3,4,5};");
_builder.newLine();
_builder.append("\t\t");
_builder.append("System.out.print(\"2=\"+(--ints[--i]));");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
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 testStaticImportCase.
@Test
public void testStaticImportCase() throws Exception {
XtendClass xtendClazz = this.toValidXtendClass("import static java.awt.AWTEvent.*; public class Test { long o= ACTION_EVENT_MASK;}");
XtendMember _get = xtendClazz.getMembers().get(0);
XtendField xtendMember = ((XtendField) _get);
Assert.assertEquals("o", xtendMember.getName());
XExpression _initialValue = xtendMember.getInitialValue();
XFeatureCall xFeatureCall = ((XFeatureCall) _initialValue);
Assert.assertEquals("ACTION_EVENT_MASK", xFeatureCall.getFeature().getSimpleName());
}
Aggregations