aboutsummaryrefslogtreecommitdiffstats
path: root/test/pattern/producer.scm
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2025-06-19 23:06:19 -0400
committerGravatar Peter McGoron 2025-06-19 23:06:19 -0400
commit8d0b89eb029793e02589f412314afa5d28928a4c (patch)
treef8457d8742271dd83d1423c0cd56b3c05b63979a /test/pattern/producer.scm
parentadd support for multiple ellipses in a sequence in producers (diff)
Add ellipsis escape form
`(... <template>)` in R6RS+ will escape a single form of ellipses in the production. I personally do not recommend this: overriding the ellipsis with a new identifier is the better approach in all circumstances.
Diffstat (limited to '')
-rw-r--r--test/pattern/producer.scm62
1 files changed, 39 insertions, 23 deletions
diff --git a/test/pattern/producer.scm b/test/pattern/producer.scm
index 14c130d..96d5176 100644
--- a/test/pattern/producer.scm
+++ b/test/pattern/producer.scm
@@ -15,36 +15,52 @@
(define (test-producers)
(let ((producer
- (compile-producer '()
- (list (empty-wrap 'x) (empty-wrap '...))
- (hashmap bound-identifier-comparator
- (empty-wrap 'x)
- 1))))
- (test-equal "produces x = '(5 4 3 2 1)"
- '(1 2 3 4 5)
- (producer (hashmap bound-identifier-comparator
- (empty-wrap 'x)
- '(5 4 3 2 1)))))
+ (compile-producer '()
+ (list (empty-wrap 'x) (empty-wrap '...))
+ (hashmap bound-identifier-comparator
+ (empty-wrap 'x)
+ 1))))
+ (test-equal "x ..."
+ '(1 2 3 4 5)
+ (producer (hashmap bound-identifier-comparator
+ (empty-wrap 'x)
+ '(5 4 3 2 1)))))
(let ((producer
- (compile-producer '()
- (list (list (empty-wrap 'x) (empty-wrap '...))
- (empty-wrap '...))
- (hashmap bound-identifier-comparator
- (empty-wrap 'x)
- 2))))
- (test-equal "double ellipsis"
- '((1 2) (3 4) (5 6) (7 8))
- (producer (hashmap bound-identifier-comparator
- (empty-wrap 'x)
- '((8 7) (6 5) (4 3) (2 1))))))
+ (compile-producer '()
+ (list (list (empty-wrap 'x) (empty-wrap '...))
+ (empty-wrap '...))
+ (hashmap bound-identifier-comparator
+ (empty-wrap 'x)
+ 2))))
+ (test-equal "(x ...) ..."
+ '((1 2) (3 4) (5 6) (7 8))
+ (producer (hashmap bound-identifier-comparator
+ (empty-wrap 'x)
+ '((8 7) (6 5) (4 3) (2 1))))))
(let ((producer
(compile-producer '()
(list (empty-wrap 'x) (empty-wrap '...) (empty-wrap '...))
(hashmap bound-identifier-comparator
(empty-wrap 'x)
2))))
- (test-equal "appended double ellipsis"
+ (test-equal "x ... ..."
'(1 2 3 4 5 6 7 8)
(producer (hashmap bound-identifier-comparator
(empty-wrap 'x)
- '((8 7) (6 5) (4 3) (2 1)))))))
+ '((8 7) (6 5) (4 3) (2 1))))))
+ (test-group "(... (x ...))"
+ (let* ((producer
+ (compile-producer '()
+ (list (empty-wrap '...) (list (empty-wrap 'x) (empty-wrap '...)))
+ (hashmap bound-identifier-comparator
+ (empty-wrap 'x)
+ 0)))
+ (got (producer (hashmap bound-identifier-comparator
+ (empty-wrap 'x)
+ 0))))
+ (test-assert "returned a list" (list? got))
+ (test-eqv "returned the correct length"
+ 2
+ (length got))
+ (test-eqv "first value is 0" 0 (car got))
+ (test-assert "second value" (bound-identifier=? (cadr got) (empty-wrap '...))))))