From 2ff178543f9c2633a183bcd51d1a4abc0a31d45e Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Tue, 29 Oct 2019 20:33:18 -0700 Subject: [PATCH] Add more operations to CameLIGO set tests --- src/test/contracts/set_arithmetic.mligo | 20 ++++++++++++++++++++ src/test/integration_tests.ml | 19 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/test/contracts/set_arithmetic.mligo b/src/test/contracts/set_arithmetic.mligo index 23947077d..86d81fe67 100644 --- a/src/test/contracts/set_arithmetic.mligo +++ b/src/test/contracts/set_arithmetic.mligo @@ -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 diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 00530e875..1a25abe00 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -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