diff options
Diffstat (limited to 'match-test.csc')
| -rw-r--r-- | match-test.csc | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/match-test.csc b/match-test.csc index 2728e44..e71a2d3 100644 --- a/match-test.csc +++ b/match-test.csc @@ -12,34 +12,47 @@ (want want)) (let ((tests (list (test-case - "simple" + "cond" (match 3 - (0 0) - (1 1) - (2 2) - (3 3) + ((! 0) 0) + ((! 1) 1) + ((! 2) 2) + ((! 3) 3) (_ 4)) 3) (test-case "match-list" (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)) 2) (test-case "binding" (match '(1 2 3) - ((1 (! x) 3) x)) + (((! 1) x (! 3)) x)) 2) (test-case + "destructuring" + (match '(1 2 3) + ('() 0) + ((head . _) head)) + 1) + (test-case "ignore" (match '(1 2 3) ((_ _ _ _) 0) - ((2 _ _) 1) - ((1 _ _) 2) + (((! 2) _ _) 1) + (((! 1) _ _) 2) + (_ 3)) + 2) + (test-case + "improper list" + (match '(1 2 3) + (((! 2) . _) 1) + (((! 1) . x) (car x)) (_ 3)) 2)))) (for-each |
