Last active
September 11, 2019 10:05
-
-
Save wingyplus/5280817 to your computer and use it in GitHub Desktop.
Simple unit test in Tcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc sum { a b } { | |
return [expr $a + $b] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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