From 9540c7d2004a215d229d31cb0b81f307ab8d545c Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Fri, 13 Aug 2021 12:01:34 +0300 Subject: [PATCH] Add tests --- test/aeso_compiler_tests.erl | 2 ++ test/contracts/assign_pattern_to_pattern.aes | 4 ++++ test/contracts/assign_patterns.aes | 16 ++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 test/contracts/assign_pattern_to_pattern.aes create mode 100644 test/contracts/assign_patterns.aes diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index 72b10cc..1af71da 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -201,6 +201,7 @@ compilable_contracts() -> "create", "child_contract_init_bug", "using_namespace", + "assign_patterns", "test" % Custom general-purpose test file. Keep it last on the list. ]. @@ -236,6 +237,7 @@ failing_contracts() -> , ?PARSE_ERROR(vsemi, [<>]) , ?PARSE_ERROR(vclose, [<>]) , ?PARSE_ERROR(indent_fail, [<>]) + , ?PARSE_ERROR(assign_pattern_to_pattern, [<>]) %% Type errors , ?TYPE_ERROR(name_clash, diff --git a/test/contracts/assign_pattern_to_pattern.aes b/test/contracts/assign_pattern_to_pattern.aes new file mode 100644 index 0000000..7882f92 --- /dev/null +++ b/test/contracts/assign_pattern_to_pattern.aes @@ -0,0 +1,4 @@ +contract AssignPatternToPattern = + entrypoint f() = + let x::(t::z = y) = [1, 2, 3] + (x + t)::y \ No newline at end of file diff --git a/test/contracts/assign_patterns.aes b/test/contracts/assign_patterns.aes new file mode 100644 index 0000000..2d9a784 --- /dev/null +++ b/test/contracts/assign_patterns.aes @@ -0,0 +1,16 @@ +include "List.aes" + +contract AssignPatterns = + + entrypoint test() = foo([1, 0, 2], (2, Some(3)), Some([4, 5])) + + entrypoint foo(xs : list(int), p : int * option(int), some : option(list(int))) = + let x::(t = y::_) = xs + let z::_ = t + + let (a, (o = Some(b))) = p + + let Some((f = g::_)) = some + g + List.get(1, f) + + x + y + z + a + b