From 673fb67c1cc24cabddc8a51685f7ad7a7369efb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Sat, 9 May 2020 22:02:16 +0100 Subject: [PATCH] Added test case from GitLab issue --- src/bin/expect_tests/contract_tests.ml | 3 +++ src/test/contracts/issue-184-combs.mligo | 34 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/test/contracts/issue-184-combs.mligo diff --git a/src/bin/expect_tests/contract_tests.ml b/src/bin/expect_tests/contract_tests.ml index 7025aa1a2..d069c62aa 100644 --- a/src/bin/expect_tests/contract_tests.ml +++ b/src/bin/expect_tests/contract_tests.ml @@ -18,6 +18,9 @@ let%expect_test _ = run_ligo_good [ "measure-contract" ; contract "vote.mligo" ; "main" ] ; [%expect {| 582 bytes |}] ; + run_ligo_good [ "measure-contract" ; contract "issue-184-combs.mligo" ; "main2" ] ; + [%expect {| 369 bytes |}] ; + run_ligo_good [ "compile-parameter" ; contract "coase.ligo" ; "main" ; "Buy_single (record card_to_buy = 1n end)" ] ; [%expect {| (Left (Left 1)) |}] ; diff --git a/src/test/contracts/issue-184-combs.mligo b/src/test/contracts/issue-184-combs.mligo new file mode 100644 index 000000000..7c1ab6dd8 --- /dev/null +++ b/src/test/contracts/issue-184-combs.mligo @@ -0,0 +1,34 @@ +(* Test case from https://gitlab.com/ligolang/ligo/-/issues/184 *) + +type foo = { + bar : string; + baz : nat; +} + +type foo_michelson = foo michelson_pair_right_comb + +type union1 = +| Choice1 of foo +| Choice2 of foo + +type union1_aux = +| Option1 of foo_michelson +| Option2 of foo_michelson + +type union1_michelson = union1_aux michelson_or_right_comb + +let union1_from_michelson (m : union1_michelson) : union1 = + let aux : union1_aux = Layout.convert_from_right_comb m in + match aux with + | Option1 fm -> + let f : foo = Layout.convert_from_right_comb fm in + Choice1 f +| Option2 fm -> + let f : foo = Layout.convert_from_right_comb fm in + Choice2 f + +let main2 (ums, us : (union1_michelson list) * (union1 list)) = + let new_us = List.map union1_from_michelson ums in + ([] : operation list), new_us + +