From 483e15d9af31110d2a34ad20fe010663de5afe19 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 13 Aug 2021 06:25:50 -0700 Subject: 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. --- tests/011/patmatch.tl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/011/patmatch.tl') 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") -- cgit v1.2.3