diff --git a/src/test/contracts/match.mligo b/src/test/contracts/match.mligo index 1665e9f27..bfe334546 100644 --- a/src/test/contracts/match.mligo +++ b/src/test/contracts/match.mligo @@ -11,3 +11,25 @@ let%entry main (p : param) storage = Add n -> n | Sub n -> 0-n) in (([] : operation list), storage) + +let match_list (l: int list) : int = + match l with + hd :: tl -> hd + | [] -> 10 + +(* TODO: Add support for matching options + +type option_param = + Add of int option +| Sub of int option + +let match_option (p : option_param) storage = + let storage = + storage + + (match p with + Some (Add n) -> n + | Some (Sub n) -> 0 - n + | None -> 0) + in (([] : operation list) , storage) + +*) diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 509b1f0d6..b03b9a51e 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -864,11 +864,21 @@ let let_in_mligo () : unit result = let match_variant () : unit result = let%bind program = mtype_file "./contracts/match.mligo" in - let make_input n = - e_pair (e_constructor "Sub" (e_int n)) (e_int 3) in - let make_expected n = - e_pair (e_typed_list [] t_operation) (e_int (3-n)) - in expect_eq_n program "main" make_input make_expected + let%bind () = + let make_input n = + e_pair (e_constructor "Sub" (e_int n)) (e_int 3) in + let make_expected n = + e_pair (e_typed_list [] t_operation) (e_int (3-n)) + in expect_eq_n program "main" make_input make_expected in + let%bind () = + let input = e_list [e_int 3] in + let expected = e_int 3 in + expect_eq program "match_list" input expected in + let%bind () = + let input = e_typed_list [] t_int in + let expected = e_int 10 in + expect_eq program "match_list" input expected in + ok () let match_matej () : unit result = let%bind program = mtype_file "./contracts/match_bis.mligo" in