diff options
| author | Andy Wingo <wingo@pobox.com> | 2016-09-10 21:03:07 +0200 |
|---|---|---|
| committer | Andy Wingo <wingo@pobox.com> | 2016-09-10 21:05:13 +0200 |
| commit | 330df8bd407224a4e1c3d8dac9ced93c0507be5a (patch) | |
| tree | 0c593ef722d39c052825dfa7171a1d426080941a /tests | |
| parent | Better fiber run order (diff) | |
| download | guile-fibers-330df8bd407224a4e1c3d8dac9ced93c0507be5a.tar.gz | |
run-fibers returns values from initial thread
* fibers.scm (run-fibers):
* fibers/internal.scm (run-scheduler): If there is an init thunk, keep
the scheduler running until the corresponding fiber is finished.
Return the values returned from the fiber.
* tests/basic.scm (assert-run-fibers-terminates): Return values.
(assert-run-fibers-returns): New helper. Use it.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basic.scm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/basic.scm b/tests/basic.scm index 44ff032..dcae6fb 100644 --- a/tests/basic.scm +++ b/tests/basic.scm @@ -45,9 +45,17 @@ (format #t "assert run-fibers on ~s terminates: " 'exp) (force-output) (let ((start (get-internal-real-time))) - (run-fibers (lambda () exp)) - (format #t "ok (~a s)\n" (/ (- (get-internal-real-time) start) - 1.0 internal-time-units-per-second))))) + (call-with-values (lambda () (run-fibers (lambda () exp))) + (lambda vals + (format #t "ok (~a s)\n" (/ (- (get-internal-real-time) start) + 1.0 internal-time-units-per-second)) + (apply values vals)))))) + +(define-syntax-rule (assert-run-fibers-returns exp expected ...) + (begin + (call-with-values (lambda () (assert-run-fibers-terminates exp)) + (lambda run-fiber-return-vals + (assert-equal '(expected ...) run-fiber-return-vals))))) (define-syntax-rule (do-times n exp) (let lp ((count n)) @@ -116,6 +124,8 @@ (iota count))) (assert-run-fibers-terminates (test-wakeup-order 10))) +(assert-run-fibers-returns 1 1) + ;; sleep wakeup order ;; fib using channels |
