Skip to content

Instantly share code, notes, and snippets.

@wingyplus
Last active September 11, 2019 10:05
Show Gist options
  • Save wingyplus/5280817 to your computer and use it in GitHub Desktop.
Save wingyplus/5280817 to your computer and use it in GitHub Desktop.
Simple unit test in Tcl
proc sum { a b } {
return [expr $a + $b]
}
package require tcltest
namespace impor ::tcltest::*
source mymath.tcl
test "sum 1 + 1 must be 2" {
Test: result == 2
} -body {
set result [sum 1 1]
} -result 2
test "sum 2 + 3 must be 5" {
Test: [sum 2 3] == 5
} -body {
sum 2 3
} -result 5
cleanupTests
package require tcltest
namespace import ::tcltest::*
runAllTests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment