diff options
Diffstat (limited to 'tests/init.test')
| -rw-r--r-- | tests/init.test | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/tests/init.test b/tests/init.test index c31412b..07270e1 100644 --- a/tests/init.test +++ b/tests/init.test @@ -9,16 +9,14 @@ # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -# -# RCS: @(#) $Id: init.test,v 1.8 2001/04/06 17:57:32 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest + package require tcltest 2.3.4 namespace import -force ::tcltest::* } # Clear out any namespaces called test_ns_* -catch {eval namespace delete [namespace children :: test_ns_*]} +catch {namespace delete {*}[namespace children :: test_ns_*]} # Six cases - white box testing @@ -55,34 +53,27 @@ test init-1.7 {auto_qualify - multiples colons 1} { test init-1.8 {auto_qualify - multiple colons 2} { auto_qualify :::foo ::bar } foo - + # we use a sub interp and auto_reset and double the tests because there is 2 # places where auto_loading occur (before loading the indexes files and after) set testInterp [interp create] -interp eval $testInterp [list set argv $argv] -interp eval $testInterp [list package require tcltest] -interp eval $testInterp [list namespace import -force ::tcltest::*] - +tcltest::loadIntoSlaveInterpreter $testInterp {*}$argv interp eval $testInterp { - -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest -} - -auto_reset -catch {rename parray {}} - + namespace import -force ::tcltest::* + auto_reset + catch {rename parray {}} + test init-2.0 {load parray - stage 1} { - set ret [catch {namespace eval ::tcltest {parray}} error] + set ret [catch {parray} error] rename parray {} ; # remove it, for the next test - that should not fail. list $ret $error } {1 {wrong # args: should be "parray a ?pattern?"}} test init-2.1 {load parray - stage 2} { - set ret [catch {namespace eval ::tcltest {parray}} error] + set ret [catch {parray} error] list $ret $error } {1 {wrong # args: should be "parray a ?pattern?"}} @@ -129,17 +120,16 @@ test init-2.7 {oad setLogCmd from safe:: - stage 2} { } {} -auto_reset -package require http 2.0 -catch {rename ::http::geturl {}} -test init-2.8 {load http::geturl (package)} { +test init-2.8 {load tcl::HistAdd} -setup { + auto_reset + catch {rename ::tcl::HistAdd {}} +} -body { # 3 ':' on purpose - set ret [catch {namespace eval ::tcltest {http:::geturl}} error] - # removing it, for the next test. should not fail. - rename ::http::geturl {} ; - list $ret $error -} {1 {wrong # args: should be "http:::geturl url args"}} + list [catch {tcl:::HistAdd} error] $error +} -cleanup { + rename ::tcl::HistAdd {} ; +} -result {1 {wrong # args: should be "tcl:::HistAdd command ?exec?"}} test init-3.0 {random stuff in the auto_index, should still work} { @@ -154,13 +144,13 @@ test init-3.0 {random stuff in the auto_index, should still work} { # should be the same. set count 0 -foreach arg { - c - {argument +foreach arg [subst -nocommands -novariables { + c + {argument which spans multiple lines} - {argument which is all on one line but which is of such great length that the Tcl C library will truncate it when appending it onto the global error stack} - {argument which spans multiple lines + {argument which is all on one line but which is of such great length that the Tcl C library will truncate it when appending it onto the global error stack} + {argument which spans multiple lines and is long enough to be truncated and " <- includes a false lead in the prune point search and must be longer still to force truncation} @@ -169,12 +159,13 @@ foreach arg { error stack cannot be uniquely determined. foo bar foo "} - {contrived example: rare circumstance + {contrived example: rare circumstance where the point at which to prune the error stack cannot be uniquely determined. foo bar "} - } { + {argument that contains non-ASCII character, \u20ac, and which is of such great length that it will be longer than 150 bytes so it will be truncated by the Tcl C library} + }] { ;# emacs needs -> " test init-4.$count.0 {::errorInfo produced by [unknown]} { auto_reset @@ -200,6 +191,20 @@ foreach arg { incr count } +test init-5.0 {return options passed through ::unknown} -setup { + catch {rename xxx {}} + set ::auto_index(::xxx) {proc ::xxx {} { + return -code error -level 2 xxx + }} +} -body { + set code [catch {::xxx} foo bar] + set code2 [catch {::xxx} foo2 bar2] + list $code $foo $bar $code2 $foo2 $bar2 +} -cleanup { + unset ::auto_index(::xxx) +} -result {2 xxx {-errorcode NONE -code 1 -level 1} 2 xxx {-code 1 -level 1 -errorcode NONE}} + +cleanupTests } ;# End of [interp eval $testInterp] # cleanup |
