Skip to content

Commit

Permalink
also verify error's message parts for duplicate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Dec 20, 2023
1 parent 09635c7 commit b5a41cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public class OverrideValidationTest extends AbstractXtendTestCase {
XtendClass xtendClass = clazz(source);
helper.assertError(xtendClass.getMembers().get(0), XTEND_FUNCTION, DUPLICATE_METHOD,
source.indexOf("bar"), "bar".length(),
"duplicate");
"duplicate", "method");
helper.assertError(xtendClass.getMembers().get(0), XTEND_FUNCTION, DUPLICATE_METHOD,
source.lastIndexOf("bar"), "bar".length(),
"duplicate");
"duplicate", "method");
}

@Test public void testDuplicateMethod_1() throws Exception {
Expand All @@ -56,9 +56,11 @@ public class OverrideValidationTest extends AbstractXtendTestCase {

@Test public void testDuplicateMethod_3() throws Exception {
XtendClass xtendClass = clazz("class Foo { def bar(java.util.List<String> x) {true} def bar(java.util.List<Integer> x) {false} }");
helper.assertError(xtendClass.getMembers().get(0), XTEND_FUNCTION, DUPLICATE_METHOD, "erasure", "List)",
helper.assertError(xtendClass.getMembers().get(0), XTEND_FUNCTION, DUPLICATE_METHOD,
"erasure", "List)", "method",
"List<String");
helper.assertError(xtendClass.getMembers().get(1), XTEND_FUNCTION, DUPLICATE_METHOD, "erasure", "List)",
helper.assertError(xtendClass.getMembers().get(1), XTEND_FUNCTION, DUPLICATE_METHOD,
"erasure", "List)", "method",
"List<Integer");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,22 @@ public void clearPreferences() {
var source = "class K { new(Object o) {} new(Object o) {} }";
XtendClass clazz = clazz(source);
helper.assertError(clazz, XTEND_CONSTRUCTOR, DUPLICATE_METHOD,
source.indexOf("new(Object o) {}"), "new(Object o) {}".length());
source.indexOf("new(Object o) {}"), "new(Object o) {}".length(),
"Duplicate", "constructor");
helper.assertError(clazz, XTEND_CONSTRUCTOR, DUPLICATE_METHOD,
source.lastIndexOf("new(Object o) {}"), "new(Object o) {}".length());
source.lastIndexOf("new(Object o) {}"), "new(Object o) {}".length(),
"Duplicate", "constructor");
}

@Test public void testConstructorDuplicateErasure() throws Exception {
var source = "class K { new(java.util.List<Object> o) {} new(java.util.List<String> o) {} }";
XtendClass clazz = clazz(source);
helper.assertError(clazz, XTEND_CONSTRUCTOR, DUPLICATE_METHOD,
source.indexOf("new(java.util.List<Object> o) {}"), "new(java.util.List<Object> o) {}".length());
source.indexOf("new(java.util.List<Object> o) {}"), "new(java.util.List<Object> o) {}".length(),
"erasure", "constructor", "List<Object>");
helper.assertError(clazz, XTEND_CONSTRUCTOR, DUPLICATE_METHOD,
source.indexOf("new(java.util.List<String> o) {}"), "new(java.util.List<String> o) {}".length());
source.indexOf("new(java.util.List<String> o) {}"), "new(java.util.List<String> o) {}".length(),
"erasure", "constructor", "List<String>");
}

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

0 comments on commit b5a41cb

Please sign in to comment.