Skip to content

Commit

Permalink
also verify error position for constructors' errors
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Jan 4, 2024
1 parent 365f1fa commit 9b52cd7
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,19 @@ public void clearPreferences() {
}

@Test public void testMissingConstructor() throws Exception {
XtendClass clazz = clazz("class K extends test.NoDefaultConstructor {}");
helper.assertError(clazz, XTEND_CLASS, MISSING_CONSTRUCTOR);
var source = "class K extends test.NoDefaultConstructor {}";
XtendClass clazz = clazz(source);
helper.assertError(clazz, XTEND_CLASS, MISSING_CONSTRUCTOR,
source.indexOf("K"), 1,
"must define an explicit constructor");
}

@Test public void testMissingSuperConstructorCall() throws Exception {
XtendClass clazz = clazz("class K extends test.NoDefaultConstructor { new() {} }");
helper.assertError(clazz, XTEND_CONSTRUCTOR, MUST_INVOKE_SUPER_CONSTRUCTOR);
var source = "class K extends test.NoDefaultConstructor { new() {} }";
XtendClass clazz = clazz(source);
helper.assertError(clazz, XTEND_CONSTRUCTOR, MUST_INVOKE_SUPER_CONSTRUCTOR,
source.indexOf("new() {}"), "new() {}".length(),
"Another constructor must be invoked explicitly");
}

@Test public void testSuperConstructorCall() throws Exception {
Expand Down

0 comments on commit 9b52cd7

Please sign in to comment.