Add tests for using namespace parts

This commit is contained in:
Gaith Hallak 2021-08-20 19:33:09 +03:00
parent c29e9a7b2e
commit 2d916733d8
4 changed files with 31 additions and 3 deletions

View File

@ -798,6 +798,14 @@ failing_contracts() ->
[<<?Pos(2,3)
"Cannot use undefined namespace MyUndefinedNamespace">>
])
, ?TYPE_ERROR(using_namespace_undefined_parts,
[<<?Pos(5,3)
"The namespace Nsp does not define the following names: a">>
])
, ?TYPE_ERROR(using_namespace_hidden_parts,
[<<?Pos(8,23)
"Unbound variable g at line 8, column 23">>
])
].
-define(Path(File), "code_errors/" ??File).

View File

@ -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"

View File

@ -0,0 +1,8 @@
namespace Nsp =
function f() = 1
function g() = 2
contract Cntr =
using Nsp for [f]
entrypoint init() = g()

View File

@ -0,0 +1,7 @@
namespace Nsp =
function f() = 1
contract Cntr =
using Nsp for [a]
entrypoint init() = f()