use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class ValidationBug409602Test method test_01.
@Test
public void test_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if (\"\" == null) {");
_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("1");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
this.helper.assertError(file, XbasePackage.Literals.XNUMBER_LITERAL, IssueCodes.INVALID_INNER_EXPRESSION);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class ValidationBug409602Test method test_09.
@Test
public void test_09() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if (\"\" == null) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("return");
_builder.newLine();
_builder.append("\t\t");
_builder.append("} else {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("return 1");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
this.helper.assertError(file, XbasePackage.Literals.XRETURN_EXPRESSION, IssueCodes.INVALID_RETURN, "Void functions cannot return a value.");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class ValidationBug419050Test method test_02.
@Test
public void test_02() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def m(boolean b) { ");
_builder.newLine();
_builder.append("\t ");
_builder.append("var boolean y = false");
_builder.newLine();
_builder.append("\t ");
_builder.append("y = if (b) return true else return false");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
this.helper.assertError(file, XbasePackage.Literals.XASSIGNMENT, IssueCodes.UNREACHABLE_CODE);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class ValidationBug432193Test method test_09.
@Test
public void test_09() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("interface Bar<T extends Number> {");
_builder.newLine();
_builder.append("\t");
_builder.append("def String bar(Iterable<T> o) ");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("public Bar<? extends Integer> bar = [ Iterable<Integer> o | ");
_builder.newLine();
_builder.append("\t\t");
_builder.append("o.head");
_builder.newLine();
_builder.append("\t");
_builder.append("]");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
this.helper.assertError(file, XbasePackage.Literals.XMEMBER_FEATURE_CALL, IssueCodes.INCOMPATIBLE_TYPES, "Type mismatch: cannot convert from Integer to String");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class ValidationBug432193Test method test_12.
@Test
public void test_12() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void n(L<String> list) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("list.addListener [");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("LC<String> c |");
_builder.newLine();
_builder.append("\t\t");
_builder.append("]");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("interface O {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void addListener(IL listener)");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("interface L<E> extends O {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void addListener(LL<? super E> listener)");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("interface LL<E> {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void onChanged(LC<? extends E> c)");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("interface LC<E> {}");
_builder.newLine();
_builder.append("interface IL {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void invalidated(O o)");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
this.helper.assertError(file, XbasePackage.Literals.XCLOSURE, IssueCodes.INCOMPATIBLE_TYPES, "Type mismatch: cannot convert from (LC<String>)=>void to LL<? super String>");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations