higher order function test, pass two closure one calling the other as function arg
This commit is contained in:
parent
9f0b61659e
commit
c9bcfc3ab0
@ -8,9 +8,9 @@ function foobar (const i : int) : int is
|
|||||||
|
|
||||||
// higher order function with more than one argument
|
// higher order function with more than one argument
|
||||||
function higher2(const i: int; const f: int -> int): int is
|
function higher2(const i: int; const f: int -> int): int is
|
||||||
block {
|
block {
|
||||||
const ii: int = f(i)
|
const ii: int = f(i)
|
||||||
} with ii
|
} with ii
|
||||||
|
|
||||||
function foobar2 (const i : int) : int is
|
function foobar2 (const i : int) : int is
|
||||||
function foo2 (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
|
function foobar4 (const i : int) : int is
|
||||||
block { skip }
|
block { skip }
|
||||||
with g(g(i))
|
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)
|
||||||
|
@ -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 "foobar2" make_expect in
|
||||||
let%bind _ = expect_eq_n_int program "foobar3" 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 "foobar4" make_expect in
|
||||||
|
let%bind _ = expect_eq_n_int program "foobar5" make_expect in
|
||||||
ok ()
|
ok ()
|
||||||
|
|
||||||
let shared_function () : unit result =
|
let shared_function () : unit result =
|
||||||
|
Loading…
Reference in New Issue
Block a user