summaryrefslogtreecommitdiffstats
path: root/tests/011
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-04-20 07:50:34 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-04-20 07:50:34 -0700
commit8c08bb39c860ce264af1a35278d27658228c7a0e (patch)
tree804c0b19a4d86f6876a7f60532690b92d0b33c81 /tests/011
parent2db8b0497c7cc13b44210fb06b74d45fefccefc3 (diff)
downloadtxr-8c08bb39c860ce264af1a35278d27658228c7a0e.tar.gz
txr-8c08bb39c860ce264af1a35278d27658228c7a0e.tar.bz2
txr-8c08bb39c860ce264af1a35278d27658228c7a0e.zip
matcher: new pattern operator @(end)
* share/txr/stdlib/doc-syms.tl: New entry for end. * share/txr/stdlib/match.tl (check, check-end, check-sym, loosen, pat-len): New functions, taken from original local functions of sme macro. (sme): Refactored by hoisting local functions out. Some local variable renaming. (end): New pattern macro. * tests/011/patmatch.tl: New test for end. * txr.1: Documented.
Diffstat (limited to 'tests/011')
-rw-r--r--tests/011/patmatch.tl7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl
index 4be407fa..346b21b6 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -314,3 +314,10 @@
(2 (3 5)))
(test (when-match @(sme () () 5) 5 t) t)
+
+(test (when-match @(end 3 x) 3 x) 3)
+(test (when-match @(end (2 @x) y) '(1 2 3) (list x y)) (3 (2 3)))
+(test (when-match @(end (2 . @x) y) '(1 2 . 3) (list x y)) (3 (2 . 3)))
+
+(test (when-match @(as z @(end (2 @x) y)) '(1 2 3) (list x y z))
+ (3 (2 3) (1 2 3)))