summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-12-05 01:05:18 -0800
committerOri Bernstein <ori@eigenstate.org>2017-12-05 01:05:18 -0800
commit3360bf0e88b086b0c7f7957eeb4a6f0b4eaeebc7 (patch)
tree95aeb9f8bf85ca70dc9cbdb2729fe166303ca048 /test
parent5aaf4d7e6e7eb9e55bf314a2db83ab25b834b4fb (diff)
downloadmc-3360bf0e88b086b0c7f7957eeb4a6f0b4eaeebc7.tar.gz
Shift the match frontier correctly.
Fixes #159
Diffstat (limited to 'test')
-rw-r--r--test/matchnest.myr45
-rw-r--r--test/tests1
2 files changed, 46 insertions, 0 deletions
diff --git a/test/matchnest.myr b/test/matchnest.myr
new file mode 100644
index 0000000..3572abd
--- /dev/null
+++ b/test/matchnest.myr
@@ -0,0 +1,45 @@
+use std
+
+type a = struct
+ x : int
+ y : int
+;;
+
+type b = struct
+ u : a
+ v : int
+;;
+
+const main = {
+ var v : b
+
+ match ((0, 1), 2)
+ | ((0, 1), 2): std.put("a")
+ | _: std.put("f")
+ ;;
+
+ match ((0, 1), 2)
+ | (_, 2): std.put("b")
+ | _: std.put("f")
+ ;;
+
+ v = [.u=[.x=1, .y=2], .v=3]
+ match v
+ | [.u=[.x=1, .y=2], .v=3]: std.put("c")
+ | _: std.put("f")
+ ;;
+ match v
+ | [.u=_, .v=3]: std.put("d")
+ | _: std.put("f")
+ ;;
+
+
+ match [[1,2], [3,4]]
+ | [[1,2], [3,4]]: std.put("e")
+ | _: std.put("f")
+ ;;
+ match [[1,2], [3,4]]
+ | [_, [3,4]]: std.put("f")
+ | _: std.put("f")
+ ;;
+}
diff --git a/test/tests b/test/tests
index 69878fe..e20df53 100644
--- a/test/tests
+++ b/test/tests
@@ -121,6 +121,7 @@ B matchargstr C
B matchunion_sl P foo
B matchbind E 8
B matchptr P 'worked'
+B matchnest P "abcdef"
F matchmixed
B bigliteral P 34359738368
B arraylit-ni E 2