tests for sets

This commit is contained in:
Lesenechal Remi 2019-10-27 14:12:42 +01:00
parent b71309bfa2
commit 1a035f9713
2 changed files with 17 additions and 8 deletions

View File

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

View File

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