diff --git a/src/test/contracts/loop.ligo b/src/test/contracts/loop.ligo index d96753105..eaa429df7 100644 --- a/src/test/contracts/loop.ligo +++ b/src/test/contracts/loop.ligo @@ -35,7 +35,6 @@ function for_collection_ (var nee : unit; var nuu : unit) : (int * string) is bl var acc : int := 0 ; var st : string := "to" ; var mylist : list(int) := list 1 ; 1 ; 1 end ; - var init_record : (record st : string; acc : int end ) := record st = st; acc = acc; end; var folded_record : (record st : string; acc : int end ) := @@ -43,23 +42,28 @@ function for_collection_ (var nee : unit; var nuu : unit) : (int * string) is bl skip ; st := folded_record.st ; acc := folded_record.acc ; - } with (folded_record.acc , folded_record.st) -function for_collection (var nee : unit) : (int * string) is block { +function for_collection_list (var nee : unit) : (int * string) is block { var acc : int := 0 ; var st : string := "to" ; - // var toto : (string * string) := ("foo","bar") ; - var mylist : list(int) := list 1 ; 1 ; 1 end ; - for x : int in list mylist begin - // toto.1 := "r"; acc := acc + x ; st := st^"to" ; end +} with (acc, st) +function for_collection_set (var nee : unit) : (int * string) is block { + var acc : int := 0 ; + var st : string := "to" ; + var myset : set(int) := set 1 ; 2 ; 3 end ; + for x : int in set myset + begin + acc := acc + x ; + st := st^"to" ; + end } with (acc, st) function dummy (const n : nat) : nat is block { diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index dbd388cdd..3ed6d871e 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -667,7 +667,12 @@ let loop () : unit result = let%bind () = let input = e_unit () in let expected = e_pair (e_int 3) (e_string "totototo") in - expect_eq program "for_collection" input expected + expect_eq program "for_collection_list" input expected + in + let%bind () = + let input = e_unit () in + let expected = e_pair (e_int 6) (e_string "totototo") in + expect_eq program "for_collection_set" input expected in ok ()