summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-08-21 23:18:53 -0700
committerOri Bernstein <ori@eigenstate.org>2016-08-21 23:18:53 -0700
commit37c3a754daff7f53930a7d47987403e6e2357bc7 (patch)
tree98fd9b7a341f3f1deb0f75dc745d830332227085 /test
parentbcaade73359400424fb9ff18697e81444b365245 (diff)
downloadmc-37c3a754daff7f53930a7d47987403e6e2357bc7.tar.gz
Fix handling of pointers in match.
Diffstat (limited to 'test')
-rw-r--r--test/matchptr.myr23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/matchptr.myr b/test/matchptr.myr
index f7f2f8b..9dc2367 100644
--- a/test/matchptr.myr
+++ b/test/matchptr.myr
@@ -1,13 +1,34 @@
use std
+type loop = struct
+ l : loop#
+ val : int
+;;
+
const main = {
var x : std.option(std.option(int)#)
+ var y : loop
+ var ok
x = `std.Some &(`std.Some 123)
match x
| `std.Some &(`std.None): std.put("failed\n")
| `std.Some &(`std.Some 666): std.put("failed\n")
- | `std.Some &(`std.Some 123): std.put("worked\n")
+ | `std.Some &(`std.Some 123): ok = true
| _: std.put("failed\n")
;;
+
+ y.val=666
+ match &y
+ | &[.val=777]: std.put("failed\n")
+ | &[.val=123]: ok = ok && true
+ | &[.val=999]: std.put("failed\n")
+ | _:
+ ;;
+
+ if ok
+ std.put("worked\n")
+ else
+ std.put("failed\n")
+ ;;
}