Add tuple tests to CameLIGO

This commit is contained in:
John David Pressman 2019-10-29 20:55:36 -07:00
parent 2ff178543f
commit 85345387d0
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,15 @@
type abc = int * int * int
let projection_abc (tpl : abc) : int =
tpl.(1)
type foobar = int * int
let fb : foobar = (0, 0)
let projection (tpl : foobar) : int =
tpl.(0) + tpl.(1)
type big_tuple = int * int * int * int * int
let br : big_tuple = (23, 23, 23, 23, 23)

View File

@ -467,6 +467,30 @@ let tuple () : unit result =
in
ok ()
let tuple_mligo () : unit result =
let%bind program = mtype_file "./contracts/tuple.mligo" in
let ez n =
e_tuple (List.map e_int n) in
let%bind () =
let expected = ez [0 ; 0] in
expect_eq_evaluate program "fb" expected
in
let%bind () =
let make_input = fun n -> ez [n ; n] in
let make_expected = fun n -> e_int (2 * n) in
expect_eq_n program "projection" make_input make_expected
in
let%bind () =
let make_input = fun n -> ez [n ; 2 * n ; n] in
let make_expected = fun n -> e_int (2 * n) in
expect_eq_n program "projection_abc" make_input make_expected
in
let%bind () =
let expected = ez [23 ; 23 ; 23 ; 23 ; 23] in
expect_eq_evaluate program "br" expected
in
ok ()
let option () : unit result =
let%bind program = type_file "./contracts/option.ligo" in
let%bind () =
@ -1023,6 +1047,7 @@ let main = test_suite "Integration (End to End)" [
test "variant (mligo)" variant_mligo ;
test "variant matching" variant_matching ;
test "tuple" tuple ;
test "tuple (mligo)" tuple_mligo ;
test "record" record ;
test "condition simple" condition_simple ;
test "condition" condition ;