diff options
author | Steve Bennett <steveb@workware.net.au> | 2014-10-10 19:06:23 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2014-10-10 19:07:52 +1000 |
commit | a2ae2a197461d1ba500dcff662b27cd0c8f35c9c (patch) | |
tree | e30d1612a2053c1109634f7003dea50be2c4cd7a /tests/namespace.test | |
parent | 7748e1073aedaecb20f1526c38fc223b4937f0e3 (diff) | |
download | jimtcl-a2ae2a197461d1ba500dcff662b27cd0c8f35c9c.zip jimtcl-a2ae2a197461d1ba500dcff662b27cd0c8f35c9c.tar.gz jimtcl-a2ae2a197461d1ba500dcff662b27cd0c8f35c9c.tar.bz2 |
namespace: disallow creation of import loops
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/namespace.test')
-rw-r--r-- | tests/namespace.test | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/namespace.test b/tests/namespace.test index 090fcf0..6c36672 100644 --- a/tests/namespace.test +++ b/tests/namespace.test @@ -482,9 +482,30 @@ test namespace-12.1 {namespace import} { } {a} test namespace-12.2 {namespace import recursive} -body { - namespace import * + namespace eval test_ns_scope1 { + namespace import [namespace current]::* + } } -returnCodes error -match glob -result {import pattern "*" tries to import from namespace "*" into itself} +test namespace-12.3 {namespace import loop} -setup { + namespace eval one { + namespace export cmd + proc cmd {} {} + } + namespace eval two namespace export cmd + namespace eval two \ + [list namespace import [namespace current]::one::cmd] + namespace eval three namespace export cmd + namespace eval three \ + [list namespace import [namespace current]::two::cmd] +} -body { + namespace eval two [list namespace import -force \ + [namespace current]::three::cmd] + namespace origin two::cmd +} -cleanup { + namespace delete one two three +} -returnCodes error -match glob -result {import pattern * would create a loop*} + foreach cmd [info commands test_ns_*] { rename $cmd "" } |