add test case (#14882)

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Chun Lok Ling 2022-08-31 11:28:59 +01:00 committed by GitHub
parent 00fe14c6a5
commit bb4a17e345
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 0 deletions

View File

@ -25,6 +25,7 @@ daml_compile(
srcs = [
"src/main/daml/MyMain.daml",
"src/main/daml/MyMainIface.daml",
"src/main/daml/MyMainIfaceRetro.daml",
],
target = lf_version_configuration.get(tested_lf_config),
)

View File

@ -0,0 +1,20 @@
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module MyMainIfaceRetro where
import qualified MyMain
data EmptyInterfaceView = EmptyInterfaceView {}
interface MyMainIfaceRetro where
viewtype EmptyInterfaceView
getOwner: Party
choice Retro: Int with
sth: Int
controller getOwner this
do return $ sth + 1
interface instance MyMainIfaceRetro for MyMain.InterfaceMixer where
view = EmptyInterfaceView
getOwner = party

View File

@ -92,10 +92,15 @@ class DataTypeIT extends AnyWordSpec with Matchers {
val sleId: P.ContractId[MyMain.SimpleListExample] = P.ContractId("fakesle")
val imId: P.ContractId[MyMain.InterfaceMixer] = P.ContractId("fakeimid")
val itmId: P.ContractId[MyMainIface.IfaceFromAnotherMod] = P.ContractId("fakeitmid")
val itrmId: P.ContractId[MyMainIfaceRetro.MyMainIfaceRetro] = P.ContractId("fakeitrmid")
"coerce from template to interface" in {
val ifId = imId.toInterface[MyMainIface.IfaceFromAnotherMod]
(ifId: MyMainIface.IfaceFromAnotherMod.ContractId) should ===(imId)
val ifRetroId = imId.toInterface[MyMainIfaceRetro.MyMainIfaceRetro]
(ifRetroId: MyMainIfaceRetro.MyMainIfaceRetro.ContractId) should ===(imId)
illTyped(
"sleId.toInterface[MyMainIface.IfaceFromAnotherMod]",
"com.daml.sample.MyMain.SimpleListExample is not a template that implements interface com.daml.sample.MyMainIface.IfaceFromAnotherMod",
@ -109,6 +114,10 @@ class DataTypeIT extends AnyWordSpec with Matchers {
"coerce from interface to template" in {
val tpId = itmId.unsafeToTemplate[MyMain.InterfaceMixer]
(tpId: MyMain.InterfaceMixer.ContractId) should ===(itmId)
val tpIdRetro = itrmId.unsafeToTemplate[MyMain.InterfaceMixer]
(tpIdRetro: MyMain.InterfaceMixer.ContractId) should ===(itrmId)
illTyped(
"itmId.unsafeToTemplate[MyMain.SimpleListExample]",
".*SimpleListExample is not a template that implements interface .*IfaceFromAnotherMod",