racket/promise: fix promise/force on the result of delay/sync

Closes #1933
This commit is contained in:
Matthew Flatt 2018-03-13 19:39:52 -06:00
parent 7af67af119
commit 6db03c7eb9
2 changed files with 13 additions and 1 deletions

View File

@ -907,6 +907,14 @@
(test (void) sync p)
(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 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))

View File

@ -26,7 +26,11 @@
(define-struct (running-thread running) (thread))
;; 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) ()
#:property prop:custom-write