aboutsummaryrefslogtreecommitdiffstats
path: root/match-test.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-01-09 22:55:59 -0800
committerRose Hogenson <rhogenson@posteo.net>2022-01-09 22:55:59 -0800
commit77583a881b03ce38c8065c40641489fe88b61eb2 (patch)
treed4f65cfd698fee8e63168b4a5b64ab4123177fc3 /match-test.csc
parentRemove str- prefixes from the strings library. (diff)
downloadchromatopelma-77583a881b03ce38c8065c40641489fe88b61eb2.tar.zst
Write the linker.
Diffstat (limited to 'match-test.csc')
-rw-r--r--match-test.csc33
1 files changed, 21 insertions, 12 deletions
diff --git a/match-test.csc b/match-test.csc
index 84b488d..73daa58 100644
--- a/match-test.csc
+++ b/match-test.csc
@@ -7,10 +7,10 @@
(assert-equal
3
(match 3
- (0 0)
- (1 1)
- (2 2)
- (3 3)
+ ((! 0) 0)
+ ((! 1) 1)
+ ((! 2) 2)
+ ((! 3) 3)
(_ 4))))
@@ -19,9 +19,9 @@
2
(match '(1 2 3)
('() 0)
- ((1 2) 1)
- ((1 2 3) 2)
- ((1 2 3 4) 3)
+ (((! 1) (! 2)) 1)
+ (((! 1) (! 2) (! 3)) 2)
+ (((! 1) (! 2) (! 3) (! 4)) 3)
(_ 4))))
@@ -29,7 +29,7 @@
(assert-equal
2
(match '(1 2 3)
- ((1 x 3) x))))
+ (((! 1) x (! 3)) x))))
(test match-destructuring
@@ -45,8 +45,8 @@
2
(match '(1 2 3)
((_ _ _ _) 0)
- ((2 _ _) 1)
- ((1 _ _) 2)
+ (((! 2) _ _) 1)
+ (((! 1) _ _) 2)
(_ 3))))
@@ -54,6 +54,15 @@
(assert-equal
2
(match '(1 2 3)
- ((2 . _) 1)
- ((1 . x) (car x))
+ (((! 2) . _) 1)
+ (((! 1) . x) (car x))
+ (_ 3))))
+
+
+(test match-symbol
+ (assert-equal
+ 2
+ (match 'b
+ ((! 'a) 1)
+ ((! 'b) 2)
(_ 3))))