Add set size op for CameLIGO and PascaLIGO
This commit is contained in:
parent
9ad0859a4c
commit
c4cc4fcba9
@ -82,6 +82,7 @@ module Simplify = struct
|
||||
("set_remove" , "SET_REMOVE") ;
|
||||
("set_iter" , "SET_ITER") ;
|
||||
("set_fold" , "SET_FOLD") ;
|
||||
("set_size" , "SIZE");
|
||||
("list_iter" , "LIST_ITER") ;
|
||||
("list_fold" , "LIST_FOLD") ;
|
||||
("list_map" , "LIST_MAP") ;
|
||||
@ -154,6 +155,7 @@ module Simplify = struct
|
||||
("Set.add" , "SET_ADD") ;
|
||||
("Set.remove" , "SET_REMOVE") ;
|
||||
("Set.fold" , "SET_FOLD") ;
|
||||
("Set.size", "SIZE") ;
|
||||
|
||||
("Map.find_opt" , "MAP_FIND_OPT") ;
|
||||
("Map.find" , "MAP_FIND") ;
|
||||
|
@ -32,5 +32,5 @@ function patch_op_empty (var s: set(string)) : set(string) is
|
||||
function mem_op (const s : set(string)) : bool is
|
||||
begin skip end with set_mem("foobar" , s)
|
||||
|
||||
|
||||
|
||||
function size_op (const s : set(string)) : nat is
|
||||
set_size(s);
|
||||
|
4
src/test/contracts/set_arithmetic.mligo
Normal file
4
src/test/contracts/set_arithmetic.mligo
Normal file
@ -0,0 +1,4 @@
|
||||
(* Test set operations in CameLIGO *)
|
||||
|
||||
let size_op (s: string set) : nat =
|
||||
Set.size s
|
@ -280,6 +280,10 @@ let set_arithmetic () : unit result =
|
||||
expect_eq program "patch_op_empty"
|
||||
(e_set [e_string "foo" ; e_string "bar"])
|
||||
(e_set [e_string "foo" ; e_string "bar"]) in
|
||||
let%bind () =
|
||||
expect_eq program "size_op"
|
||||
(e_set [e_string "foo" ; e_string "bar" ; e_string "foobar"])
|
||||
(e_nat 3) in
|
||||
let%bind () =
|
||||
expect_eq program "mem_op"
|
||||
(e_set [e_string "foo" ; e_string "bar" ; e_string "foobar"])
|
||||
@ -295,6 +299,13 @@ let set_arithmetic () : unit result =
|
||||
in
|
||||
ok ()
|
||||
|
||||
let set_arithmetic_mligo () : unit result =
|
||||
let%bind program = mtype_file "./contracts/set_arithmetic.mligo" in
|
||||
let%bind () =
|
||||
expect_eq program "size_op"
|
||||
(e_set [e_string "foo"; e_string "bar"; e_string "foobar"])
|
||||
(e_nat 3) in ok ()
|
||||
|
||||
let unit_expression () : unit result =
|
||||
let%bind program = type_file "./contracts/unit.ligo" in
|
||||
expect_eq_evaluate program "u" (e_unit ())
|
||||
@ -936,6 +947,7 @@ let main = test_suite "Integration (End to End)" [
|
||||
test "string_arithmetic (mligo)" string_arithmetic_mligo ;
|
||||
test "bytes_arithmetic" bytes_arithmetic ;
|
||||
test "set_arithmetic" set_arithmetic ;
|
||||
test "set_arithmetic (mligo)" set_arithmetic_mligo ;
|
||||
test "unit" unit_expression ;
|
||||
test "string" string_expression ;
|
||||
test "option" option ;
|
||||
|
Loading…
Reference in New Issue
Block a user