Tcl Source Code

Artifact [0f6bd1e8ef]
Login

Artifact 0f6bd1e8ef3bb1afd7317c12fdefb538205b5a45:

Attachment "eunknown.patch" to ticket [1577282fff] added by msofer 2006-10-15 01:16:16.
Index: doc/namespace.n
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/namespace.n,v
retrieving revision 1.21
diff -u -r1.21 namespace.n
--- doc/namespace.n	26 Aug 2006 13:00:38 -0000	1.21
+++ doc/namespace.n	14 Oct 2006 18:11:50 -0000
@@ -771,9 +771,9 @@
 .PP
 When the result is a non-empty list, the words of that list are used
 to replace the ensemble command and subcommand, just as if they had
-been looked up in the \fB\-map\fR. It is up to the unknown handler to
-supply all namespace qualifiers if the implementing subcommand is not
-in the namespace of the caller of the ensemble command. Also note that
+been looked up in the \fB\-map\fR. The implementing subcommand is looked up
+in the ensemble's namespace.
+Also note that
 when ensemble commands are chained (e.g. if you make one of the
 commands that implement an ensemble subcommand into an ensemble, in a
 manner similar to the text widget's tag and mark subcommands) then the
Index: tests/namespace.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/namespace.test,v
retrieving revision 1.58
diff -u -r1.58 namespace.test
--- tests/namespace.test	10 Oct 2006 18:23:03 -0000	1.58
+++ tests/namespace.test	14 Oct 2006 18:12:16 -0000
@@ -1889,6 +1889,45 @@
     while parsing result of ensemble unknown subcommand handler
     invoked from within
 "foo bar"}}
+test namespace-47.7 {ensemble: unknown handler invokes in ensemble's ns} \
+-body {
+    namespace eval ns0 {
+	proc MagicImpl args {
+	    return {Magic called}
+	}
+    }
+    namespace eval ns1 {
+	namespace path ::ns0
+	proc Magic {ensemble subcmd args} {
+	    return [list MagicImpl]
+	}
+	namespace ensemble create -unknown ::ns1::Magic
+    }
+    ns1 foo
+} -cleanup {
+    namespace delete ns0
+    namespace delete ns1
+} -result {Magic called}
+test namespace-47.8 {ensemble: unknown handler invokes in ensemble's ns} \
+-body {
+    namespace eval ns0 {
+	proc MagicImpl args {
+	    return {Magic called}
+	}
+    }
+    namespace eval ns1 {
+	namespace unknown [list namespace eval ::ns0]
+	proc Magic {ensemble subcmd args} {
+	    return [list MagicImpl]
+	}
+	namespace ensemble create -unknown ::ns1::Magic
+    }
+    ns1 foo
+} -cleanup {
+    namespace delete ns0
+    namespace delete ns1
+} -result {Magic called}
+
 
 test namespace-48.1 {ensembles and namespace import: unknown handler} {
     namespace eval foo {