Merge branch 'test/cameligo-closure' into 'dev'

Add CameLIGO closure test

See merge request ligolang/ligo!155
This commit is contained in:
John David Pressman 2019-11-21 14:53:31 +00:00
commit 8b1b9bed82
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,9 @@
(* Test whether closures retain values in CameLIGO *)
let test (k: int) : int =
let j: int = k + 5 in
let close: (int -> int) =
fun (i: int) -> i + j
in
let j: int = 20 in (* Shadow original variable to see if value close'd *)
close 20

View File

@ -134,6 +134,15 @@ let closure () : unit result =
in
ok ()
let closure_mligo () : unit result =
let%bind program = mtype_file "./contracts/closure.mligo" in
let%bind _ =
let input = e_int 0 in
let expected = e_int 25 in
expect_eq program "test" input expected
in
ok ()
let shadow () : unit result =
let%bind program = type_file "./contracts/shadow.ligo" in
let make_expect = fun _ -> 0 in
@ -1269,6 +1278,7 @@ let main = test_suite "Integration (End to End)" [
test "anon function" anon_function ;
test "various applications" application ;
test "closure" closure ;
test "closure (mligo)" closure_mligo ;
test "shared function" shared_function ;
test "shared function (mligo)" shared_function_mligo ;
test "higher order" higher_order ;