summaryrefslogtreecommitdiffstats
path: root/tests/namespace.test
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2020-09-01 22:36:41 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2020-09-01 22:36:41 (GMT)
commit008cd7d2a99f93f590fdefbea117b9f78d03b4ce (patch)
tree3f22b48ea94ee3393cca98439bd1abf9c6c21810 /tests/namespace.test
parentd99566171273e05f659f3f4f364b9d1948ec8565 (diff)
downloadtcl-008cd7d2a99f93f590fdefbea117b9f78d03b4ce.zip
tcl-008cd7d2a99f93f590fdefbea117b9f78d03b4ce.tar.gz
tcl-008cd7d2a99f93f590fdefbea117b9f78d03b4ce.tar.bz2
Fix for [c1a376375e0e6488], imported namespace ensemble command name distorted
during deletion trace on the import
Diffstat (limited to 'tests/namespace.test')
-rw-r--r--tests/namespace.test96
1 files changed, 96 insertions, 0 deletions
diff --git a/tests/namespace.test b/tests/namespace.test
index 2b25803..9c4672f 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