higher order function test, pass two closure one calling the other as function arg

This commit is contained in:
Lesenechal Remi 2019-10-17 17:33:29 +02:00
parent 9f0b61659e
commit c9bcfc3ab0
2 changed files with 17 additions and 3 deletions

View File

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

View File

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