diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-04 07:59:10 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-04 07:59:10 (GMT) |
commit | 1674055d7a5077032b0ae8c68af6e7593420cdfd (patch) | |
tree | 5a2b26b3d8c8cca03a5e60c6b1b87979021cac38 /tests/namespace.test | |
parent | a9843e57c2416046ee657b66dc7bd9e4fba46ff3 (diff) | |
parent | fd253d8677ffcef7052c8ac03cbd68c656835a35 (diff) | |
download | tcl-1674055d7a5077032b0ae8c68af6e7593420cdfd.zip tcl-1674055d7a5077032b0ae8c68af6e7593420cdfd.tar.gz tcl-1674055d7a5077032b0ae8c68af6e7593420cdfd.tar.bz2 |
Merge 8.7
Diffstat (limited to 'tests/namespace.test')
-rw-r--r-- | tests/namespace.test | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/tests/namespace.test b/tests/namespace.test index 7bc69aa..5119a60 100644 --- a/tests/namespace.test +++ b/tests/namespace.test @@ -616,6 +616,102 @@ test namespace-13.2 {DeleteImportedCmd, Bug a4494e28ed} { namespace delete src } {} + +test namespace-13.3 { + deleting origin of import in trace on deletion of import +} -setup { + namespace eval ns0 { + namespace export * + variable res {} + + proc traced {oldname newname op} { + variable res + + lappend res {Is oldname the name of the imported routine?} + set expected [namespace qualifiers [namespace current]::fake]::ns2::ns1 + if {$oldname eq $expected} { + lappend res 1 + } else { + lappend res 0 + } + + lappend res {[namespace which] finds the old name} + set which [namespace which $oldname] + if {$which eq $expected} { + lappend res 1 + } else { + lappend res $which + } + + lappend res {Is origin name correct} + catch { + namespace origin $oldname + } cres copts + set expected [namespace qualifiers [namespace current]::fake]::ns1 + if {$cres eq $expected} { + lappend res 1 + } else { + lappend res $cres + } + + set origin $cres + rename $origin {} + + lappend res {After deletion of the origin is it an error to ask for the origin (compiled)?} + set status [catch { + namespace origin $oldname + } cres copts] + if {$status && [string match {invalid command name "*::ns2::ns1"} $cres]} { + lappend res 1 + } else { + lappend res $cres + } + + lappend res {After deletion of the origin is it an error to ask for the origin (uncompiled)?} + set status [catch { + namespace eval [namespace current] "namespace origin $oldname" + } cres copts] + if {$status && [string match {invalid command name "*::ns2::ns1"} $cres]} { + lappend res 1 + } else { + lappend res $cres + } + + lappend res {after deletion of origin, [namespace which] on the imported routine returns the empty string} + set which [namespace which $oldname] + if {$which eq {}} { + lappend res 1 + } else { + lappend res $which + } + + return + } + + } +} -body { + namespace eval ns0::ns1 { + namespace ensemble create + } + + namespace eval ns0::ns2 { + namespace import [namespace parent]::ns1 + trace add command ns1 delete [namespace parent]::traced + rename ns1 {} + } + return $ns0::res +} -cleanup { + namespace delete ns0 +} -result [list \ + {Is oldname the name of the imported routine?} 1 \ + {[namespace which] finds the old name} 1 \ + {Is origin name correct} 1 \ + {After deletion of the origin is it an error to ask for the origin (compiled)?} 1 \ + {After deletion of the origin is it an error to ask for the origin (uncompiled)?} 1 \ + {after deletion of origin, [namespace which] on the imported routine returns the empty string} 1 \ +] + + test namespace-14.1 {TclGetNamespaceForQualName, absolute names} -setup { catch {namespace delete {*}[namespace children :: test_ns_*]} variable v 10 |