summaryrefslogtreecommitdiffstats
path: root/tests/namespace.test
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2004-09-09 15:44:15 (GMT)
committerdgp <dgp@users.sourceforge.net>2004-09-09 15:44:15 (GMT)
commitd78ee8b94bc6fcdd3bbd3b5d1c9cb5107a360e20 (patch)
tree993634e4710551fb7d9a8197455f470d1ad377c6 /tests/namespace.test
parent650847f3b6562e21662bff6f2eefea5bfb2628d1 (diff)
downloadtcl-d78ee8b94bc6fcdd3bbd3b5d1c9cb5107a360e20.zip
tcl-d78ee8b94bc6fcdd3bbd3b5d1c9cb5107a360e20.tar.gz
tcl-d78ee8b94bc6fcdd3bbd3b5d1c9cb5107a360e20.tar.bz2
* generic/tclNamesp.c (Tcl_ForgetImport): Corrected faulty
* tests/namespace.test: logic that relied exclusively on string matching and failed in the presence of [rename]s. [Bug 560297]
Diffstat (limited to 'tests/namespace.test')
-rw-r--r--tests/namespace.test116
1 files changed, 115 insertions, 1 deletions
diff --git a/tests/namespace.test b/tests/namespace.test
index f49c09b..02aa0e5 100644
--- a/tests/namespace.test
+++ b/tests/namespace.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: namespace.test,v 1.34 2004/08/27 13:59:29 dkf Exp $
+# RCS: @(#) $Id: namespace.test,v 1.35 2004/09/09 15:44:23 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -270,6 +270,120 @@ test namespace-10.3 {Tcl_ForgetImport, deletes matching imported cmds} {
}
} [list [lsort {::test_ns_import::p ::test_ns_import::cmd1}] ::test_ns_import::p 1 {invalid command name "cmd1"}]
+test namespace-10.4 {Tcl_ForgetImport: Bug 560297} -setup {
+ namespace eval origin {
+ namespace export cmd
+ proc cmd {} {}
+ }
+ namespace eval unrelated {
+ proc cmd {} {}
+ }
+ namespace eval my \
+ [list namespace import [namespace current]::origin::cmd]
+} -body {
+ namespace eval my \
+ [list namespace forget [namespace current]::unrelated::cmd]
+ my::cmd
+} -cleanup {
+ namespace delete origin unrelated my
+}
+
+test namespace-10.5 {Tcl_ForgetImport: Bug 560297} -setup {
+ namespace eval origin {
+ namespace export cmd
+ proc cmd {} {}
+ }
+ namespace eval my \
+ [list namespace import [namespace current]::origin::cmd]
+ namespace eval my rename cmd newname
+} -body {
+ namespace eval my \
+ [list namespace forget [namespace current]::origin::cmd]
+ my::newname
+} -cleanup {
+ namespace delete origin my
+} -returnCodes error -match glob -result *
+
+test namespace-10.6 {Tcl_ForgetImport: Bug 560297} -setup {
+ namespace eval origin {
+ namespace export cmd
+ proc cmd {} {}
+ }
+ namespace eval my \
+ [list namespace import [namespace current]::origin::cmd]
+ namespace eval your {}
+ namespace eval my \
+ [list rename cmd [namespace current]::your::newname]
+} -body {
+ namespace eval your namespace forget newname
+ your::newname
+} -cleanup {
+ namespace delete origin my your
+} -returnCodes error -match glob -result *
+
+test namespace-10.7 {Tcl_ForgetImport: Bug 560297} -setup {
+ namespace eval origin {
+ namespace export cmd
+ proc cmd {} {}
+ }
+ namespace eval link namespace export cmd
+ namespace eval link \
+ [list namespace import [namespace current]::origin::cmd]
+ namespace eval link2 namespace export cmd
+ namespace eval link2 \
+ [list namespace import [namespace current]::link::cmd]
+ namespace eval my \
+ [list namespace import [namespace current]::link2::cmd]
+} -body {
+ namespace eval my \
+ [list namespace forget [namespace current]::origin::cmd]
+ my::cmd
+} -cleanup {
+ namespace delete origin link link2 my
+} -returnCodes error -match glob -result *
+
+test namespace-10.8 {Tcl_ForgetImport: Bug 560297} -setup {
+ namespace eval origin {
+ namespace export cmd
+ proc cmd {} {}
+ }
+ namespace eval link namespace export cmd
+ namespace eval link \
+ [list namespace import [namespace current]::origin::cmd]
+ namespace eval link2 namespace export cmd
+ namespace eval link2 \
+ [list namespace import [namespace current]::link::cmd]
+ namespace eval my \
+ [list namespace import [namespace current]::link2::cmd]
+} -body {
+ namespace eval my \
+ [list namespace forget [namespace current]::link::cmd]
+ my::cmd
+} -cleanup {
+ namespace delete origin link link2 my
+}
+
+test namespace-10.8 {Tcl_ForgetImport: Bug 560297} -setup {
+ namespace eval origin {
+ namespace export cmd
+ proc cmd {} {}
+ }
+ namespace eval link namespace export cmd
+ namespace eval link \
+ [list namespace import [namespace current]::origin::cmd]
+ namespace eval link2 namespace export cmd
+ namespace eval link2 \
+ [list namespace import [namespace current]::link::cmd]
+ namespace eval my \
+ [list namespace import [namespace current]::link2::cmd]
+} -body {
+ namespace eval my \
+ [list namespace forget [namespace current]::link2::cmd]
+ my::cmd
+} -cleanup {
+ namespace delete origin link link2 my
+} -returnCodes error -match glob -result *
+
test namespace-11.1 {TclGetOriginalCommand, check if not imported cmd} {
catch {namespace delete {expand}[namespace children :: test_ns_*]}
namespace eval test_ns_export {