Add more operations to CameLIGO set tests

This commit is contained in:
John David Pressman 2019-10-29 20:33:18 -07:00
parent ec3f836605
commit 2ff178543f
2 changed files with 38 additions and 1 deletions

View File

@ -1,4 +1,24 @@
(* Test set operations in CameLIGO *)
let add_op (s : string set) : string set =
Set.add "foobar" s
let remove_op (s : string set) : string set =
Set.remove "foobar" s
let remove_deep (s : string set * nat) : string set * nat =
Set.remove "foobar" s.(0)
(*
let patch_op (s: string set) : string set =
begin patch s with set ["foobar"]; end with s
let patch_op_deep (s: string set * nat) : string set * nat =
begin patch s.0 with set ["foobar"]; end with s
*)
let mem_op (s : string set) : bool =
Set.mem "foobar" s
let size_op (s: string set) : nat =
Set.size s

View File

@ -333,7 +333,24 @@ let set_arithmetic_mligo () : unit result =
let%bind () =
expect_eq program "size_op"
(e_set [e_string "foo"; e_string "bar"; e_string "foobar"])
(e_nat 3) in ok ()
(e_nat 3) in
let%bind () =
expect_eq program "add_op"
(e_set [e_string "foo" ; e_string "bar"])
(e_set [e_string "foo" ; e_string "bar" ; e_string "foobar"]) in
let%bind () =
expect_eq program "add_op"
(e_set [e_string "foo" ; e_string "bar" ; e_string "foobar"])
(e_set [e_string "foo" ; e_string "bar" ; e_string "foobar"]) in
let%bind () =
expect_eq program "remove_op"
(e_set [e_string "foo" ; e_string "bar"])
(e_set [e_string "foo" ; e_string "bar"]) in
let%bind () =
expect_eq program "remove_op"
(e_set [e_string "foo" ; e_string "bar" ; e_string "foobar"])
(e_set [e_string "foo" ; e_string "bar"]) in
ok ()
let unit_expression () : unit result =
let%bind program = type_file "./contracts/unit.ligo" in