From ac449d2cb3dd15b1c94cbcc30d39ed49388d554b Mon Sep 17 00:00:00 2001 From: galfour Date: Tue, 24 Sep 2019 10:54:14 +0200 Subject: [PATCH] test List.iter and List.map in cameligo --- src/test/contracts/list.mligo | 8 ++++++++ src/test/integration_tests.ml | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/test/contracts/list.mligo b/src/test/contracts/list.mligo index 10d9dcf91..77bd98fc2 100644 --- a/src/test/contracts/list.mligo +++ b/src/test/contracts/list.mligo @@ -16,3 +16,11 @@ let%entry main (p : param) storage = let fold_op (s : int list) : int = let aggregate = fun (prec : int) (cur : int) -> prec + cur in 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 diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 85e02d22d..1b6f96ce7 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -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 "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 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 () let lambda_mligo () : unit result =