cmdr
Check-in [58cb0c6af7]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Testing validation types, continued.
Timelines: family | ancestors | descendants | both | vtype-testing
Files: files | file ages | folders
SHA1:58cb0c6af753d54278729a4abb376eda6991ed5d
User & Date: aku 2015-05-11 22:21:10
Context
2015-05-11
22:28
Merged trunk testsuite fixes. check-in: 133579f38a user: aku tags: vtype-testing
22:21
Testing validation types, continued. check-in: 58cb0c6af7 user: aku tags: vtype-testing
2015-05-09
00:08
Started on testsuite for validation types. Template for the common API signatures. check-in: 52969c8c6f user: andreask tags: vtype-testing
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tests/v_boolean.test.

11
12
13
14
15
16
17

18
19
20
21















22
23
24
25
kt local   support cmdr::validate::common
kt local   testing cmdr::validate

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

set vtype cmdr::validate::boolean

kt source vtype.tcl

# # ## ### ##### ######## ############# #####################
## Specific behaviour
















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







>



|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
kt local   support cmdr::validate::common
kt local   testing cmdr::validate

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

set vtype cmdr::validate::boolean
set vtdef no
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 boolean for T "P", got "bogus"}

test vt-${vtype}-validate-2.1 "$vtype validate, ok, true" -body {
    $vtype validate P yes
} -result 1

test vt-${vtype}-validate-2.2 "$vtype validate, ok, false" -body {
    $vtype validate P no
} -result 0

# # ## ### ##### ######## ############# #####################
## Specific behaviour - completion

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

Added tests/v_double.test.





























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- 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

Added tests/v_identity.test.





















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (sub: identity).

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::identity
set vtdef {}
kt source vtype.tcl

# # ## ### ##### ######## ############# #####################
## Specific behaviour

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

Added tests/v_integer.test.





































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (sub: integer).

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::integer
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 an integer for T "P", got "bogus"}

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

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

test vt-${vtype}-validate-2.3 "$vtype validate, ok, octal" -body {
    $vtype validate P 010
} -result 8

test vt-${vtype}-validate-2.4 "$vtype validate, ok, hex" -body {
    $vtype validate P 0xff
} -result 255

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

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

Added tests/v_percent.test.











































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (sub: percent).

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::percent
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 percentage for T "P", got "bogus"}

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

test vt-${vtype}-validate-2.2 "$vtype validate, fail range, up" -body {
    $vtype validate P 101
} -returnCodes error -result {Expected a percentage for T "P", got "101"}

test vt-${vtype}-validate-2.3 "$vtype validate, fail range, low" -body {
    $vtype validate P -0.5
} -returnCodes error -result {Expected a percentage for T "P", got "-0.5"}

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

test vt-${vtype}-validate-2.5 "$vtype validate, ok, fractional" -body {
    $vtype validate P 50.3
} -result 50.3

# # ## ### ##### ######## ############# #####################
## Specific behaviour

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

Added tests/v_rdir.test.





















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (sub: rdirectory).

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::rdirectory
set vtdef {}
kt source vtype.tcl

# # ## ### ##### ######## ############# #####################
## Specific behaviour

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

Added tests/v_rfile.test.





















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (sub: rfile).

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::rfile
set vtdef {}
kt source vtype.tcl

# # ## ### ##### ######## ############# #####################
## Specific behaviour

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

Added tests/v_rwdir.test.





















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (sub: rwdirectory).

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::rwdirectory
set vtdef {}
kt source vtype.tcl

# # ## ### ##### ######## ############# #####################
## Specific behaviour

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

Added tests/v_rwfile.test.





















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (sub: rwfile).

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::rwfile
set vtdef {}
kt source vtype.tcl

# # ## ### ##### ######## ############# #####################
## Specific behaviour

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

Added tests/v_wfile.test.





















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (sub: wfile).

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::wfile
set vtdef {}
kt source vtype.tcl

# # ## ### ##### ######## ############# #####################
## Specific behaviour

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

Changes to tests/vtype.tcl.

6
7
8
9
10
11
12
13

14
15
16
17

18
19
20
21
22
23
24
















25
26
27
28
29
30
31
32
33
34
35




36
37
38
39
40
41
42
# ensemble command of the validation type. This file only tests the
# standard part of the API for the type, i.e. the command
# signatures. The actual validation, completion, etc. must be tested
# by the caller, as that changes from type to type.
#
# File API variables
#
# - "vtype"  - command for the validation type.

# - "vtparm" - name of the parameter variable used by all VT API commands.
# - "vtval"  - name of the value variable used by the all VT API commands except "default".
#
# The last two can be left unspecified, and will default to "p" and "x", respectively.


if {![info exists vtparm]} { set vtparm p }
if {![info exists vtval]}  { set vtval  x }

if {![info exists vtype]} {
    # TODO: kt ... - Abort testsuite
}

















# # ## ### ##### ######## ############# #####################
## default

test vt-${vtype}-default-1.0 "$vtype default, wrong args, not enough" -body {
    $vtype default
} -returnCodes error -result "wrong # args: should be \"$vtype default $vtparm\""

test vt-${vtype}-default-1.1 "$vtype default, wrong args, too many" -body {
    $vtype default P X
} -returnCodes error -result "wrong # args: should be \"$vtype default $vtparm\""





# # ## ### ##### ######## ############# #####################
## validate

test vt-${vtype}-validate-1.0 "$vtype validate, wrong args, not enough" -body {
    $vtype validate
} -returnCodes error -result "wrong # args: should be \"$vtype validate $vtparm $vtval\""







|
>
|
|


>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
>
>
>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# ensemble command of the validation type. This file only tests the
# standard part of the API for the type, i.e. the command
# signatures. The actual validation, completion, etc. must be tested
# by the caller, as that changes from type to type.
#
# File API variables
#
# - "vtype"  - Command for the validation type.
# - "vtdef"  - Default value of the validation type.
# - "vtparm" - Name of the parameter variable used by all VT API commands.
# - "vtval"  - Name of the value variable used by the all VT API commands except "default".
#
# The last two can be left unspecified, and will default to "p" and "x", respectively.
# The first two must be defined.

if {![info exists vtparm]} { set vtparm p }
if {![info exists vtval]}  { set vtval  x }

if {![info exists vtype]} {
    # TODO: kt ... - Abort testsuite
}

if {![info exists vtdef]} {
    # TODO: kt ... - Abort testsuite
}

# # ## ### ##### ######## ############# #####################
## Pseudo/Fake parameter object to satisfy a validation type.
## More specifically the command used inside to generate failure
## messages.

namespace eval P {
    namespace export type the-name
    namespace ensemble create
    proc type     {} { return T }
    proc the-name {} { return P }
}

# # ## ### ##### ######## ############# #####################
## default

test vt-${vtype}-default-1.0 "$vtype default, wrong args, not enough" -body {
    $vtype default
} -returnCodes error -result "wrong # args: should be \"$vtype default $vtparm\""

test vt-${vtype}-default-1.1 "$vtype default, wrong args, too many" -body {
    $vtype default P X
} -returnCodes error -result "wrong # args: should be \"$vtype default $vtparm\""

test vt-${vtype}-default-2.0 "$vtype default, value" -body {
    $vtype default P
} -result $vtdef

# # ## ### ##### ######## ############# #####################
## validate

test vt-${vtype}-validate-1.0 "$vtype validate, wrong args, not enough" -body {
    $vtype validate
} -returnCodes error -result "wrong # args: should be \"$vtype validate $vtparm $vtval\""