mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 17:28:46 +03:00
parent
00fe14c6a5
commit
bb4a17e345
@ -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),
|
||||
)
|
||||
|
@ -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
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user