diff --git a/src/test/contracts/map.ligo b/src/test/contracts/map.ligo index 797bb1a8b..f6c63598b 100644 --- a/src/test/contracts/map.ligo +++ b/src/test/contracts/map.ligo @@ -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 diff --git a/src/test/contracts/map.mligo b/src/test/contracts/map.mligo index 15f45ead1..7b13f406c 100644 --- a/src/test/contracts/map.mligo +++ b/src/test/contracts/map.mligo @@ -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) diff --git a/src/test/contracts/map.religo b/src/test/contracts/map.religo index 6faacb700..74ec39dcf 100644 --- a/src/test/contracts/map.religo +++ b/src/test/contracts/map.religo @@ -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 */ diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 58b492fc2..e944b7c91 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -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