talideon.com

I am ten ninjas!

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
Technorati Search Technorati Search Irish Bloggers

Comments

No comments.

Post a comment

All form information is optional, but it’s a good idea to fill in your name and email address if you want me to take your comment seriously.

Spammers, don’t bother posting crap down here. The site is set up so that legitimate search engines (Google, for instance) won’t index pages with comments on them. Posting crud here only means you’re wasting my time and patience. Shoo!

Real names, please. Please include!
Won’t be displayed. Please include!
Displayed, if present.