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:
Eli Barzilay 2010-02-05 03:22:15 +00:00
parent d5822a3ee5
commit 2368290cdb

View File

@ -64,16 +64,15 @@
(lambda () (begin body0 body ...))
;; get here only on at the end of the generator
(lambda rs
(set! state 'done)
(set! cont (lambda () (apply values rs)))
(set! cont (lambda () (set! state 'done) (apply values rs)))
(cont))))))
(define (err [what "send a value to"])
(error 'generator "cannot ~a a ~a generator" what state))
(define generator
(case-lambda
[() (if #t ; (memq state '(fresh suspended done))
(begin (set! state 'running) (cont))
(err "call"))]
[() (if (eq? state 'running)
(err "call")
(begin (set! state 'running) (cont)))]
;; yield-tag means return the state (see `generator-state' below)
[(x) (cond [(eq? x yield-tag) state]
[(memq state '(suspended running))