cmdr
Artifact Content
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Artifact c2e8d6eebf6dd3c402d32eae4704048a547e86af:


# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (sub: double).

kt check Tcl     8.5
kt check tcltest 2

kt require support debug
kt require support debug::caller

kt local   support cmdr::validate::common
kt local   testing cmdr::validate

# # ## ### ##### ######## ############# #####################
## Basic API.

set vtype cmdr::validate::double
set vtdef 0
kt source vtype.tcl

# # ## ### ##### ######## ############# #####################
## Specific behaviour - validation

test vt-${vtype}-validate-2.0 "$vtype validate, fail" -body {
    $vtype validate P bogus
} -returnCodes error -result {Expected a double for T "P", got "bogus"}

test vt-${vtype}-validate-2.1 "$vtype validate, fail, strict" -body {
    $vtype validate P {}
} -returnCodes error -result {Expected a double for T "P", got ""}

test vt-${vtype}-validate-2.2 "$vtype validate, ok" -body {
    $vtype validate P 33.33
} -result 33.33

test vt-${vtype}-validate-2.3 "$vtype validate, ok, int" -body {
    $vtype validate P 10
} -result 10

test vt-${vtype}-validate-2.4 "$vtype validate, ok, negative" -body {
    $vtype validate P -2.5
} -result -2.5

# # ## ### ##### ######## ############# #####################
cleanupTests
return