mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-04 03:36:36 +02:00
Adding tests for syntax patterns with ellipsis in middle of lists.
This commit is contained in:
parent
955190d4da
commit
1d252ae893
1 changed files with 20 additions and 0 deletions
|
@ -439,6 +439,26 @@
|
|||
(be-like-begin3 sequence3)
|
||||
(test 5 (sequence3 2 3 4 5))
|
||||
|
||||
;; Syntax pattern with ellipsis in middle of proper list.
|
||||
(define-syntax part-2
|
||||
(syntax-rules ()
|
||||
((_ a b (m n) ... x y)
|
||||
(vector (list a b) (list m ...) (list n ...) (list x y)))
|
||||
((_ . rest) 'error)))
|
||||
(test '#((10 43) (31 41 51) (32 42 52) (63 77))
|
||||
(part-2 10 (+ 21 22) (31 32) (41 42) (51 52) (+ 61 2) 77))
|
||||
;; Syntax pattern with ellipsis in middle of improper list.
|
||||
(define-syntax part-2x
|
||||
(syntax-rules ()
|
||||
((_ a b (m n) ... x y . rest)
|
||||
(vector (list a b) (list m ...) (list n ...) (list x y)
|
||||
(cons "rest:" 'rest)))
|
||||
((_ . rest) 'error)))
|
||||
(test '#((10 43) (31 41 51) (32 42 52) (63 77) ("rest:"))
|
||||
(part-2x 10 (+ 21 22) (31 32) (41 42) (51 52) (+ 61 2) 77))
|
||||
(test '#((10 43) (31 41 51) (32 42 52) (63 77) ("rest:" . "tail"))
|
||||
(part-2x 10 (+ 21 22) (31 32) (41 42) (51 52) (+ 61 2) 77 . "tail"))
|
||||
|
||||
;; underscore
|
||||
(define-syntax count-to-2
|
||||
(syntax-rules ()
|
||||
|
|
Loading…
Add table
Reference in a new issue