diff --git a/src/test/contracts/condition.mligo b/src/test/contracts/condition.mligo new file mode 100644 index 000000000..4a0a0038f --- /dev/null +++ b/src/test/contracts/condition.mligo @@ -0,0 +1,9 @@ +// Test if conditional in CameLIGO + +let main (i : int) : int = + let result : int = 23 in + if i = 2 then 42 else 0 + +let foo (b : bool) : int = + let x : int = 41 in + let x : int = 1 + (if b then x else main(x)) in x diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 3160ebf91..ecc69e7b4 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -619,6 +619,19 @@ let condition () : unit result = in ok () +let condition_mligo () : unit result = + let%bind program = mtype_file "./contracts/condition.mligo" in + let%bind _ = + let make_input = e_int in + let make_expected = fun n -> e_int (if n = 2 then 42 else 0) in + expect_eq_n program "main" make_input make_expected + in + let%bind _ = + let make_expected = fun b -> e_int (if b then 42 else 1) in + expect_eq_b program "foo" make_expected + in + ok () + let condition_simple () : unit result = let%bind program = type_file "./contracts/condition-simple.ligo" in let make_input = e_int in @@ -937,6 +950,7 @@ let main = test_suite "Integration (End to End)" [ test "record" record ; test "condition simple" condition_simple ; test "condition" condition ; + test "condition (mligo)" condition_mligo ; test "shadow" shadow ; test "annotation" annotation ; test "multiple parameters" multiple_parameters ;