Skip to content

Commit

Permalink
Added an Xtend validator test for cycles in internal types
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Jan 8, 2024
1 parent cd0c81e commit 813fbdd
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -996,13 +996,29 @@ public void clearPreferences() {
+ "class Foo implements Bar { interface I {} }"
+ "interface Bar extends Foo.I {}").getXtendTypes().iterator();
helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, "hierarchy", "cycles");
helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, "hierarchy", "cycles");
}

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

@Test public void testInheritanceCycle_6() throws Exception {
Iterator<XtendTypeDeclaration> types = file("package test "
+ "class Container {"
+ " interface Foo extends Bar {}"
+ " interface Bar extends Baz {}"
+ " interface Baz extends Foo {}"
+ "}").getXtendTypes().iterator();
var container = types.next();
var internalTypes = container.getMembers().iterator();
helper.assertError(internalTypes.next(), XTEND_INTERFACE, CYCLIC_INHERITANCE, "hierarchy", "cycles");
helper.assertError(internalTypes.next(), XTEND_INTERFACE, CYCLIC_INHERITANCE, "hierarchy", "cycles");
helper.assertError(internalTypes.next(), XTEND_INTERFACE, CYCLIC_INHERITANCE, "hierarchy", "cycles");
}

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

0 comments on commit 813fbdd

Please sign in to comment.