test List.iter and List.map in cameligo

This commit is contained in:
galfour 2019-09-24 10:54:14 +02:00
parent 9c3c40c9ef
commit ac449d2cb3
2 changed files with 10 additions and 0 deletions

View File

@ -16,3 +16,11 @@ let%entry main (p : param) storage =
let fold_op (s : int list) : int = let fold_op (s : int list) : int =
let aggregate = fun (prec : int) (cur : int) -> prec + cur in let aggregate = fun (prec : int) (cur : int) -> prec + cur in
List.fold s 10 aggregate List.fold s 10 aggregate
let map_op (s : int list) : int list =
let aggregate = fun (cur : int) -> cur + 1 in
List.map s aggregate
let iter_op (s : int list) : unit =
let do_nothing = fun (cur : int) -> unit in
List.iter s do_nothing

View File

@ -699,6 +699,8 @@ let mligo_list () : unit result =
let%bind () = expect_eq_evaluate program "x" (e_list []) in let%bind () = expect_eq_evaluate program "x" (e_list []) in
let%bind () = expect_eq_evaluate program "y" (e_list @@ List.map e_int [3 ; 4 ; 5]) in let%bind () = expect_eq_evaluate program "y" (e_list @@ List.map e_int [3 ; 4 ; 5]) in
let%bind () = expect_eq_evaluate program "z" (e_list @@ List.map e_int [2 ; 3 ; 4 ; 5]) in let%bind () = expect_eq_evaluate program "z" (e_list @@ List.map e_int [2 ; 3 ; 4 ; 5]) in
let%bind () = expect_eq program "map_op" (aux [2 ; 3 ; 4 ; 5]) (aux [3 ; 4 ; 5 ; 6]) in
let%bind () = expect_eq program "iter_op" (aux [2 ; 3 ; 4 ; 5]) (e_unit ()) in
ok () ok ()
let lambda_mligo () : unit result = let lambda_mligo () : unit result =