Skip to content

Commit

Permalink
also verify error position for INCOMPATIBLE_THROWS_CLAUSE (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Jan 16, 2024
1 parent a7e0cc7 commit aa24a7a
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public void testClassMustBeAbstract_06() throws Exception {
XtendClass xtendClass = clazz(source);
helper.assertError(xtendClass.getMembers().get(0), XTEND_FUNCTION, INCOMPATIBLE_THROWS_CLAUSE,
source.lastIndexOf("Exception"), "Exception".length(),
"Exception", "not", "compatible", "throws", "clause");
"Exception", "is not", "compatible", "throws", "clause");
}

@Test public void testIncompatibleThrowsClause_01() throws Exception {
Expand Down Expand Up @@ -512,7 +512,19 @@ public void testClassMustBeAbstract_06() throws Exception {
helper.assertError(xtendClass.getMembers().get(0), XTEND_FUNCTION, INCOMPATIBLE_THROWS_CLAUSE,
"Exception", "FileNotFoundException", "not", "compatible", "throws", "clause");
}


/**
* Two incompatible exceptions; the marker is on the first one
*/
@Test public void testIncompatibleThrowsClause_06() throws Exception {
var source = "class Foo extends test.ExceptionThrowing { override nullPointerException() throws java.io.IOException, java.io.FileNotFoundException {} }";
XtendClass xtendClass = clazz(source);
helper.assertError(xtendClass.getMembers().get(0), XTEND_FUNCTION, INCOMPATIBLE_THROWS_CLAUSE,
source.indexOf("java.io.IOException"), "java.io.IOException".length(),
"declared exceptions", "IOException", "FileNotFoundException",
"are not", "compatible", "throws", "clause");
}

@Test public void testCompatibleThrowsClause() throws Exception {
XtendClass xtendClass = clazz("class Foo extends test.ExceptionThrowing { override ioException() throws java.io.FileNotFoundException {} }");
helper.assertNoError(xtendClass.getMembers().get(0), INCOMPATIBLE_THROWS_CLAUSE);
Expand Down

0 comments on commit aa24a7a

Please sign in to comment.