Browsing All Posts filed under »Tcl«

Tcl Print CSV File

February 20, 2013

1

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 […]

How to Print a Tcl Keyed List

September 8, 2011

0

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.

Tcl: How to Throw an Exception

July 17, 2011

0

Many Tcl scripters know how to catch an exception, but not many know how to throw it. This wiki page shows how.

Better Font and Color for tkcon in Linux Mint 11

July 2, 2011

0

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 […]

Tcl: Does This File Belong to Me?

July 2, 2011

0

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!

tcltest Part 8: Recursive Test Suites

April 26, 2011

1

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 […]

tcltest Part 7 – Inexact Result Matching

April 19, 2011

0

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 […]

tcltest Part 6 – Test for Error Conditions

April 12, 2011

0

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 […]

tcltest part 5: Capture the Standard Output

April 8, 2011

2

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 […]

tcltest Part 4: Constraints

April 3, 2011

0

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 […]

Follow

Get every new post delivered to your Inbox.

Join 34 other followers