Posted to tcl by mjanssen at Fri Sep 21 22:38:32 GMT 2007view raw

  1. # run as tclsh filename.tcl to run tests
  2. # source in other file to use totest proc
  3.  
  4. proc totest {a b} {
  5. return $a$b
  6. }
  7.  
  8. if {[info script] eq $argv0} {
  9. # called file so run tests
  10.  
  11. package require tcltest
  12.  
  13. tcltest::verbose pfs
  14.  
  15. tcltest::test TestCase1 {Simple case} -body {
  16. totest de fg
  17. } -result {defg}
  18.  
  19.  
  20. tcltest::test TestCase2 {Test correct error message} -body {
  21. totest 12
  22. } -returnCodes 1 -result {wrong # args: should be "totest a b"}
  23.  
  24. tcltest::cleanupTests
  25. }