# p7tests are run when compiling with -g. # they must return a non-zero integer. proc p7test {name body} { if [p7debug] { p7proc (void)${name}__TEST_INIT {} [format { set (tcl)cond set (tcl)func [ lambda (int)test_predicate {} { %s } ] set (int)e [ catch { test_predicate $func } cond ] if ( e ) { ::puts stderr "***** Test %s THREW ERROR: $cond\n[::set ::errorInfo]" ; ::exit 13 } if ( ! $cond ) { ::puts stderr "***** Test %s FAILED ASSERTION" ; ::exit 13 } ::puts stderr "Passed: %s" } $body $name $name $name ] } } proc p7testeq {name expected body} { if [p7debug] { p7proc (void)${name}__TEST_INIT {} [format { set (tcl)what set (tcl)func [ lambda (tcl)test_string {} { %s } ] set (int)e [ catch { test_string $func } what ] if ( e ) { ::puts stderr "***** Test %s THREW ERROR: $cond\n[::set ::errorInfo]" ; ::exit 13 } if ( $what ne $expected ) { ::puts stderr "***** Test %s FAILED ASSERTION: expected `$expected' but got `$what'" ::exit 13 } ::puts stderr "Passed: %s" } $body $name $name $name ] } }