racket/draw: pens and brushes from lists should be immutable

Closes PR 12732
This commit is contained in:
Matthew Flatt 2012-04-25 20:31:54 -06:00
parent a8ca75b773
commit 5e4b9e3aca
3 changed files with 15 additions and 0 deletions

View File

@ -212,6 +212,7 @@
(ephemeron-value e))
(let* ([f (make-object brush% col s)]
[e (make-ephemeron key f)])
(send f set-immutable)
(send f s-set-key key)
(hash-set! brushes key e)
f)))

View File

@ -164,6 +164,7 @@
(ephemeron-value e))
(let* ([f (make-object pen% col w s c j)]
[e (make-ephemeron key f)])
(send f set-immutable)
(send f s-set-key key)
(hash-set! pens key e)
f)))

View File

@ -507,4 +507,17 @@
;; ----------------------------------------
(define (check-immutable v)
(test 'immutable 'immutable
(with-handlers ([exn:fail? (lambda (x)
(if (regexp-match #rx"immutable" (exn-message x))
'immutable
x))])
(send v set-color "red"))))
(check-immutable (send the-brush-list find-or-create-brush "white" 'solid))
(check-immutable (send the-pen-list find-or-create-pen "white" 1 'solid))
;; ----------------------------------------
(report-errs)