Test now that the generator is not in a running state when it's called.
The previous problem was just a bug. svn: r17984
This commit is contained in:
parent
d5822a3ee5
commit
2368290cdb
|
@ -64,16 +64,15 @@
|
||||||
(lambda () (begin body0 body ...))
|
(lambda () (begin body0 body ...))
|
||||||
;; get here only on at the end of the generator
|
;; get here only on at the end of the generator
|
||||||
(lambda rs
|
(lambda rs
|
||||||
(set! state 'done)
|
(set! cont (lambda () (set! state 'done) (apply values rs)))
|
||||||
(set! cont (lambda () (apply values rs)))
|
|
||||||
(cont))))))
|
(cont))))))
|
||||||
(define (err [what "send a value to"])
|
(define (err [what "send a value to"])
|
||||||
(error 'generator "cannot ~a a ~a generator" what state))
|
(error 'generator "cannot ~a a ~a generator" what state))
|
||||||
(define generator
|
(define generator
|
||||||
(case-lambda
|
(case-lambda
|
||||||
[() (if #t ; (memq state '(fresh suspended done))
|
[() (if (eq? state 'running)
|
||||||
(begin (set! state 'running) (cont))
|
(err "call")
|
||||||
(err "call"))]
|
(begin (set! state 'running) (cont)))]
|
||||||
;; yield-tag means return the state (see `generator-state' below)
|
;; yield-tag means return the state (see `generator-state' below)
|
||||||
[(x) (cond [(eq? x yield-tag) state]
|
[(x) (cond [(eq? x yield-tag) state]
|
||||||
[(memq state '(suspended running))
|
[(memq state '(suspended running))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user