The [tcltest] customMatch command allows the test developer to create a custom match routine, extending your options beyond "exact," "glob," and "regexp." [RWT] needed a way to reliably compare floating point numbers, which sometimes vary from platform to platform. One approach is to format number with a fixed number of decimal places and use the usual ''-match exact'' semantics for the test. This works pretty well until you compare floating point numbers with three exponent digits to floating point numbers with two digits, as you will find on Windows and Linux, respectively. A more reliable approach for comparing floating point numbers would be to define a customMatch script which performs a numeric comparison using '''expr''' != operator on double values. #---------------------------------------------------------------- # # customMatch matchDouble # # Custom match routine that performs word-by-word comparisons # using expr's floating point comparison operation (!=) # for words that are [string is double]. # # This custom match routine is required for tests to # run on Microsoft Windows (and perhaps other) platforms # where floating point numbers get a three digit # exponent (i.e. 3.0e008 instead of 3.0e08). # # Note that this routines treats all white space (spaces, # tabs and newlines) as equal. # #---------------------------------------------------------------- customMatch matchDouble matchDoubleProc proc matchDoubleProc {expectedResult actualResult} { # split expected/actual into list of words set elist [split $expectedResult " \t\n"] set alist [split $actualResult " \t\n"] # perform word-by-word comparison foreach eword $elist aword $alist { if { [string is double $eword] && ! [string is integer $eword] } { # perform numeric comparison if { $eword != $aword } {return 0} } else { # perform string comparison if { $eword ne $aword } {return 0} } } return 1 } ---- An interesting variant on matchDouble would use a sigma parameter for approximate comparisons. ---- [Category Testing]