1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
# Tests for the 'set' module in the 'struct' library. -*- tcl -*-
#
# This file contains a collection of tests for one or more of the Tcllib
# procedures. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 2004-2008 by Andreas Kupries
#
# RCS: @(#) $Id: sets.test,v 1.18 2008/03/07 06:51:36 andreas_kupries Exp $
#----------------------------------------------------------------------
source [file join \
[file dirname [file dirname [file join [pwd] [info script]]]] \
devtools testutilities.tcl]
testsNeedTcl 8.2
testsNeedTcltest 1.0
testing {
useAccel [useTcllibC] struct/sets.tcl struct::set
TestAccelInit struct::set
}
# -------------------------------------------------------------------------
set sempty {}
set smultiples {a::foo b::foo c::foo a::foo d::foo f::foo a::foo f::foo c::foo h::foo j::foo}
set sa {a::foo b::foo c::foo d::foo}
set sb {e::foo f::foo g::foo h::foo}
set sc {c::foo d::foo e::foo f::foo}
set sd {a::foo b::foo c::foo d::foo e::foo f::foo} ; # a + c
set se {c::foo d::foo e::foo f::foo g::foo h::foo} ; # b + c
set sf {a::foo b::foo c::foo d::foo e::foo f::foo g::foo h::foo} ; # a + b
set sg {a::foo b::foo c::foo d::foo f::foo h::foo j::foo}
set sh {c::foo d::foo}
set si {a::foo b::foo}
set sj {e::foo f::foo}
set sk {a::foo b::foo e::foo f::foo}
set sl {b::foo c::foo d::foo}
interp alias {} setop {} ::struct::set
proc luniq {list} {
set x() {} ; unset x()
foreach l $list {set x($l) .}
return [lsort [array names x]]
}
############################################################
## Iterate over all loaded implementations, activate
## them in turn, and run the tests for the active
## implementation.
TestAccelDo struct::set impl {
# The global variable 'impl' is part of the public
# API the testsuite (in set.testsuite) can expect
# from the environment.
switch -exact -- $impl {
critcl {
if {[package vsatisfies [package present Tcl] 8.5]} {
proc tmWrong {m loarg n} {
return [tcltest::wrongNumArgs "setop $m" $loarg $n]
}
proc tmTooMany {m loarg} {
return [tcltest::tooManyArgs "setop $m" $loarg]
}
proc Nothing {} {
return [tcltest::wrongNumArgs {setop} {cmd ?arg ...?} 0]
}
} else {
proc tmWrong {m loarg n} {
return [tcltest::wrongNumArgs "::struct::set $m" $loarg $n]
}
proc tmTooMany {m loarg} {
return [tcltest::tooManyArgs "::struct::set $m" $loarg]
}
proc Nothing {} {
return [tcltest::wrongNumArgs {::struct::set} {cmd ?arg ...?} 0]
}
}
}
tcl {
if {[package vsatisfies [package present Tcl] 8.6]} {
# In 8.6 head Tcl again reports what the alias resolved to
proc Nothing {} {
return [tcltest::wrongNumArgs {::struct::set} {cmd args} 0]
}
} elseif {[package vsatisfies [package present Tcl] 8.5]} {
# In 8.5 head the alias itself is reported, not what it
# resolved to.
proc Nothing {} {
return [tcltest::wrongNumArgs setop {cmd args} 0]
}
} else {
proc Nothing {} {
return [tcltest::wrongNumArgs {::struct::set} {cmd args} 0]
}
}
proc tmWrong {m loarg n} {
return [tcltest::wrongNumArgs "::struct::set::S_$m" $loarg $n]
}
proc tmTooMany {m loarg} {
return [tcltest::tooManyArgs "::struct::set::S_$m" $loarg]
}
}
}
source [localPath sets.testsuite]
}
############################################################
TestAccelExit struct::set
testsuiteCleanup
|