Add test for the if conditional in CameLIGO
This commit is contained in:
parent
2566ebc7d0
commit
2aa201553c
9
src/test/contracts/condition.mligo
Normal file
9
src/test/contracts/condition.mligo
Normal file
@ -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
|
@ -619,6 +619,19 @@ let condition () : unit result =
|
|||||||
in
|
in
|
||||||
ok ()
|
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 condition_simple () : unit result =
|
||||||
let%bind program = type_file "./contracts/condition-simple.ligo" in
|
let%bind program = type_file "./contracts/condition-simple.ligo" in
|
||||||
let make_input = e_int in
|
let make_input = e_int in
|
||||||
@ -937,6 +950,7 @@ let main = test_suite "Integration (End to End)" [
|
|||||||
test "record" record ;
|
test "record" record ;
|
||||||
test "condition simple" condition_simple ;
|
test "condition simple" condition_simple ;
|
||||||
test "condition" condition ;
|
test "condition" condition ;
|
||||||
|
test "condition (mligo)" condition_mligo ;
|
||||||
test "shadow" shadow ;
|
test "shadow" shadow ;
|
||||||
test "annotation" annotation ;
|
test "annotation" annotation ;
|
||||||
test "multiple parameters" multiple_parameters ;
|
test "multiple parameters" multiple_parameters ;
|
||||||
|
Loading…
Reference in New Issue
Block a user