Add Map.add to test suite
This commit is contained in:
parent
be658bd65e
commit
6d421ab4b1
@ -20,6 +20,7 @@ function set_ (var n : int ; var m : foobar) : foobar is block {
|
||||
m[23] := n ;
|
||||
} with m
|
||||
|
||||
function add (var n : int ; var m : foobar) : foobar is set_(n,m)
|
||||
|
||||
function rm (var m : foobar) : foobar is block {
|
||||
remove 42 from map m
|
||||
|
@ -11,6 +11,8 @@ let set_2 (n: int) (m: foobar) : foobar = Map.update 23 (Some n) m
|
||||
|
||||
let set_ (t: int * foobar) : foobar = set_2 t.0 t.1
|
||||
|
||||
let add (n,m: int * foobar) : foobar = Map.add 23 n m
|
||||
|
||||
let rm (m: foobar) : foobar = Map.remove 42 m
|
||||
|
||||
(* Dummy test so that we can add the same test for PascaLIGO *)
|
||||
@ -30,7 +32,7 @@ let gf (m: foobar) : int = Map.find 23 m
|
||||
let get (m: foobar) : int option = Map.find_opt 42 m
|
||||
let get_ (m: foobar) : int option = Map.find_opt 42 m
|
||||
|
||||
let mem (km: int * foobar) : bool = Map.mem km.0 km.1
|
||||
let mem (k,m: int * foobar) : bool = Map.mem k m
|
||||
|
||||
let iter_op (m : foobar) : unit =
|
||||
let assert_eq = fun (i: int * int) -> assert (i.0 = i.1)
|
||||
|
@ -10,6 +10,8 @@ let map2: foobar = Map.literal([(23, 0), (42, 0)]);
|
||||
|
||||
let set_ = (n: int, m: foobar): foobar => Map.update(23, Some(n), m);
|
||||
|
||||
let add = (n: int, m: foobar) : foobar => Map.add(23, n, m);
|
||||
|
||||
let rm = (m: foobar): foobar => Map.remove(42, m);
|
||||
|
||||
/* Dummy test so that we can add the same test for PascaLIGO */
|
||||
|
@ -974,6 +974,11 @@ let map_ type_f path : unit result =
|
||||
let make_expected = fun n -> ez [(23 , n) ; (42 , 0)] in
|
||||
expect_eq_n_pos_small program "set_" make_input make_expected
|
||||
in
|
||||
let%bind () =
|
||||
let input = (e_pair (e_int 23) (ez [(42, 42)])) in
|
||||
let expected = ez [(23, 23) ; (42, 42)] in
|
||||
expect_eq program "add" input expected
|
||||
in
|
||||
let%bind () =
|
||||
let input = ez [(23, 23) ; (42, 42)] in
|
||||
let expected = ez [23, 23] in
|
||||
|
Loading…
Reference in New Issue
Block a user