• Problem with 'customMatch' of tcltest

    From Helmut Giese@hgiese@ratiosoft.com to comp.lang.tcl on Wed Sep 24 19:15:33 2025
    From Newsgroup: comp.lang.tcl

    Hello out there,
    take the following program:
    ---
    package require tcltest
    namespace import ::tcltest::*

    #
    # Accept a difference of '1' in each elt of 'exp'/'act'
    #
    proc oneOffOK {exp act} {
    # flatten the lists
    set exp [join $exp]
    set act [join $act]
    set res 1
    set eps [expr {1e-4}]
    foreach e $exp a $act {
    if {abs($e - $a) > (1.0 + $eps)} {
    set res 0
    break
    }
    }
    return $res
    }

    customMatch oneOffIsOk oneOffOk

    test easy-1.1 {Dummy test} -match oneOffIsOk -body {
    return {1 2 3}
    } -result {1 3 4}
    ---
    The idea is to accept small differences in a Tk program but I get this
    result:
    ---
    d:\proj\_ToolsSE\Skeleton\TclTests>tclsh
    % source easy.test


    ==== easy-1.1 Dummy test FAILED
    ==== Contents of test case:

    return {1 2 3}

    ---- Error testing result: invalid command name "oneOffOk"
    ==== easy-1.1 FAILED

    % info procs one*
    oneOffOK
    %
    ----
    I don't understand what is happening: 'oneOffOK' is known (as the last statement shows) while for the test it is invalid.
    Any help will be greatly appreciated
    Helmut

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Helmut Giese@hgiese@ratiosoft.com to comp.lang.tcl on Wed Sep 24 21:19:30 2025
    From Newsgroup: comp.lang.tcl

    I forgot: This is on Windows 10 with Tcl 8.6.13
    Helmut
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From saito@saitology9@gmail.com to comp.lang.tcl on Wed Sep 24 15:38:42 2025
    From Newsgroup: comp.lang.tcl

    On 9/24/2025 1:15 PM, Helmut Giese wrote:
    Hello out there,
    take the following program:
    ---
    package require tcltest
    namespace import ::tcltest::*

    #
    # Accept a difference of '1' in each elt of 'exp'/'act'
    #
    proc oneOffOK {exp act} {
    vs.

    test easy-1.1 {Dummy test} -match oneOffIsOk -body {

    You may want to check how you spell OK in the two instances: OK vs. Ok


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Helmut Giese@hgiese@ratiosoft.com to comp.lang.tcl on Thu Sep 25 21:42:10 2025
    From Newsgroup: comp.lang.tcl

    You may want to check how you spell OK in the two instances: OK vs. Ok
    Arrrgh - I don't believe it (but I have to since you are right).
    Thanks for having better eyes than me
    Helmut
    --- Synchronet 3.21a-Linux NewsLink 1.2