⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.test

📁 tcl是工具命令语言
💻 TEST
字号:
# Functionality covered: this file contains a collection of tests for the# auto loading and namespaces.## Sourcing this file into Tcl runs the tests and generates output for# errors. No output means no errors were found.## Copyright (c) 1997 Sun Microsystems, Inc.# Copyright (c) 1998-1999 by Scriptics Corporation.## 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.9 2002/06/05 01:12:38 dgp Exp $if {[lsearch [namespace children] ::tcltest] == -1} {    package require tcltest    namespace import -force ::tcltest::*}# Clear out any namespaces called test_ns_*catch {eval namespace delete [namespace children :: test_ns_*]}# Six cases - white box testingtest init-1.1 {auto_qualify - absolute cmd - namespace} {    auto_qualify ::foo::bar ::blue} ::foo::bartest init-1.2 {auto_qualify - absolute cmd - global} {    auto_qualify ::global ::sub} globaltest init-1.3 {auto_qualify - no colons cmd - global} {    auto_qualify nocolons ::} nocolons test init-1.4 {auto_qualify - no colons cmd - namespace} {    auto_qualify nocolons ::sub} {::sub::nocolons nocolons}test init-1.5 {auto_qualify - colons in cmd - global} {    auto_qualify foo::bar ::} ::foo::bartest init-1.6 {auto_qualify - colons in cmd - namespace} {    auto_qualify foo::bar ::sub} {::sub::foo::bar ::foo::bar}# Some additional teststest init-1.7 {auto_qualify - multiples colons 1} {    auto_qualify :::foo::::bar ::blue} ::foo::bartest 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::*]interp eval $testInterp {if {[lsearch [namespace children] ::tcltest] == -1} {    package require tcltest}auto_resetcatch {rename parray {}}test init-2.0 {load parray - stage 1} {    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 {parray} error]    list $ret $error} {1 {wrong # args: should be "parray a ?pattern?"}}auto_resetcatch {rename ::safe::setLogCmd {}}#unset auto_index(::safe::setLogCmd)#unset auto_oldpathtest init-2.2 {load ::safe::setLogCmd - stage 1} {    ::safe::setLogCmd    rename ::safe::setLogCmd {} ; # should not fail} {}test init-2.3 {load ::safe::setLogCmd - stage 2} {    ::safe::setLogCmd    rename ::safe::setLogCmd {} ; # should not fail} {}auto_resetcatch {rename ::safe::setLogCmd {}}test init-2.4 {load safe:::setLogCmd - stage 1} {    safe:::setLogCmd ; # intentionally 3 :    rename ::safe::setLogCmd {} ; # should not fail} {}test init-2.5 {load safe:::setLogCmd - stage 2} {    safe:::setLogCmd ; # intentionally 3 :    rename ::safe::setLogCmd {} ; # should not fail} {}auto_resetcatch {rename ::safe::setLogCmd {}}test init-2.6 {load setLogCmd from safe:: - stage 1} {    namespace eval safe setLogCmd     rename ::safe::setLogCmd {} ; # should not fail} {}test init-2.7 {oad setLogCmd from safe::  - stage 2} {    namespace eval safe setLogCmd     rename ::safe::setLogCmd {} ; # should not fail} {}auto_resetpackage require http 2.0catch {rename ::http::geturl {}}test init-2.8 {load http::geturl (package)} {    # 3 ':' on purpose    set ret [catch {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"}}test init-3.0 {random stuff in the auto_index, should still work} {    set auto_index(foo:::bar::blah) {        namespace eval foo {namespace eval bar {proc blah {} {return 1}}}    }    foo:::bar::blah} 1# Tests that compare the error stack trace generated when autoloading# with that generated when no autoloading is necessary.  Ideally they# should be the same.set count 0foreach arg {		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                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}                {contrived example: rare circumstance 		where the point at which to prune the		error stack cannot be uniquely determined.		foo bar foo"}                {contrived example: rare circumstance 		where the point at which to prune the		error stack cannot be uniquely determined.		foo bar"}	} {    test init-4.$count.0 {::errorInfo produced by [unknown]} {	auto_reset	catch {parray a b $arg}	set first $::errorInfo	catch {parray a b $arg}	set second $::errorInfo	string equal $first $second    } 1    test init-4.$count.1 {::errorInfo produced by [unknown]} {	auto_reset	namespace eval junk [list array set $arg [list 1 2 3 4]]	trace variable ::junk::$arg r \		"[list error [subst {Variable \"$arg\" is write-only}]] ;# "	catch {parray ::junk::$arg}	set first $::errorInfo	catch {parray ::junk::$arg}	set second $::errorInfo	string equal $first $second    } 1    incr count}}	;#  End of [interp eval $testInterp]# cleanupinterp delete $testInterp::tcltest::cleanupTestsreturn

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -