Skip to content

Commit

Permalink
also verify the error's position for hierarchy cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Dec 20, 2023
1 parent 00ef2ad commit a444ee7
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,11 @@ public void clearPreferences() {
}

@Test public void testClassExtendsItself() throws Exception {
XtendClass clazz = clazz("class Foo extends Foo {}");
helper.assertError(clazz, XTEND_CLASS, CYCLIC_INHERITANCE, "hierarchy", "cycles");
var source = "class Foo extends Foo {}";
XtendClass clazz = clazz(source);
helper.assertError(clazz, XTEND_CLASS, CYCLIC_INHERITANCE,
source.indexOf("Foo"), "Foo".length(),
"hierarchy", "cycles");
}

@Test public void testClassUniqueNames() throws Exception {
Expand Down Expand Up @@ -956,13 +959,20 @@ public void clearPreferences() {
}

@Test public void testInheritanceCycle() throws Exception {
Iterator<XtendTypeDeclaration> types = file("package test "
var source = "package test "
+ "class Foo extends Bar {}"
+ "class Bar extends Baz {}"
+ "class Baz extends Foo {}").getXtendTypes().iterator();
helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, "hierarchy", "cycles");
helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, "hierarchy", "cycles");
helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, "hierarchy", "cycles");
+ "class Baz extends Foo {}";
Iterator<XtendTypeDeclaration> types = file(source).getXtendTypes().iterator();
helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE,
source.indexOf("Foo"), "Foo".length(),
"hierarchy", "cycles");
helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE,
source.lastIndexOf("Bar"), "Bar".length(),
"hierarchy", "cycles");
helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE,
source.lastIndexOf("Baz"), "Baz".length(),
"hierarchy", "cycles");
}

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

0 comments on commit a444ee7

Please sign in to comment.