Add test for generator functions
This commit is contained in:
parent
87384f611c
commit
224fcc425c
15
test.scm
15
test.scm
@ -1,5 +1,6 @@
|
||||
(use-modules (d-)
|
||||
(rnrs base))
|
||||
(rnrs base)
|
||||
(srfi srfi-1))
|
||||
|
||||
(define-syntax-rule (define-unit-test (test-name body ...))
|
||||
(let () body ...))
|
||||
@ -54,3 +55,15 @@
|
||||
(define-test argmin
|
||||
(test
|
||||
(assert (equal? (argmin cdr < '(a . 5) '(b . 2) '(c . 3)) '(b . 2)))))
|
||||
|
||||
(define-test make-generator
|
||||
(test
|
||||
(define number-generator
|
||||
(make-generator (lambda (yield)
|
||||
(let loop ([i 1])
|
||||
(yield i)
|
||||
(loop (1+ i))))))
|
||||
(assert (= (number-generator) 1))
|
||||
(assert (= (number-generator) 2))
|
||||
(assert (= (number-generator) 3))
|
||||
(assert (= (number-generator) 4))))
|
||||
|
Loading…
Reference in New Issue
Block a user