From 503d8f771e3a7141047bc2d97c1156b513f3a0a5 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Fri, 21 Feb 2020 17:08:10 +0100 Subject: [PATCH] add tests for sum type names limit length --- src/bin/expect_tests/contract_tests.ml | 13 +++++++++++++ .../negative/long_sum_type_names.ligo | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/test/contracts/negative/long_sum_type_names.ligo diff --git a/src/bin/expect_tests/contract_tests.ml b/src/bin/expect_tests/contract_tests.ml index 49b1563d7..cb7095651 100644 --- a/src/bin/expect_tests/contract_tests.ml +++ b/src/bin/expect_tests/contract_tests.ml @@ -1139,6 +1139,19 @@ let%expect_test _ = storage (pair (map %one key_hash nat) (big_map %two key_hash bool)) ; code { DUP ; CDR ; NIL operation ; PAIR ; DIP { DROP } } } |}] +let%expect_test _ = + run_ligo_bad [ "compile-contract" ; bad_contract "long_sum_type_names.ligo" ; "main" ] ; + [%expect {| + ligo: Too long constructor 'Incrementttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt': names length is limited to 32 (tezos limitation) + + If you're not sure how to fix this error, you can + do one of the following: + + * Visit our documentation: https://ligolang.org/docs/intro/what-and-why/ + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] + let%expect_test _ = run_ligo_good [ "dry-run" ; contract "super-counter.mligo" ; "main" ; "test_param" ; "test_storage" ] ; [%expect {| diff --git a/src/test/contracts/negative/long_sum_type_names.ligo b/src/test/contracts/negative/long_sum_type_names.ligo new file mode 100644 index 000000000..71c9a4efe --- /dev/null +++ b/src/test/contracts/negative/long_sum_type_names.ligo @@ -0,0 +1,18 @@ +type action is +| Incrementttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt of int +// | Increment of int +| Decrement of int + +function add (const a : int ; const b : int) : int is a + b + +function subtract (const a : int ; const b : int) : int is a - b + +function main (const p : action ; const s : int) : (list(operation) * int) is + ((nil : list(operation)), + case p of + | Incrementttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt (n) -> add (s, n) + // | Increment(n) -> add (s, n) + | Decrement (n) -> subtract (s, n) + end) + +// incrementttttttttttttttttttttttt \ No newline at end of file