From bda1bd90a560b5dafb39e0823899d157c6d91e0d Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Tue, 28 Apr 2020 10:10:09 +1000 Subject: [PATCH] tests: namespace.test More namespace tests from Evan Hunter Signed-off-by: Steve Bennett --- tests/namespace.test | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/namespace.test b/tests/namespace.test index 6c36672..eca28de 100644 --- a/tests/namespace.test +++ b/tests/namespace.test @@ -139,6 +139,24 @@ test namespace-1.28 {namespace variable with array element syntax} -body { } } -returnCodes error -result {can't define "x(3)": name refers to an element in an array} + +test namespace-1.29 {namespace variable too many args} -body { + namespace eval ns1 { + variable x(3) y a b c + } +} -returnCodes error -result {wrong # args: should be "variable name ?value?"} + +test namespace-1.30 {namespace current too many args} -body { + namespace current a +} -returnCodes error -result {wrong # args: should be "namespace current"} + +# TODO: Add tests for canonical option + +test namespace-1.31 {namespace canonical too many args} -body { + namespace canonical a b c +} -returnCodes error -result {wrong # args: should be "namespace canonical ?current? ?name?"} + + unset -nocomplain ns1::x ns1::y # ----------------------------------------------------------------------- @@ -287,6 +305,13 @@ test namespace-5.21 {querying namespace parent for explicit namespace} { [namespace parent nsh1::nsh2::nsh3a] } {{} :: ::nsh1 ::nsh1::nsh2} +test namespace-5.22 {query namespace parent with fully qualified names} { + list [namespace eval :: {namespace parent}] \ + [namespace eval ::nsh1 {namespace parent}] \ + [namespace eval ::nsh1::nsh2 {namespace parent}] \ + [namespace eval nsh1::nsh2::nsh3a {namespace parent ::nsh1::nsh2}] \ +} {{} :: ::nsh1 ::nsh1} + # ----------------------------------------------------------------------- # TEST: name resolution and caching # ----------------------------------------------------------------------- -- 2.11.4.GIT