From 212ccd56c7b49a750b77e049fc392fe676d76384 Mon Sep 17 00:00:00 2001 From: Galfour Date: Tue, 23 Apr 2019 17:54:45 +0000 Subject: [PATCH] extend variant cases --- src/ligo/contracts/variant-matching.ligo | 2 ++ src/ligo/contracts/variant.ligo | 2 ++ src/ligo/test/integration_tests.ml | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ligo/contracts/variant-matching.ligo b/src/ligo/contracts/variant-matching.ligo index 92e5588d4..5c13a5053 100644 --- a/src/ligo/contracts/variant-matching.ligo +++ b/src/ligo/contracts/variant-matching.ligo @@ -1,9 +1,11 @@ type foobar is | Foo of int | Bar of bool +| Kee of nat function fb(const p : foobar) : int is block { skip } with (case p of | Foo (n) -> n | Bar (t) -> 42 + | Kee (n) -> 23 end) diff --git a/src/ligo/contracts/variant.ligo b/src/ligo/contracts/variant.ligo index b2a306bc8..b98001a02 100644 --- a/src/ligo/contracts/variant.ligo +++ b/src/ligo/contracts/variant.ligo @@ -1,8 +1,10 @@ type foobar is | Foo of int | Bar of bool +| Kee of nat const foo : foobar = Foo (42) const bar : foobar = Bar (True) +const kee : foobar = Kee (23n) diff --git a/src/ligo/test/integration_tests.ml b/src/ligo/test/integration_tests.ml index a393e4510..9d622b825 100644 --- a/src/ligo/test/integration_tests.ml +++ b/src/ligo/test/integration_tests.ml @@ -22,6 +22,9 @@ let variant () : unit result = let%bind () = let expected = e_a_constructor "Bar" (e_a_bool true) in expect_evaluate program "bar" expected in + let%bind () = + let expected = e_a_constructor "Kee" (e_a_nat 23) in + expect_evaluate program "kee" expected in ok () let variant_matching () : unit result = @@ -29,7 +32,10 @@ let variant_matching () : unit result = let%bind () = let make_input = fun n -> e_a_constructor "Foo" (e_a_int n) in let make_expected = e_a_int in - expect_n program "fb" make_input make_expected + expect_n program "fb" make_input make_expected >>? fun () -> + expect program "fb" (e_a_constructor "Kee" (e_a_nat 50)) (e_a_int 23) >>? fun () -> + expect program "fb" (e_a_constructor "Bar" (e_a_bool true)) (e_a_int 42) >>? fun () -> + ok () in ok ()