From 2d916733d82e68397d9530adce77a465450bc22e Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Fri, 20 Aug 2021 19:33:09 +0300 Subject: [PATCH] Add tests for using namespace parts --- test/aeso_compiler_tests.erl | 8 ++++++++ test/contracts/using_namespace.aes | 11 ++++++++--- test/contracts/using_namespace_hidden_parts.aes | 8 ++++++++ test/contracts/using_namespace_undefined_parts.aes | 7 +++++++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 test/contracts/using_namespace_hidden_parts.aes create mode 100644 test/contracts/using_namespace_undefined_parts.aes diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index ab66966..72b10cc 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -798,6 +798,14 @@ failing_contracts() -> [<> ]) + , ?TYPE_ERROR(using_namespace_undefined_parts, + [<> + ]) + , ?TYPE_ERROR(using_namespace_hidden_parts, + [<> + ]) ]. -define(Path(File), "code_errors/" ??File). diff --git a/test/contracts/using_namespace.aes b/test/contracts/using_namespace.aes index ae20706..95d40e5 100644 --- a/test/contracts/using_namespace.aes +++ b/test/contracts/using_namespace.aes @@ -1,15 +1,20 @@ include "Option.aes" include "Pair.aes" include "String.aes" +include "Triple.aes" using Pair +using Triple hiding [fst, snd] namespace Nsp = using Option function h() = - let op = Some(2) - is_some(op) + let op = Some((2, 3, 4)) + if (is_some(op)) + thd(force(op)) == 4 + else + false contract Cntr = using Nsp @@ -24,7 +29,7 @@ contract Cntr = snd(p) function g() = - using String + using String for [concat] let s1 = "abc" let s2 = "def" diff --git a/test/contracts/using_namespace_hidden_parts.aes b/test/contracts/using_namespace_hidden_parts.aes new file mode 100644 index 0000000..5469e95 --- /dev/null +++ b/test/contracts/using_namespace_hidden_parts.aes @@ -0,0 +1,8 @@ +namespace Nsp = + function f() = 1 + function g() = 2 + +contract Cntr = + using Nsp for [f] + + entrypoint init() = g() diff --git a/test/contracts/using_namespace_undefined_parts.aes b/test/contracts/using_namespace_undefined_parts.aes new file mode 100644 index 0000000..a728641 --- /dev/null +++ b/test/contracts/using_namespace_undefined_parts.aes @@ -0,0 +1,7 @@ +namespace Nsp = + function f() = 1 + +contract Cntr = + using Nsp for [a] + + entrypoint init() = f()