Add a test for the conversion of (nested) record updates to DAML-LF (#6915)

* Add a test for the conversion of (nested) record updates to DAML-LF

The new tests check that we generate the DAML-LF we intend to generate,
namely code using `ERecUpd` AST nodes rather than calls to the
`setField` function.

CHANGELOG_BEGIN
CHANGELOG_END

* Use get_value_name instead of get_dotted_name

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Martin Huschenbett 2020-07-29 15:13:17 +02:00 committed by GitHub
parent f1a83448d5
commit 76e5df6369
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,8 +3,8 @@
-- @INFO range=43:17-43:41; Evaluate
-- @INFO range=43:24-43:40; Use const
-- @ QUERY-LF .modules[] | .values[] | select(.name_with_type | lf::get_value_name($pkg) == ["p_1_0"]) | .expr.rec_upd | (lf::get_field($pkg) == "x") and (.record.val | lf::get_value_name($pkg) == ["origin"]) and (.update.prim_lit.int64 == "1")
-- xx @ QUERY-LF .modules[] | .values[] | select(.name_with_type | lf::get_value_name($pkg) == ["p_1_2"]) | .expr.rec_upd | (lf::get_field($pkg) == "y") and (.record.rec_upd | (lf::get_field($pkg) == "x") and (.record.val | lf::get_value_name($pkg) == ["origin"]) and (.update.prim_lit.int64 == "1")) and (.update.prim_lit.int64 == "2")
module RecordUpdate where
@ -51,3 +51,20 @@ main3 = scenario do
let b = (1,2,"test")
show b{_1=4, _3="new"} === "(4,2,\"new\")"
-- NOTE(MH): Check that the code generated for record updates uses the
-- `ERecUpd` AST node.
data Point = Point with
x: Int
y: Int
origin = Point with x = 0; y = 0
-- NOTE(MH): We expect this to become
-- `ERecUpd _ "x" (EVal ["origin"]) (EBuiltin (BEInt64 1))`
-- modulo location information.
p_1_0 = origin with x = 1
-- NOTE(MH): We expect this to become
-- `ERecUpd _ "y" (ERecUpd _ "x" (EVal ["origin"]) (EBuiltin (BEInt64 1))) (EBuiltin (BEInt64 2))`
-- modulo location information.
p_1_2 = origin with x = 1; y = 2