summaryrefslogtreecommitdiffstats
path: root/tests/011/txr-case.txr
blob: d6d8d788c1d0d6ea148e05be34be0fde12409b92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@(load `@{stdlib}txr-case`)
@(include "../common")
@(define date (year month day))
@{year /\d\d\d\d/}-@{month /\d\d/}-@{day /\d\d/}
@(end)
@(do
   (each ((date '("09-10-20" "2009-10-20" "July-15-2014" "foo")))
     (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`)))
   (mtest
     (match-fboundp 'notmatch) t
     (match-fboundp 'stuff) t
     (match-fboundp 'xyzzy) nil))