diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-06-29 21:52:30 -0700 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-06-29 21:52:30 -0700 |
| commit | 804a2fe3c90c06a22a1eed5ea50d667ff3e7b08c (patch) | |
| tree | d168f8ade1f358fc607e14825617423d77f51d09 /csc/match-test.csc | |
| parent | Improve CPS. (diff) | |
| download | chromatopelma-804a2fe3c90c06a22a1eed5ea50d667ff3e7b08c.tar.zst | |
Add pattern matching for record types.
I like scheme because it's possible to add any convenient language
feature I can think of.
Diffstat (limited to 'csc/match-test.csc')
| -rw-r--r-- | csc/match-test.csc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/csc/match-test.csc b/csc/match-test.csc index 31e7afa..c5314ce 100644 --- a/csc/match-test.csc +++ b/csc/match-test.csc @@ -85,3 +85,19 @@ (n (when (= 1 n)) 1) (n (when (= 10 n)) 2) (_ 3)))) + + +(define-match-record-type <test-record-type> + (make-test-record-type a b c) + test-record-type? + %test-record-type + (a test-record-type-a) + (b test-record-type-b) + (c test-record-type-c)) + + +(test match-record-type + (assert-equal + 2 + (match (make-test-record-type 1 2 3) + ((% %test-record-type a b c) b)))) |
