Skip to content

Commit e73e0d1

Browse files
committed
Fix impersonate-mvar (and mvar/c as an impersonator contract)
1 parent 847ad19 commit e73e0d1

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

mvar-lib/data/mvar.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
(apply wrap-proc mv struct:mvar props)))
297297

298298
(define (impersonate-mvar mv #:get [get-proc #f] #:put [put-proc #f] . props)
299-
(wrap-mvar impersonate-struct mv get-proc put-proc props))
299+
(wrap-mvar impersonate-struct mv props #:get get-proc #:put put-proc))
300300
(define (chaperone-mvar mv #:get [get-proc #f] #:put [put-proc #f] . props)
301301
(define ((make-checked-chaperone-proc proc) a)
302302
(define b (proc a))

mvar-test/tests/data/mvar.rkt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,26 @@
127127
(check-exn (exn?-blaming 'pos) (λ () (mvar-peek mv+c)))
128128
(check-exn (exn?-blaming 'pos) (λ () (mvar-take! mv+c)))
129129
(check-equal? (mvar-empty? mv+c) #t))
130+
131+
(test-case
132+
"mvar/c impersonator contract"
133+
134+
(define coerce-to-bool/c
135+
(make-contract
136+
#:late-neg-projection
137+
(λ (blame)
138+
(λ (val neg-party)
139+
(and val #t)))))
140+
141+
(define mv (contract (mvar/c coerce-to-bool/c boolean?)
142+
(make-mvar)
143+
'pos
144+
'neg))
145+
146+
(check-equal? (mvar-put! mv 'ok) (void))
147+
(check-equal? (mvar-peek mv) #t)
148+
(check-equal? (mvar-take! mv) #t)
149+
150+
(check-equal? (mvar-put! mv #f) (void))
151+
(check-equal? (mvar-peek mv) #f)
152+
(check-equal? (mvar-take! mv) #f))

0 commit comments

Comments
 (0)