summaryrefslogtreecommitdiff
path: root/test/c
diff options
context:
space:
mode:
authorAlasdair Armstrong2019-04-05 14:58:27 +0100
committerAlasdair Armstrong2019-04-05 14:59:09 +0100
commitfcc48f06848b9ee7e2ed22ad4a6901761db764e4 (patch)
tree3b90fa582d9bf3f9f905aea5aec3f82260a4206e /test/c
parente9ecc057647d1a13c2eefda0a66a411a6aa17e35 (diff)
Fix: Add test case for commit 689eae
Diffstat (limited to 'test/c')
-rw-r--r--test/c/tuple_union.expect42
-rw-r--r--test/c/tuple_union.sail48
2 files changed, 90 insertions, 0 deletions
diff --git a/test/c/tuple_union.expect b/test/c/tuple_union.expect
new file mode 100644
index 00000000..d8ea9f4f
--- /dev/null
+++ b/test/c/tuple_union.expect
@@ -0,0 +1,42 @@
+y = 1
+z = 2
+y = 1
+z = 2
+y = 1
+z = 2
+
+y = 3
+z = 4
+y = 3
+z = 4
+y = 3
+z = 4
+
+y = 5
+z = 6
+y = 5
+z = 6
+y = 5
+z = 6
+
+y = 7
+z = 8
+y = 7
+z = 8
+y = 7
+z = 8
+
+y = 9
+z = 10
+y = 9
+z = 10
+y = 9
+z = 10
+
+y = 11
+z = 12
+y = 11
+z = 12
+y = 11
+z = 12
+
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));
+}