Added test for Matej.
This commit is contained in:
parent
346a6fdbc4
commit
a8e344c24e
20
src/contracts/match_bis.mligo
Normal file
20
src/contracts/match_bis.mligo
Normal file
@ -0,0 +1,20 @@
|
||||
type storage = int
|
||||
|
||||
(* variant defining pseudo multi-entrypoint actions *)
|
||||
|
||||
type action =
|
||||
| Increment of int
|
||||
| Decrement of int
|
||||
|
||||
let add (a: int) (b: int) : int = a + b
|
||||
|
||||
let subtract (a: int) (b: int) : int = a - b
|
||||
|
||||
(* real entrypoint that re-routes the flow based on the action provided *)
|
||||
|
||||
let%entry main (p : action) storage =
|
||||
let storage =
|
||||
match p with
|
||||
| Increment n -> add storage n
|
||||
| Decrement n -> subtract storage n
|
||||
in (([] : operation list), storage)
|
@ -484,6 +484,14 @@ let match_variant () : unit result =
|
||||
e_pair (e_typed_list [] t_operation) (e_int (3-n))
|
||||
in expect_eq_n program "main" make_input make_expected
|
||||
|
||||
let match_matej () : unit result =
|
||||
let%bind program = mtype_file "./contracts/match_bis.mligo" in
|
||||
let make_input n =
|
||||
e_pair (e_constructor "Decrement" (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 mligo_list () : unit result =
|
||||
let%bind program = mtype_file "./contracts/list.mligo" in
|
||||
let make_input n =
|
||||
@ -560,6 +568,7 @@ let main = test_suite "Integration (End to End)" [
|
||||
test "counter contract (mligo)" counter_mligo ;
|
||||
test "let-in (mligo)" let_in_mligo ;
|
||||
test "match variant (mligo)" match_variant ;
|
||||
test "match variant 2 (mligo)" match_matej ;
|
||||
(* test "list matching (mligo)" mligo_list ; *)
|
||||
(* test "guess the hash mligo" guess_the_hash_mligo ; WIP? *)
|
||||
(* test "failwith mligo" failwith_mligo ; *)
|
||||
|
Loading…
Reference in New Issue
Block a user