Skip to content

Commit

Permalink
testInheritanceCycle
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Feb 5, 2024
1 parent 4ddfa6f commit df5de3a
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,23 @@ public class JvmGenericTypeValidatorTest {
validationHelper.assertNoErrors(model);
}

@Test public void testInheritanceCycle() throws Exception {
var source = "package test "
+ "class Foo extends Bar {}"
+ "class Bar extends Baz {}"
+ "class Baz extends Foo {}";
var model = parse(source);
validationHelper.assertError(model, MY_CLASS, CYCLIC_INHERITANCE,
source.indexOf("Foo"), "Foo".length(),
"hierarchy", "cycles");
validationHelper.assertError(model, MY_CLASS, CYCLIC_INHERITANCE,
source.lastIndexOf("Bar"), "Bar".length(),
"hierarchy", "cycles");
validationHelper.assertError(model, MY_CLASS, CYCLIC_INHERITANCE,
source.lastIndexOf("Baz"), "Baz".length(),
"hierarchy", "cycles");
}

private JvmGenericTypeValidatorTestLangModel parse(CharSequence programText) throws Exception {
return parseHelper.parse(programText);
}
Expand Down

0 comments on commit df5de3a

Please sign in to comment.