diff --git a/src/contracts/super-counter.mligo b/src/contracts/super-counter.mligo new file mode 100644 index 000000000..ff3a1f5fb --- /dev/null +++ b/src/contracts/super-counter.mligo @@ -0,0 +1,10 @@ +type action = +| Increment of int +| Decrement of int + +let main (p : action) (s : int) : (operation list * int) = + let storage = + match p with + | Increment n -> s + n + | Decrement n -> s - n in + (([] : operation list) , storage) diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 92e88ed1e..bbc62d39a 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -429,6 +429,16 @@ let super_counter_contract () : unit result = e_pair (e_typed_list [] t_operation) (e_int (op 42 n)) in expect_eq_n program "main" make_input make_expected +let super_counter_contract_mligo () : unit result = + let%bind program = mtype_file "./contracts/super-counter.mligo" in + let make_input = fun n -> + let action = if n mod 2 = 0 then "Increment" else "Decrement" in + e_pair (e_constructor action (e_int n)) (e_int 42) in + let make_expected = fun n -> + let op = if n mod 2 = 0 then (+) else (-) in + e_pair (e_typed_list [] t_operation) (e_int (op 42 n)) in + expect_eq_n program "main" make_input make_expected + let dispatch_counter_contract () : unit result = let%bind program = type_file "./contracts/dispatch-counter.ligo" in let make_input = fun n -> @@ -566,6 +576,7 @@ let main = test_suite "Integration (End to End)" [ test "#include directives" include_ ; test "counter contract" counter_contract ; test "super counter contract" super_counter_contract ; + test "super counter contract" super_counter_contract_mligo ; test "dispatch counter contract" dispatch_counter_contract ; test "closure" closure ; test "shared function" shared_function ;