From 8ce4772ae4f202f177726eb4a21757a37ae7654f Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Mon, 6 Jan 2020 18:51:43 +0100 Subject: [PATCH] add tests --- src/bin/expect_tests/contract_tests.ml | 10 +++++++++- src/test/contracts/double_main.ligo | 8 ++++++++ src/test/contracts/redeclaration.ligo | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/test/contracts/double_main.ligo create mode 100644 src/test/contracts/redeclaration.ligo diff --git a/src/bin/expect_tests/contract_tests.ml b/src/bin/expect_tests/contract_tests.ml index b9b34c076..97516018e 100644 --- a/src/bin/expect_tests/contract_tests.ml +++ b/src/bin/expect_tests/contract_tests.ml @@ -943,4 +943,12 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; contract "bad_timestamp.ligo" ; "main" ] ; - [%expect {| ligo: in file "bad_timestamp.ligo", line 5, characters 29-43. Badly formatted timestamp "badtimestamp": {"location":"in file \"bad_timestamp.ligo\", line 5, characters 29-43"} |}] \ No newline at end of file + [%expect {| ligo: in file "bad_timestamp.ligo", line 5, characters 29-43. Badly formatted timestamp "badtimestamp": {"location":"in file \"bad_timestamp.ligo\", line 5, characters 29-43"} |}] + +let%expect_test _ = + run_ligo_good [ "dry-run" ; contract "redeclaration.ligo" ; "main" ; "unit" ; "0" ] ; + [%expect {|( [] , 0 ) |}] + +let%expect_test _ = + run_ligo_good [ "dry-run" ; contract "double_main.ligo" ; "main" ; "unit" ; "0" ] ; + [%expect {|( [] , 2 ) |}] \ No newline at end of file diff --git a/src/test/contracts/double_main.ligo b/src/test/contracts/double_main.ligo new file mode 100644 index 000000000..6ad75dd80 --- /dev/null +++ b/src/test/contracts/double_main.ligo @@ -0,0 +1,8 @@ +function main(const p : unit; const s : int) : list(operation) * int is + ((list end : list(operation)), s + 1) + +function main(const p : unit; const s : int) : list(operation) * int is + begin + const ret : list(operation) * int = main(p, s) + end + with (ret.0, ret.1 + 1) \ No newline at end of file diff --git a/src/test/contracts/redeclaration.ligo b/src/test/contracts/redeclaration.ligo new file mode 100644 index 000000000..c74594ad3 --- /dev/null +++ b/src/test/contracts/redeclaration.ligo @@ -0,0 +1,6 @@ +function foo(const p : unit) : int is 0 + +function main(const p : unit; const s : int) : list(operation) * int is + ((list end : list(operation)), foo(unit)) + +function foo(const p : unit) : int is 1 \ No newline at end of file