Protect against user code changing the namespace, plus tests. (PR9644)

svn: r11138
This commit is contained in:
Eli Barzilay 2008-08-08 08:56:00 +00:00
parent 372bbefdb3
commit a7248560da
2 changed files with 23 additions and 4 deletions

View File

@ -203,9 +203,10 @@
(namespace-require lang)) (namespace-require lang))
(check-interactive-language)) (check-interactive-language))
(define (*init) (define (*init)
(parameterize ([current-namespace (current-namespace)])
;; the prompt makes it continue after an error ;; the prompt makes it continue after an error
(call-with-continuation-prompt (call-with-continuation-prompt
(λ () (dynamic-require modspec #f))) (λ () (dynamic-require modspec #f))))
(current-namespace (module->namespace modspec)) (current-namespace (module->namespace modspec))
(check-interactive-language)) (check-interactive-language))
;; here's where they're all combined with the module expression ;; here's where they're all combined with the module expression

View File

@ -219,11 +219,29 @@
" support a REPL \\(no #%top-interaction\\)\n*$")) " support a REPL \\(no #%top-interaction\\)\n*$"))
#t) #t)
;; test scheme/load behavior
(test @t{#lang scheme/load (test @t{#lang scheme/load
(module m mzscheme (provide x) (define x 2)) (module m mzscheme (provide x) (define x 2))
(require 'm) (require 'm)
(printf "~s\n" x) (printf "~s\n" x)
(flush-output)} (flush-output)}
#f #f
@t{2}) "2")
(test @t{#lang scheme/load
(module m mzscheme (provide x) (define x 2))
(module n scheme/base (require 'm) (provide y) (define y (* x x)))
(require 'n)
(printf "~s\n" y)
(flush-output)}
#f
"4")
;; test protection against user-code changing the namespace
(test @t{#lang scheme/base
(current-namespace (make-base-namespace))}
"(+ 1 2)"
"3")
(test @t{#lang scheme/base
(current-namespace (make-base-empty-namespace))}
"(+ 1 2)"
"3")