You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
2.2 KiB
45 lines
2.2 KiB
package require tcltest |
|
|
|
namespace eval ::testspace { |
|
namespace import ::tcltest::* |
|
variable common { |
|
set result "" |
|
} |
|
|
|
test nsprefix {Test the basic cases of nsprefix that are different to 'namespace qualifiers'}\ |
|
-setup $common -body { |
|
lappend result [punk::ns::nsprefix ::tcl] ;# :: |
|
lappend result [punk::ns::nsprefix ::::tcl] ;# parts {} tcl - the prefix is :: (because Tcl disallows further empty ns name after root - so we collapse it to ::) |
|
|
|
#the rightmost colon is *only sometimes* associated with the word tcl to be an *unwisely* named child namespace of ":tcl" |
|
#(specifically when the number of colons is divisble by 3) |
|
#see nsparts to understand the splitting mechanism. (colons processed 2 at a time from left, no empty ns aside from root allowed, no trailing colons in ns - except that single colon ns allowed) |
|
|
|
#Colons as part of an ns generally shouldn't exist - but punk::ns, punk::nav::ns are intended to be able to deal with oddly named namespaces as much as possible |
|
#This still leaves ambiguities and impossibilities with another unwise namespace name - with trailing colon - such as "tcl:" |
|
#A pathological case would be a tree of namespaces with mixed leading and trailing colons in each namespace name. |
|
lappend result [punk::ns::nsprefix :::tcl] ; # parts {} :tcl - the prefix is :: |
|
|
|
lappend result [punk::ns::nsprefix ::tcl::x] |
|
|
|
lappend result [punk::ns::nsprefix :::tcl::x] |
|
lappend result [punk::ns::nsprefix ::::tcl::x] |
|
|
|
lappend result [punk::ns::nsprefix :::::tcl::x] ;# parts {} : tcl x - the prefix is :::::tcl |
|
|
|
lappend result [punk::ns::nsprefix :::::tcl] ;# parts {} : tcl - the prefix is ::: - such that joining the prefix ::: to suffix x with 2 colons gives :::::tcl |
|
|
|
#this is somewhat counterintuitive |
|
lappend result [punk::ns::nsprefix ::::::tcl] ;#parts {} : :tcl - the prefix is ::: |
|
lappend result [punk::ns::nsprefix ::::::tcl::x] ;#parts {} : :tcl x - the prefix is ::::::tcl |
|
|
|
}\ |
|
-cleanup { |
|
}\ |
|
-result [list\ |
|
:: :: :: ::tcl :::tcl ::tcl :::::tcl ::: ::: ::::::tcl |
|
] |
|
|
|
|
|
|
|
} |