From 85345387d0bb126d56b22f37272dd81b9ac04d53 Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Tue, 29 Oct 2019 20:55:36 -0700 Subject: [PATCH] Add tuple tests to CameLIGO --- src/test/contracts/tuple.mligo | 15 +++++++++++++++ src/test/integration_tests.ml | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/test/contracts/tuple.mligo diff --git a/src/test/contracts/tuple.mligo b/src/test/contracts/tuple.mligo new file mode 100644 index 000000000..178ecfe7b --- /dev/null +++ b/src/test/contracts/tuple.mligo @@ -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) diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 1a25abe00..7c5b18938 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -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 ;