diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-07-24 19:08:13 -0700 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-07-24 19:08:13 -0700 |
| commit | 51a1e71c269f298fba18b620c68a0b1b15d236e9 (patch) | |
| tree | 10eb01e4afed9d636d7e20f36a676363a8359ad1 /csc/match-test.csc | |
| parent | 192ab9c4e21bab8c08a640b349fa9630a9a672df (diff) | |
| download | chromatopelma-51a1e71c269f298fba18b620c68a0b1b15d236e9.tar.zst | |
Improve the match syntax for constants.
I guess you can pattern match using quote as a literal.
That's pretty cool.
Diffstat (limited to 'csc/match-test.csc')
| -rw-r--r-- | csc/match-test.csc | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/csc/match-test.csc b/csc/match-test.csc index bcd0d35..8323952 100644 --- a/csc/match-test.csc +++ b/csc/match-test.csc @@ -7,11 +7,11 @@ (assert-equal 3 (match 3 - ((! 0) 0) - ((! 1) 1) - ((! 2) 2) - ((! 3) 3) - (_ 4)))) + ('0 0) + ('1 1) + ('2 2) + ('3 3) + ('4 4)))) (test match-list @@ -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,8 +54,8 @@ (assert-equal 2 (match '(1 2 3) - (((! 2) . _) 1) - (((! 1) . x) (car x)) + (('2 . _) 1) + (('1 . x) (car x)) (_ 3)))) @@ -63,8 +63,8 @@ (assert-equal 2 (match 'b - ((! 'a) 1) - ((! 'b) 2) + ('a 1) + ('b 2) (_ 3)))) @@ -72,9 +72,9 @@ (assert-equal 3 (match 'b - ((! 'a) 1) - ((! 'b) when #f 2) - ((! 'b) when #t 3) + ('a 1) + ('b when #f 2) + ('b when #t 3) (_ 4)))) @@ -105,7 +105,7 @@ (test match-record-type-any (assert-equal - #t + 2 (match '(1 2 3) - ((% %test-record-type . _) #f) - ((! '(1 2 3)) #t)))) + ((% %test-record-type . _) 1) + ('(1 2 3) 2)))) |
