Skip to content

Commit

Permalink
tests for duplicate interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Feb 5, 2024
1 parent e550177 commit 48fde74
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,32 @@ public class JvmGenericTypeValidatorTest {
"Extended", "interface");
}

@Test public void testDuplicateImplementedInterfaces() throws Exception {
var source = "import java.io.Serializable\n"
+ "class Foo implements "
+ "Serializable, java.io.Serializable, Cloneable, Serializable {}";
var model = parse(source);
validationHelper.assertError(model, MY_CLASS, DUPLICATE_INTERFACE,
source.lastIndexOf("java.io.Serializable"), "java.io.Serializable".length(),
"Duplicate interface Serializable for the type Foo");
validationHelper.assertError(model, MY_CLASS, DUPLICATE_INTERFACE,
source.lastIndexOf("Serializable"), "Serializable".length(),
"Duplicate interface Serializable for the type Foo");
}

@Test public void testDuplicateExtendedInterfaces() throws Exception {
var source = "import java.io.Serializable\n"
+ "interface Foo extends "
+ "Serializable, java.io.Serializable, Cloneable, Serializable {}";
var model = parse(source);
validationHelper.assertError(model, MY_INTERFACE, DUPLICATE_INTERFACE,
source.lastIndexOf("java.io.Serializable"), "java.io.Serializable".length(),
"Duplicate interface Serializable for the type Foo");
validationHelper.assertError(model, MY_INTERFACE, DUPLICATE_INTERFACE,
source.lastIndexOf("Serializable"), "Serializable".length(),
"Duplicate interface Serializable for the type Foo");
}

@Test public void testCheckSuperTypesWithClassWithSuperTypes() throws Exception {
// the first supertype must be a class, and then the other ones interfaces
var source = "classWithSuperTypes Foo superTypes Cloneable, Object {}";
Expand Down

0 comments on commit 48fde74

Please sign in to comment.