March 4, 2008 at 2:36PM Idea: Doctests for Tcl
I was chatting with Laura over IM about testing in Tcl, and I mentioned one of my favourite features of Python, doctests, and a possible method for implementing them in Tcl.
The trick would be to define two new commands, #% and #>. Normally, these would act like regular comment commands, but when being ran in a testing environment, #% would take a command to be evaluated, the result of which would be saved and compared to the arguments passed to the next #>. Here’s a very simple example:
#% llength {a b c d e f g}
#> 7
No comments.