From c9bcfc3ab036e9c4baf99dee3c0dbc08fc665a29 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Thu, 17 Oct 2019 17:33:29 +0200 Subject: [PATCH] higher order function test, pass two closure one calling the other as function arg --- src/test/contracts/high-order.ligo | 19 ++++++++++++++++--- src/test/integration_tests.ml | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/test/contracts/high-order.ligo b/src/test/contracts/high-order.ligo index 9059b1efb..44822f088 100644 --- a/src/test/contracts/high-order.ligo +++ b/src/test/contracts/high-order.ligo @@ -8,9 +8,9 @@ function foobar (const i : int) : int is // higher order function with more than one argument function higher2(const i: int; const f: int -> int): int is - block { - const ii: int = f(i) - } with ii + block { + const ii: int = f(i) + } with ii function foobar2 (const i : int) : int is function foo2 (const i : int) : int is @@ -34,3 +34,16 @@ function g (const i : int) : int is function foobar4 (const i : int) : int is block { skip } with g(g(i)) + +function higher3(const i: int; const f: int -> int; const g: int -> int): int is + block { + const ii: int = f(g(i)); + } with ii + +function foobar5 (const i : int) : int is + const a : int = 0; + function foo (const i : int) : int is + block { skip } with (a+i); + function goo (const i : int) : int is + block { skip } with foo(i); + block { skip } with higher3(i,foo,goo) diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index a7fc3858a..6726d66b5 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -115,6 +115,7 @@ let higher_order () : unit result = let%bind _ = expect_eq_n_int program "foobar2" make_expect in let%bind _ = expect_eq_n_int program "foobar3" make_expect in let%bind _ = expect_eq_n_int program "foobar4" make_expect in + let%bind _ = expect_eq_n_int program "foobar5" make_expect in ok () let shared_function () : unit result =