diff --git a/test.scm b/test.scm index a163432..142452e 100644 --- a/test.scm +++ b/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))))