summaryrefslogtreecommitdiffstats
path: root/tests/011
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-13 06:25:50 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-13 06:25:50 -0700
commit483e15d9af31110d2a34ad20fe010663de5afe19 (patch)
tree6721ce5ccadde9b844ec674bff3145941fa0da17 /tests/011
parent3d7e614022c19d0c42ff32d60c8e51b226fb427d (diff)
downloadtxr-483e15d9af31110d2a34ad20fe010663de5afe19.tar.gz
txr-483e15d9af31110d2a34ad20fe010663de5afe19.tar.bz2
txr-483e15d9af31110d2a34ad20fe010663de5afe19.zip
matcher: new must-match and must-match-case macros.
* lisplib.c (match_set_entries): Intern the match-error symbol. Register autoloads for must-match and must-match-case. * stdlib/match.tl (match-error): Register exception symbol, as subtype of match-error. (must-match, must-match-case): New macros. * tests/011/patmatch.tl: Test cases. * txr.1: Documented.
Diffstat (limited to 'tests/011')
-rw-r--r--tests/011/patmatch.tl9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl
index 9647c52b..c6b67614 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -513,6 +513,15 @@
(@else (error "unhandled case")))))
(:odd 1 :pair 2 3 :even 4 :pair 5 6))
+(mtest
+ (must-match (@a @b) '(1 2) (list a b)) (1 2)
+ (must-match (@a @b) '(1 2 3) (list a b)) :error)
+
+(mtest
+ (must-match-case 42) :error
+ (must-match-case 42 (@a a)) 42
+ (must-match-case '(1 2) ((@a) a)) :error)
+
(compile-only
(eval-only
(compile-file (base-name *load-path*) "temp.tlo")