NOTE: how to test Racket GUI preferences
In Racket GUI, framework/preferences
is a built-in module that allows you to set and get configuration for your GUI. However, invoking preferences:set-default
twice is illegal, this usually happened when you are trying to test the code using preferences:set
/ preferences:get
. Hence, you will need preferences:new-layer
and preferences:current-layer
, the following is an example from sauron.
(module+ test (require rackunit) (define test-layer (preferences:new-layer (preferences:current-layer))) (parameterize ([preferences:current-layer test-layer]) (preferences:set-default 'current-project (current-directory) path-string?) (check-equal? (run "ls") (void))))