ifaces: tests: check for interface collisions in ast (#13196)

* ifaces: tests: check for interface collisions in ast

We add a test to check for interface name collisions in the daml-lf AST.

CHANGELOG_BEGIN
CHANGELOG_END

* Update daml-lf/language/src/test/scala/com/digitalasset/daml/lf/language/AstSpec.scala

Co-authored-by: Remy <remy.haemmerle@daml.com>

Co-authored-by: Remy <remy.haemmerle@daml.com>
This commit is contained in:
Robin Krom 2022-03-08 15:08:48 +01:00 committed by GitHub
parent 1c4b767295
commit be6bbc82b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,6 +60,14 @@ class AstSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matchers {
key = None,
implements = VectorMap.empty,
)
def interface = DefInterface(
param = Name.assertFromString("x"),
precond = ETrue,
fixedChoices = Map.empty,
methods = Map.empty,
requires = Set.empty,
)
def exception = DefException(
message = eText
)
@ -137,6 +145,40 @@ class AstSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matchers {
)
}
"catch interface collisions" in {
Module.build(
name = modName1,
definitions = List(
defName("defName1") -> recordDef,
defName("defName2") -> recordDef,
),
interfaces = List(
defName("defName1") -> interface
),
exceptions = List.empty,
templates = List.empty,
featureFlags = FeatureFlags.default,
)
a[PackageError] shouldBe thrownBy(
Module.build(
name = modName1,
definitions = List(
defName("defName1") -> recordDef,
defName("defName2") -> recordDef,
),
interfaces = List(
defName("defName1") -> interface,
defName("defName1") -> interface,
),
templates = List.empty,
exceptions = List.empty,
featureFlags = FeatureFlags.default,
)
)
}
"catch exception collisions" in {
Module.build(
name = modName1,