summaryrefslogtreecommitdiffstats
path: root/tests/011
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-06-16 06:14:29 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-06-16 06:14:29 -0700
commit60301ab68ec6a6b7ecb72f83d411c651e029a587 (patch)
tree9682a11bc65ebb42ef012a13c10b6f61cfff08df /tests/011
parent40c1dee7647ddb7d4768a2eadf9915ab29e62f59 (diff)
downloadtxr-60301ab68ec6a6b7ecb72f83d411c651e029a587.tar.gz
txr-60301ab68ec6a6b7ecb72f83d411c651e029a587.tar.bz2
txr-60301ab68ec6a6b7ecb72f83d411c651e029a587.zip
txr-case: upkeep.
* share/txr/stdlib/txr-case.tl (txr-case-impl): If the input is a stream, then convert it to a lazy list of lines, so that running multiple functions against it produces sane, backtracking behavior, like a @(cases) construct. * tests/011/txr-case.expected: Updated. * tests/011/txr-case.txr: Now actually contains a test case for txr-case. * txr.1: Address an issue reported by Paul A. Patience: the input to match-fun, txr-if and txr-when may be a stream. That has always been the case in the implementation. Also document that when the input is a single string, it is treated as a list. Document the new requirement in txr-case that a stream is converted into lazy list of lines.
Diffstat (limited to 'tests/011')
-rw-r--r--tests/011/txr-case.expected1
-rw-r--r--tests/011/txr-case.txr12
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/011/txr-case.expected b/tests/011/txr-case.expected
index 4af473e5..e7582780 100644
--- a/tests/011/txr-case.expected
+++ b/tests/011/txr-case.expected
@@ -2,3 +2,4 @@ no match for 09-10-20
match: year 2009, month 10, day 20
no match for July-15-2014
no match for foo
+match: year 2021, month 06, day 16, foo:bar
diff --git a/tests/011/txr-case.txr b/tests/011/txr-case.txr
index 1aa80478..aa234ed8 100644
--- a/tests/011/txr-case.txr
+++ b/tests/011/txr-case.txr
@@ -7,3 +7,15 @@
(txr-if date (y m d) date
(put-line `match: year @y, month @m, day @d`)
(put-line `no match for @date`))))
+@(define notmatch ())
+blah
+@(end)
+@(define stuff (year month day a b))
+@(date year month day)
+@a @b
+@(end)
+@(do (txr-case (make-strlist-input-stream '("2021-06-16"
+ "foo bar"))
+
+ (notmatch () (put-line "notexpected"))
+ (stuff (y m d a b) (put-line `match: year @y, month @m, day @d, @a:@b`))))