summaryrefslogtreecommitdiffstats
path: root/tests/011
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-01-24 13:10:20 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-01-24 13:10:20 -0800
commit2a6e91240f8ff72cc340b7910cec23eea0533ccd (patch)
tree10cf58c8cdba93c36603eec991b90a38c260fb28 /tests/011
parent87d89d601fba2dd1acc20e723b922da0e7210f1b (diff)
downloadtxr-2a6e91240f8ff72cc340b7910cec23eea0533ccd.tar.gz
txr-2a6e91240f8ff72cc340b7910cec23eea0533ccd.tar.bz2
txr-2a6e91240f8ff72cc340b7910cec23eea0533ccd.zip
matcher: rescind support for @(rcons ...) patterns.
There is no longer any way to write a @(rcons ...) pattern using the range syntax, so there is no point in supporting that operator. The silly syntax @@a..@b which previously worked was actually due to a mistaken requirement in the parser. * share/txr/stdlib/match.tl (compile-range-match): Function moved closer to compile-atom-match, below compile-vec-match. The argument is now a range object containing patterns, so we pull it apart with from and to. (compile-atom-match): Pass range directly to compile-range-match; no need to construct (rcons ...) syntax. * tests/011/patmatch.tl: Add range tests from documentation and a few others. * txr.1: References to @(rcons ...) pattern scrubbed. One wrong #R pattern example corrected.
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 d045c45b..ac474738 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -135,3 +135,12 @@
(test (when-match @(hash (x @y) (@(symbolp y) @datum)) #H(() (x k) (k 42)) datum)
(42))
+
+(test (if-match #R(10 20) 10..20 :yes :no) :yes)
+(test (if-match #R(10 20) #R(10 20) :yes :no) :yes)
+(test (if-match #R(10 20) #R(1 2) :yes :no) :no)
+(test (when-match #R(@a @b) 1..2 (list a b)) (1 2))
+(test (when-match #R(@a 2) 1..2 a) 1)
+(test (when-match #R(1 @a) 1..2 a) 2)
+(test (when-match #R(2 @a) 1..2 a) nil)
+(test (when-match #R(@a 1) 1..2 a) nil)