tests for sets
This commit is contained in:
parent
b71309bfa2
commit
1a035f9713
@ -35,7 +35,6 @@ function for_collection_ (var nee : unit; var nuu : unit) : (int * string) is bl
|
|||||||
var acc : int := 0 ;
|
var acc : int := 0 ;
|
||||||
var st : string := "to" ;
|
var st : string := "to" ;
|
||||||
var mylist : list(int) := list 1 ; 1 ; 1 end ;
|
var mylist : list(int) := list 1 ; 1 ; 1 end ;
|
||||||
|
|
||||||
var init_record : (record st : string; acc : int end ) :=
|
var init_record : (record st : string; acc : int end ) :=
|
||||||
record st = st; acc = acc; end;
|
record st = st; acc = acc; end;
|
||||||
var folded_record : (record st : string; acc : int 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 ;
|
skip ;
|
||||||
st := folded_record.st ;
|
st := folded_record.st ;
|
||||||
acc := folded_record.acc ;
|
acc := folded_record.acc ;
|
||||||
|
|
||||||
} with (folded_record.acc , folded_record.st)
|
} 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 acc : int := 0 ;
|
||||||
var st : string := "to" ;
|
var st : string := "to" ;
|
||||||
// var toto : (string * string) := ("foo","bar") ;
|
|
||||||
|
|
||||||
var mylist : list(int) := list 1 ; 1 ; 1 end ;
|
var mylist : list(int) := list 1 ; 1 ; 1 end ;
|
||||||
|
|
||||||
for x : int in list mylist
|
for x : int in list mylist
|
||||||
begin
|
begin
|
||||||
// toto.1 := "r";
|
|
||||||
acc := acc + x ;
|
acc := acc + x ;
|
||||||
st := st^"to" ;
|
st := st^"to" ;
|
||||||
end
|
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)
|
} with (acc, st)
|
||||||
|
|
||||||
function dummy (const n : nat) : nat is block {
|
function dummy (const n : nat) : nat is block {
|
||||||
|
@ -667,7 +667,12 @@ let loop () : unit result =
|
|||||||
let%bind () =
|
let%bind () =
|
||||||
let input = e_unit () in
|
let input = e_unit () in
|
||||||
let expected = e_pair (e_int 3) (e_string "totototo") 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
|
in
|
||||||
ok ()
|
ok ()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user