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 8, 2024
1 parent d017375 commit 96d25ab
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 96d25ab

Please sign in to comment.