extend variant cases
This commit is contained in:
parent
f68d592653
commit
212ccd56c7
@ -1,9 +1,11 @@
|
|||||||
type foobar is
|
type foobar is
|
||||||
| Foo of int
|
| Foo of int
|
||||||
| Bar of bool
|
| Bar of bool
|
||||||
|
| Kee of nat
|
||||||
|
|
||||||
function fb(const p : foobar) : int is
|
function fb(const p : foobar) : int is
|
||||||
block { skip } with (case p of
|
block { skip } with (case p of
|
||||||
| Foo (n) -> n
|
| Foo (n) -> n
|
||||||
| Bar (t) -> 42
|
| Bar (t) -> 42
|
||||||
|
| Kee (n) -> 23
|
||||||
end)
|
end)
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
type foobar is
|
type foobar is
|
||||||
| Foo of int
|
| Foo of int
|
||||||
| Bar of bool
|
| Bar of bool
|
||||||
|
| Kee of nat
|
||||||
|
|
||||||
const foo : foobar = Foo (42)
|
const foo : foobar = Foo (42)
|
||||||
|
|
||||||
const bar : foobar = Bar (True)
|
const bar : foobar = Bar (True)
|
||||||
|
|
||||||
|
const kee : foobar = Kee (23n)
|
||||||
|
@ -22,6 +22,9 @@ let variant () : unit result =
|
|||||||
let%bind () =
|
let%bind () =
|
||||||
let expected = e_a_constructor "Bar" (e_a_bool true) in
|
let expected = e_a_constructor "Bar" (e_a_bool true) in
|
||||||
expect_evaluate program "bar" expected 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 ()
|
ok ()
|
||||||
|
|
||||||
let variant_matching () : unit result =
|
let variant_matching () : unit result =
|
||||||
@ -29,7 +32,10 @@ let variant_matching () : unit result =
|
|||||||
let%bind () =
|
let%bind () =
|
||||||
let make_input = fun n -> e_a_constructor "Foo" (e_a_int n) in
|
let make_input = fun n -> e_a_constructor "Foo" (e_a_int n) in
|
||||||
let make_expected = e_a_int 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
|
in
|
||||||
ok ()
|
ok ()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user