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

📄 tcltest.tcl

📁 Swarm,由圣塔菲研究所开发,用于复杂适应系统(CAS)仿真及其他
💻 TCL
📖 第 1 页 / 共 5 页
字号:
# Results:#     Prints the contents of the array. Nothing else is allowed.## Side Effects:#     None.#proc tcltest::DebugPArray {level arrayvar} {    variable debug    if {$debug >= $level} {	catch {upvar  $arrayvar $arrayvar}	parray $arrayvar    }    return}# Define our own [parray] in ::tcltest that will inherit use of the [puts]# defined in ::tcltest.  NOTE: Ought to construct with [info args] and# [info default], but can't be bothered now.  If [parray] changes, then# this will need changing too.auto_load ::parrayproc tcltest::parray {a {pattern *}} [info body ::parray]# tcltest::DebugDo --##     Executes the script if the current debug level is greater than#       the provided level argument## Arguments:#     level   The lowest debug level triggering the execution.#     script  The tcl script executed upon a debug level high enough.## Results:#     Arbitrary side effects, dependent on the executed script.## Side Effects:#     None.#proc tcltest::DebugDo {level script} {    variable debug    if {$debug >= $level} {	uplevel 1 $script    }    return}#####################################################################proc tcltest::Warn {msg} {    puts [outputChannel] "WARNING: $msg"}# tcltest::mainThread##     Accessor command for tcltest variable mainThread.#proc tcltest::mainThread { {new ""} } {    variable mainThread    if {[llength [info level 0]] == 1} {	return $mainThread    }    set mainThread $new}# tcltest::testConstraint --##	sets a test constraint to a value; to do multiple constraints,#       call this proc multiple times.  also returns the value of the#       named constraint if no value was supplied.## Arguments:#	constraint - name of the constraint#       value - new value for constraint (should be boolean) - if not#               supplied, this is a query## Results:#	content of tcltest::testConstraints($constraint)## Side effects:#	noneproc tcltest::testConstraint {constraint {value ""}} {    variable testConstraints    variable Option    DebugPuts 3 "entering testConstraint $constraint $value"    if {[llength [info level 0]] == 2} {	return $testConstraints($constraint)    }    # Check for boolean values    if {[catch {expr {$value && $value}} msg]} {	return -code error $msg    }    if {[limitConstraints] 	    && [lsearch -exact $Option(-constraints) $constraint] == -1} {	set value 0    }    set testConstraints($constraint) $value}# tcltest::interpreter --##	the interpreter name stored in tcltest::tcltest## Arguments:#	executable name## Results:#	content of tcltest::tcltest## Side effects:#	None.proc tcltest::interpreter { {interp ""} } {    variable tcltest    if {[llength [info level 0]] == 1} {	return $tcltest    }    if {[string equal {} $interp]} {	set tcltest {}    } else {	set tcltest $interp    }}###################################################################### tcltest::AddToSkippedBecause --##	Increments the variable used to track how many tests were#       skipped because of a particular constraint.## Arguments:#	constraint     The name of the constraint to be modified## Results:#	Modifies tcltest::skippedBecause; sets the variable to 1 if#       didn't previously exist - otherwise, it just increments it.## Side effects:#	None.proc tcltest::AddToSkippedBecause { constraint {value 1}} {    # add the constraint to the list of constraints that kept tests    # from running    variable skippedBecause    if {[info exists skippedBecause($constraint)]} {	incr skippedBecause($constraint) $value    } else {	set skippedBecause($constraint) $value    }    return}# tcltest::PrintError --##	Prints errors to tcltest::errorChannel and then flushes that#       channel, making sure that all messages are < 80 characters per#       line.## Arguments:#	errorMsg     String containing the error to be printed## Results:#	None.## Side effects:#	None.proc tcltest::PrintError {errorMsg} {    set InitialMessage "Error:  "    set InitialMsgLen  [string length $InitialMessage]    puts -nonewline [errorChannel] $InitialMessage    # Keep track of where the end of the string is.    set endingIndex [string length $errorMsg]    if {$endingIndex < (80 - $InitialMsgLen)} {	puts [errorChannel] $errorMsg    } else {	# Print up to 80 characters on the first line, including the	# InitialMessage.	set beginningIndex [string last " " [string range $errorMsg 0 \		[expr {80 - $InitialMsgLen}]]]	puts [errorChannel] [string range $errorMsg 0 $beginningIndex]	while {![string equal end $beginningIndex]} {	    puts -nonewline [errorChannel] \		    [string repeat " " $InitialMsgLen]	    if {($endingIndex - $beginningIndex)		    < (80 - $InitialMsgLen)} {		puts [errorChannel] [string trim \			[string range $errorMsg $beginningIndex end]]		break	    } else {		set newEndingIndex [expr {[string last " " \			[string range $errorMsg $beginningIndex \				[expr {$beginningIndex					+ (80 - $InitialMsgLen)}]		]] + $beginningIndex}]		if {($newEndingIndex <= 0)			|| ($newEndingIndex <= $beginningIndex)} {		    set newEndingIndex end		}		puts [errorChannel] [string trim \			[string range $errorMsg \			    $beginningIndex $newEndingIndex]]		set beginningIndex $newEndingIndex	    }	}    }    flush [errorChannel]    return}# tcltest::SafeFetch --##	 The following trace procedure makes it so that we can safely#        refer to non-existent members of the testConstraints array#        without causing an error.  Instead, reading a non-existent#        member will return 0. This is necessary because tests are#        allowed to use constraint "X" without ensuring that#        testConstraints("X") is defined.## Arguments:#	n1 - name of the array (testConstraints)#       n2 - array key value (constraint name)#       op - operation performed on testConstraints (generally r)## Results:#	none## Side effects:#	sets testConstraints($n2) to 0 if it's referenced but never#       before usedproc tcltest::SafeFetch {n1 n2 op} {    variable testConstraints    DebugPuts 3 "entering SafeFetch $n1 $n2 $op"    if {[string equal {} $n2]} {return}    if {![info exists testConstraints($n2)]} {	if {[catch {testConstraint $n2 [eval [ConstraintInitializer $n2]]}]} {	    testConstraint $n2 0	}    }}# tcltest::ConstraintInitializer --##	Get or set a script that when evaluated in the tcltest namespace#	will return a boolean value with which to initialize the#	associated constraint.## Arguments:#	constraint - name of the constraint initialized by the script#	script - the initializer script## Results#	boolean value of the constraint - enabled or disabled## Side effects:#	Constraint is initialized for future reference by [test]proc tcltest::ConstraintInitializer {constraint {script ""}} {    variable ConstraintInitializer    DebugPuts 3 "entering ConstraintInitializer $constraint $script"    if {[llength [info level 0]] == 2} {	return $ConstraintInitializer($constraint)    }    # Check for boolean values    if {![info complete $script]} {	return -code error "ConstraintInitializer must be complete script"    }    set ConstraintInitializer($constraint) $script}# tcltest::InitConstraints --## Call all registered constraint initializers to force initialization# of all known constraints.# See the tcltest man page for the list of built-in constraints defined# in this procedure.## Arguments:#	none## Results:#	The testConstraints array is reset to have an index for each#	built-in test constraint.## Side Effects:#       None.#proc tcltest::InitConstraints {} {    variable ConstraintInitializer    initConstraintsHook    foreach constraint [array names ConstraintInitializer] {	testConstraint $constraint    }}proc tcltest::DefineConstraintInitializers {} {    ConstraintInitializer singleTestInterp {singleProcess}    # All the 'pc' constraints are here for backward compatibility and    # are not documented.  They have been replaced with equivalent 'win'    # constraints.    ConstraintInitializer unixOnly \	    {string equal $::tcl_platform(platform) unix}    ConstraintInitializer macOnly \	    {string equal $::tcl_platform(platform) macintosh}    ConstraintInitializer pcOnly \	    {string equal $::tcl_platform(platform) windows}    ConstraintInitializer winOnly \	    {string equal $::tcl_platform(platform) windows}    ConstraintInitializer unix {testConstraint unixOnly}    ConstraintInitializer mac {testConstraint macOnly}    ConstraintInitializer pc {testConstraint pcOnly}    ConstraintInitializer win {testConstraint winOnly}    ConstraintInitializer unixOrPc \	    {expr {[testConstraint unix] || [testConstraint pc]}}    ConstraintInitializer macOrPc \	    {expr {[testConstraint mac] || [testConstraint pc]}}    ConstraintInitializer unixOrWin \	    {expr {[testConstraint unix] || [testConstraint win]}}    ConstraintInitializer macOrWin \	    {expr {[testConstraint mac] || [testConstraint win]}}    ConstraintInitializer macOrUnix \	    {expr {[testConstraint mac] || [testConstraint unix]}}    ConstraintInitializer nt {string equal $::tcl_platform(os) "Windows NT"}    ConstraintInitializer 95 {string equal $::tcl_platform(os) "Windows 95"}    ConstraintInitializer 98 {string equal $::tcl_platform(os) "Windows 98"}    # The following Constraints switches are used to mark tests that    # should work, but have been temporarily disabled on certain    # platforms because they don't and we haven't gotten around to    # fixing the underlying problem.    ConstraintInitializer tempNotPc {expr {![testConstraint pc]}}    ConstraintInitializer tempNotWin {expr {![testConstraint win]}}    ConstraintInitializer tempNotMac {expr {![testConstraint mac]}}    ConstraintInitializer tempNotUnix {expr {![testConstraint unix]}}    # The following Constraints switches are used to mark tests that    # crash on certain platforms, so that they can be reactivated again    # when the underlying problem is fixed.    ConstraintInitializer pcCrash {expr {![testConstraint pc]}}    ConstraintInitializer winCrash {expr {![testConstraint win]}}    ConstraintInitializer macCrash {expr {![testConstraint mac]}}    ConstraintInitializer unixCrash {expr {![testConstraint unix]}}    # Skip empty tests    ConstraintInitializer emptyTest {format 0}    # By default, tests that expose known bugs are skipped.    ConstraintInitializer knownBug {format 0}    # By default, non-portable tests are skipped.    ConstraintInitializer nonPortable {format 0}    # Some tests require user interaction.    ConstraintInitializer userInteraction {format 0}    # Some tests must be skipped if the interpreter is not in    # interactive mode    ConstraintInitializer interactive \	    {expr {[info exists ::tcl_interactive] && $::tcl_interactive}}    # Some tests can only be run if the installation came from a CD    # image instead of a web image.  Some tests must be skipped if you    # are running as root on Unix.  Other tests can only be run if you    # are running as root on Unix.    ConstraintInitializer root {expr \	    {[string equal unix $::tcl_platform(platform)]	    && ([string equal root $::tcl_platform(user)]		|| [string equal "" $::tcl_platform(user)])}}    ConstraintInitializer notRoot {expr {![testConstraint root]}}    # Set nonBlockFiles constraint: 1 means this platform supports    # setting files into nonblocking mode.    ConstraintInitializer nonBlockFiles {	    set code [expr {[catch {set f [open defs r]}] 		    || [catch {fconfigure $f -blocking off}]}]	    catch {close $f}	    set code    }    # Set asyncPipeClose constraint: 1 means this platform supports    # async flush and async close on a pipe.    #    # Test for SCO Unix - cannot run async flushing tests because a    # potential problem with select is apparently interfering.    # (Mark Diekhans).    ConstraintInitializer asyncPipeClose {expr {	    !([string equal unix $::tcl_platform(platform)] 	    && ([catch {exec uname -X | fgrep {Release = 3.2v}}] == 0))}}    # Test to see if we have a broken version of sprintf with respect    # to the "e" format of floating-point numbers.    ConstraintInitializer eformat {string equal [format %g 5e-5] 5e-05}    # Test to see if execed commands such as cat, echo, rm and so forth    # are present on this machine.

⌨️ 快捷键说明

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