summaryrefslogtreecommitdiff
path: root/test/matchunion_sl.myr
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/matchunion_sl.myr
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/matchunion_sl.myr')
-rw-r--r--test/matchunion_sl.myr26
1 files changed, 26 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
+}
+