racket/promise: fix promise/force
on the result of delay/sync
Closes #1933
This commit is contained in:
parent
7af67af119
commit
6db03c7eb9
|
@ -907,6 +907,14 @@
|
||||||
(test (void) sync p)
|
(test (void) sync p)
|
||||||
(test (list (void)) sync (wrap-evt p list)))
|
(test (list (void)) sync (wrap-evt p list)))
|
||||||
|
|
||||||
|
(let ()
|
||||||
|
(define pr (delay/sync 'done))
|
||||||
|
(test #f promise-forced? pr)
|
||||||
|
(test #f sync/timeout 0 pr)
|
||||||
|
(test 'done force pr)
|
||||||
|
(test #t promise-forced? pr)
|
||||||
|
(test (void) sync/timeout 0 pr))
|
||||||
|
|
||||||
(test '(list 3 4) 'quasiquote `(list ,(+ 1 2) 4))
|
(test '(list 3 4) 'quasiquote `(list ,(+ 1 2) 4))
|
||||||
(test '(list a (quote a)) 'quasiquote (let ((name 'a)) `(list ,name ',name)))
|
(test '(list a (quote a)) 'quasiquote (let ((name 'a)) `(list ,name ',name)))
|
||||||
(test '(a 3 4 5 6 b) 'quasiquote `(a ,(+ 1 2) ,@(map abs '(4 -5 6)) b))
|
(test '(a 3 4 5 6 b) 'quasiquote `(a ,(+ 1 2) ,@(map abs '(4 -5 6)) b))
|
||||||
|
|
|
@ -26,7 +26,11 @@
|
||||||
(define-struct (running-thread running) (thread))
|
(define-struct (running-thread running) (thread))
|
||||||
|
|
||||||
;; used in promise/sync until it's forced
|
;; used in promise/sync until it's forced
|
||||||
(define-struct syncinfo ([thunk #:mutable] done-evt done-sema access-sema))
|
(define-struct syncinfo ([thunk #:mutable] done-evt done-sema access-sema)
|
||||||
|
;; We don't want to apply a `syncinfo`, but declaring the `syncinfo`
|
||||||
|
;; as a procedure tells `promise-forced?` when the promise is not
|
||||||
|
;; yet forced
|
||||||
|
#:property prop:procedure (case-lambda))
|
||||||
|
|
||||||
(define-struct (promise/sync promise) ()
|
(define-struct (promise/sync promise) ()
|
||||||
#:property prop:custom-write
|
#:property prop:custom-write
|
||||||
|
|
Loading…
Reference in New Issue
Block a user