diff options
| author | Jon French | 2019-04-15 16:18:18 +0100 |
|---|---|---|
| committer | Jon French | 2019-04-15 16:18:18 +0100 |
| commit | a9f0b829507e9882efdb59cce4d83ea7e87f5f71 (patch) | |
| tree | 11cde6c1918bc15f4dda9a8e40afd4a1fe912a0a /test/c/tuple_union.sail | |
| parent | 0f6fd188ca232cb539592801fcbb873d59611d81 (diff) | |
| parent | 57443173923e87f33713c99dbab9eba7e3db0660 (diff) | |
Merge branch 'sail2' into rmem_interpreter
Diffstat (limited to 'test/c/tuple_union.sail')
| -rw-r--r-- | test/c/tuple_union.sail | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/c/tuple_union.sail b/test/c/tuple_union.sail new file mode 100644 index 00000000..1914038f --- /dev/null +++ b/test/c/tuple_union.sail @@ -0,0 +1,48 @@ +default Order dec + +$include <prelude.sail> + +val "print_endline" : string -> unit + +union U('a: Type) = { + Ctor : 'a +} + +type pair = (int, int) + +function foo(x: U(pair)) -> unit = { + match x { + Ctor(y, z) => { + print_int("y = ", y); + print_int("z = ", z) + } + }; + match x { + Ctor((y, z)) => { + print_int("y = ", y); + print_int("z = ", z) + } + }; + match x { + Ctor(x) => match x { + (y, z) => { + print_int("y = ", y); + print_int("z = ", z) + } + } + }; + print_endline("") +} + +function main((): unit) -> unit = { + foo(Ctor(1, 2)); + foo(Ctor((3, 4))); + let x = (5, 6); + foo(Ctor(x)); + let x = Ctor(7, 8); + foo(x); + let x = Ctor(((9, 10))); + foo(x); + let x = (11, 12); + foo(Ctor(x)); +} |
