summaryrefslogtreecommitdiff
path: root/test/matchargstr.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-06-12 14:03:02 -0400
committerOri Bernstein <ori@eigenstate.org>2014-06-12 14:03:02 -0400
commit00949c38a0f2a1dd742a0c568a53c2d68c85607b (patch)
tree0d5fda8c693b44aa375df40b7c687692a9db24f8 /test/matchargstr.myr
parentb9129f3f0281a4f382b5f437780076384aac826a (diff)
downloadmc-00949c38a0f2a1dd742a0c568a53c2d68c85607b.tar.gz
Add missing file.
Diffstat (limited to 'test/matchargstr.myr')
-rw-r--r--test/matchargstr.myr22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/matchargstr.myr b/test/matchargstr.myr
new file mode 100644
index 0000000..6c87821
--- /dev/null
+++ b/test/matchargstr.myr
@@ -0,0 +1,22 @@
+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 "asdf"
+ match v
+ | `Int 127: std.fatal(1, "wrong match `Int 127\n")
+ | `Str "foo": std.fatal(1, "Wrong match `Str \"foo\"\n")
+ | `Str "fsda": std.fatal(1, "Wrong match `Str \"fsda\"\n")
+ | `Str "asdf": std.put("Correct `Str \"asdf\"!\n")
+ | `Nil: std.fatal(1, "Wrong match `Str \"fsda\"\n")
+ ;;
+}
+