Protect against user code changing the namespace, plus tests. (PR9644)
svn: r11138
This commit is contained in:
parent
372bbefdb3
commit
a7248560da
|
@ -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
|
||||||
|
|
|
@ -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")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user