summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOri Bernstein <orib@google.com>2013-02-25 17:10:48 -0500
committerOri Bernstein <orib@google.com>2013-02-25 17:10:48 -0500
commitc525bc13562d68ef0aa709b5ca4bcc1cfc156397 (patch)
tree77c65f06d4ac3da9ce9848f6e1aa980e5ee48a35 /test
parent7bca94e234b70a13a93c77b3e4801368ea173d3d (diff)
downloadmc-c525bc13562d68ef0aa709b5ca4bcc1cfc156397.tar.gz
Add tests for big union argument matching.
We want to support things like putting strings into them.
Diffstat (limited to 'test')
-rw-r--r--test/matchunion_sl.myr26
-rw-r--r--test/tests1
2 files changed, 27 insertions, 0 deletions
diff --git a/test/matchunion_sl.myr b/test/matchunion_sl.myr
new file mode 100644
index 0000000..04cb055
--- /dev/null
+++ b/test/matchunion_sl.myr
@@ -0,0 +1,26 @@
+use std
+/* checks pattern matching on unions with arguments.
+exits with 42. */
+type u = union
+ `Int int
+ `Str byte[:]
+ `Nil
+;;
+
+const main = {
+ var v
+
+ v = `Str "foo"
+ match v
+ `Int 127:
+ -> 42
+ ;;
+ `Str s:
+ std.put("%s\n", s)
+ ;;
+ `Nil:
+ ;;
+ ;;
+ -> 0
+}
+
diff --git a/test/tests b/test/tests
index da1a7d2..bc50801 100644
--- a/test/tests
+++ b/test/tests
@@ -68,6 +68,7 @@ B matchint E 84
B matchconst E 88
B matchunion E 84
B matchargunion E 69
+B matchunion_sl P foo
B matchbind E 8
B arraylit-ni E 2
# B arraylit E 3 ## BUGGERED