February 20, 2013
When scripting in Tcl, I often need to process CSV files, including printing it out. Since I often found myself in need of printing, I wrote two helper procedures: load_matrix, which loads a matrix (a table) from CSV file; and print_matrix, which prints a text presentation of the matrix. The end result is the ability […]
September 8, 2011
I have added to the Tcl Wiki a section on how to print out a keyed list. If you want to print out the contents of a keyed list, give it a visit, search for keylprint.
July 17, 2011
Many Tcl scripters know how to catch an exception, but not many know how to throw it. This wiki page shows how.
July 2, 2011
The Problem In Linux Mint, the default font and background color for tkcon is terrible. I want to change that to something easier to read. The Solution Here is my ~/.tkconrc, which fixes it by choosing a better font and background color: Discussion The default font in Linux Mint is terrible: it is hard to […]
July 2, 2011
I often need to determine if a file belongs to me while my script is running in a shared environment. For that, I created a function called fileIsMine, read all about it here. Update: I did not know that Tcl has a command called file owned, which does exactly what I want. Duh!
April 26, 2011
The Problem We want to organize tests in a hierarchy of directories and execute them in all at once. The Solution We can organize tests in sub directories of arbitrary depths, but in order for tcltest to include a directory, that directory must contain a file named all.tcl. In this example, we only create two […]
April 19, 2011
The Problem We want to test the result of a function, but don’t know the exact values The Solution In case where we only have a vague idea of what the result or output should look like, we can use the test command’s -match option. For example: Explanations: Lines 6-10: this is the same test […]
April 12, 2011
The Problem We want to test functions which might return an error. The Solution tcltest provides a way to test functions which might return an error: the -returnCodes flag. Before we go into details with the -returnCodes, let’s take a look at the behavior when a function returns an error: In line 1, we started […]
April 8, 2011
The Problem Not all functions return a value. Some of them produce output to the standard output (stdout) and we want to test that. The Solution We can capture the stdout for testing using the -output option to the test command. Furthermore, we can also use the -match option to deal with cases when we […]
April 3, 2011
The Problem I want to be able to put constraints on tests such as: Platform constraints: For example, on the Unix platform, I don’t want to run Windows-specific tests. Known bugs: I want to temporarily disable valid tests that are failing until the developers fix the code. Crashed tests: I want to temporarily disabled tests […]