How do you write test cases with tcltest for procedures or methods that
access and/or modify global variables or itcl member fields?
Cheers,
Antonio
Globals are easy. Tcltests run in the global scope, so setting variables
will automatically set global variables.
If you want to control Incr Tcl objects from Tcltests, that is easy too.
But you are generally testing the object interface, and not setting or
testing member fields directly.
Bob
--
Bob Techentin techenti...@NOSPAMmayo.edu
Mayo Foundation (507) 538-5495
200 First St. SW FAX (507) 284-9171
Rochester MN, 55901 USA http://www.mayo.edu/sppdg/
No, a tcltest test is run in the scope of the caller of the
[::tcltest::test] command.
--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
Cheers,
Antonio
"Don Porter" <d...@email.nist.gov> escribió en el mensaje
news:slrndhbo1...@clover.cam.nist.gov...
Cheers,
Antonio
"Don Porter" <d...@email.nist.gov> escribió en el mensaje
news:slrndhbo1...@clover.cam.nist.gov...
You are, of course, correct, Don. (All my tests run in the global scope.)
Here are two examples:
package require tcltest 2
package require Itcl
set globalvar 2
tcltest::test global-1 {test global variable} {
set ::globalvar
} {2}
itcl::class Foo {
public method bar {} {return "foobar"}
}
tcltest::test object-1 {exercise method} -setup {
Foo f1
} -body {
f1 bar
} -cleanup {
itcl::delete object f1
} -result {foobar}
tcltest::cleanupTests
Antonio
"Bob Techentin" <techenti...@mayo.edu> escribió en el mensaje
news:df53q9$glh$1...@tribune.mayo.edu...