cmdr
Check-in [0afbe6cc28]
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 tclconference@googlegroups.com
or submit via the online form by Sep 9.

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

Overview
Comment:Flipped tests for weekday and year, were swapped.
Timelines: family | ancestors | descendants | both | vtype-testing
Files: files | file ages | folders
SHA1:0afbe6cc28182f6adc179945e21e598af883373a
User & Date: aku 2015-07-03 04:37:23
Context
2015-07-03
05:01
Fix issues with time::minute validation. Added testsuite. Closed-Leaf check-in: 1e68d757fb user: aku tags: vtype-testing
04:37
Flipped tests for weekday and year, were swapped. check-in: 0afbe6cc28 user: aku tags: vtype-testing
04:23
Merged VT work from trunk and vt-minute. Updated bool/percent failure messages. check-in: dec47d85c3 user: aku tags: vtype-testing
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tests/v_weekday.test.

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
54
55
56
57
58
59
60
61
62
63
64
65
66




67
68
69
70

71


72
73
74
75

76
77
78
79

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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::year

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

set vtype cmdr::validate::year
set vtdef [clock format [clock seconds] -format %Y] ;# current year. [**]
kt source vtype.tcl

# (Ad **): Race condition possible in the tests, here. If the tests
# are run across a tear border (Dec 31 into Jan 1 Midnight) bogus
# failure will appear in the standard API tests.

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

## Print table of short years, to determine where the border
## current/previous lies.
# for {set i 0} {$i <99} {incr i} { puts  "SHORT $i == [$vtype validate P $i]" }
# Border 37/38

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

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

test vt-${vtype}-validate-2.2 "$vtype validate, fail, octal" -body {
    $vtype validate P 010
} -returnCodes error -result {Expected a year for T "P", got "010"}

test vt-${vtype}-validate-2.3 "$vtype validate, fail, hex" -body {
    $vtype validate P 0xff
} -returnCodes error -result {Expected a year for T "P", got "0xff"}

test vt-${vtype}-validate-2.4 "$vtype validate, fail, negative" -body {
    $vtype validate P -2
} -returnCodes error -result {Expected a year for T "P", got "-2"}

test vt-${vtype}-validate-2.5 "$vtype validate, fail, negative" -body {
    $vtype validate P -1
} -returnCodes error -result {Expected a year for T "P", got "-1"}

test vt-${vtype}-validate-2.6 "$vtype validate, fail, neither short nor long year" -body {
    $vtype validate P 333
} -returnCodes error -result {Expected a year for T "P", got "333"}

test vt-${vtype}-validate-2.7 "$vtype validate, fail, neither short nor long year" -body {
    $vtype validate P 33333
} -returnCodes error -result {Expected a year for T "P", got "33333"}

# # ## ### ##### ######## ############# #####################





test vt-${vtype}-validate-2.8 "$vtype validate, ok, zero, short year, current century" -body {
    $vtype validate P 0
} -result 2000


test vt-${vtype}-validate-2.9 "$vtype validate, ok, positive, short year, current century" -body {


    $vtype validate P 1
} -result 2001

test vt-${vtype}-validate-2.10 "$vtype validate, ok, positive, short year, current century" -body {

    $vtype validate P 33
} -result 2033

test vt-${vtype}-validate-2.11 "$vtype validate, ok, positive, short year, previous century" -body {

    $vtype validate P 37
} -result 2037

test vt-${vtype}-validate-2.12 "$vtype validate, ok, positive, short year, previous century" -body {
    $vtype validate P 38
} -result 1938

test vt-${vtype}-validate-2.13 "$vtype validate, ok, positive, short year, previous century" -body {
    $vtype validate P 99
} -result 1999

test vt-${vtype}-validate-2.14 "$vtype validate, ok, positive, long year" -body {
    $vtype validate P 1923
} -result 1923

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







|




|
|



|
|




|
|
<
<



|



|



|



|



|



|

|
|
|

<
<
<
<


>
>
>
>
|
|
|
<
>
|
>
>
|
|

<
>
|
|

<
>
|
|

<
<
|

|
|
|
|
<
<
<




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
54
55
56
57
58




59
60
61
62
63
64
65
66
67

68
69
70
71
72
73
74

75
76
77
78

79
80
81
82


83
84
85
86
87
88



89
90
91
92
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::weekday

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

set vtype cmdr::validate::weekday
set vtdef [clock format [clock seconds] -format %u] ;# current weekday. [**]
kt source vtype.tcl

# (Ad **): Race condition possible in the tests, here. If the tests
# are run across a day border (23:59 -> 00:00) bogus failure will
# appear in the standard API tests.

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

## Inputs: 0-sun,1...6,7-sun
## long an short names.



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

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

test vt-${vtype}-validate-2.2 "$vtype validate, fail, octal" -body {
    $vtype validate P 010
} -returnCodes error -result {Expected a weekday for T "P", got "010"}

test vt-${vtype}-validate-2.3 "$vtype validate, fail, hex" -body {
    $vtype validate P 0xff
} -returnCodes error -result {Expected a weekday for T "P", got "0xff"}

test vt-${vtype}-validate-2.4 "$vtype validate, fail, negative" -body {
    $vtype validate P -2
} -returnCodes error -result {Expected a weekday for T "P", got "-2"}

test vt-${vtype}-validate-2.5 "$vtype validate, fail, negative" -body {
    $vtype validate P -1
} -returnCodes error -result {Expected a weekday for T "P", got "-1"}

test vt-${vtype}-validate-2.6 "$vtype validate, fail, too large" -body {
    $vtype validate P 8
} -returnCodes error -result {Expected a weekday for T "P", got "8"}





# # ## ### ##### ######## ############# #####################

foreach {wdaye wdayi shortname longname} {
    0 7 sun sunday
    1 1 mon monday
    2 2 tue tuesday
    3 3 wed wednesday
    4 4 thu thursday
    5 5 fri friday

    6 6 sat saturday
    7 7 sun sunday
} {
    test vt-${vtype}-validate-3.$wdaye "$vtype validate, ok, weekday number" -body {
	$vtype validate P $wdaye
    } -result $wdayi


    test vt-${vtype}-validate-4.$wdaye "$vtype validate, ok, short weekday name" -body {
	$vtype validate P $shortname
    } -result $wdayi


    test vt-${vtype}-validate-5.$wdaye "$vtype validate, ok, long weekday name" -body {
	$vtype validate P $longname
    } -result $wdayi



    # # ## ### ##### ######## ############# #####################

    test vt-${vtype}-2external-6.$wdaye "$vtype 2external, ok, long weekday name" -body {
	$vtype 2external $wdayi
    } -result [string totitle $longname]
}




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

Changes to tests/v_year.test.

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
54
55
56
57
58




59
60
61
62
63
64
65
66
67
68

69
70
71
72
73
74
75

76
77
78
79

80
81
82


83
84
85
86
87
88



89
90
91
92
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::weekday

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

set vtype cmdr::validate::weekday
set vtdef [clock format [clock seconds] -format %u] ;# current weekday. [**]
kt source vtype.tcl

# (Ad **): Race condition possible in the tests, here. If the tests
# are run across a day border (23:59 -> 00:00) bogus failure will
# appear in the standard API tests.

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

## Inputs: 0-sun,1...6,7-sun
## long an short names.



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

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

test vt-${vtype}-validate-2.2 "$vtype validate, fail, octal" -body {
    $vtype validate P 010
} -returnCodes error -result {Expected a weekday for T "P", got "010"}

test vt-${vtype}-validate-2.3 "$vtype validate, fail, hex" -body {
    $vtype validate P 0xff
} -returnCodes error -result {Expected a weekday for T "P", got "0xff"}

test vt-${vtype}-validate-2.4 "$vtype validate, fail, negative" -body {
    $vtype validate P -2
} -returnCodes error -result {Expected a weekday for T "P", got "-2"}

test vt-${vtype}-validate-2.5 "$vtype validate, fail, negative" -body {
    $vtype validate P -1
} -returnCodes error -result {Expected a weekday for T "P", got "-1"}

test vt-${vtype}-validate-2.6 "$vtype validate, fail, too large" -body {
    $vtype validate P 8
} -returnCodes error -result {Expected a weekday for T "P", got "8"}





# # ## ### ##### ######## ############# #####################

foreach {wdaye wdayi shortname longname} {
    0 7 sun sunday
    1 1 mon monday
    2 2 tue tuesday
    3 3 wed wednesday
    4 4 thu thursday
    5 5 fri friday
    6 6 sat saturday

    7 7 sun sunday
} {
    test vt-${vtype}-validate-3.$wdaye "$vtype validate, ok, weekday number" -body {
	$vtype validate P $wdaye
    } -result $wdayi

    test vt-${vtype}-validate-4.$wdaye "$vtype validate, ok, short weekday name" -body {

	$vtype validate P $shortname
    } -result $wdayi

    test vt-${vtype}-validate-5.$wdaye "$vtype validate, ok, long weekday name" -body {

	$vtype validate P $longname
    } -result $wdayi



    # # ## ### ##### ######## ############# #####################

    test vt-${vtype}-2external-6.$wdaye "$vtype 2external, ok, long weekday name" -body {
	$vtype 2external $wdayi
    } -result [string totitle $longname]
}




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







|




|
|



|
|




|
|
>
>



|



|



|



|



|



|

|
|
|

>
>
>
>


<
<
<
<
|
|
|
<
>
|
<
<
|
|

<
>
|
|

<
>
|
|

>
>
|

|
|
|
|
>
>
>




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
54
55
56
57
58
59
60
61
62
63
64
65
66




67
68
69

70
71


72
73
74

75
76
77
78

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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::year

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

set vtype cmdr::validate::year
set vtdef [clock format [clock seconds] -format %Y] ;# current year. [**]
kt source vtype.tcl

# (Ad **): Race condition possible in the tests, here. If the tests
# are run across a tear border (Dec 31 into Jan 1 Midnight) bogus
# failure will appear in the standard API tests.

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

## Print table of short years, to determine where the border
## current/previous lies.
# for {set i 0} {$i <99} {incr i} { puts  "SHORT $i == [$vtype validate P $i]" }
# Border 37/38

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

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

test vt-${vtype}-validate-2.2 "$vtype validate, fail, octal" -body {
    $vtype validate P 010
} -returnCodes error -result {Expected a year for T "P", got "010"}

test vt-${vtype}-validate-2.3 "$vtype validate, fail, hex" -body {
    $vtype validate P 0xff
} -returnCodes error -result {Expected a year for T "P", got "0xff"}

test vt-${vtype}-validate-2.4 "$vtype validate, fail, negative" -body {
    $vtype validate P -2
} -returnCodes error -result {Expected a year for T "P", got "-2"}

test vt-${vtype}-validate-2.5 "$vtype validate, fail, negative" -body {
    $vtype validate P -1
} -returnCodes error -result {Expected a year for T "P", got "-1"}

test vt-${vtype}-validate-2.6 "$vtype validate, fail, neither short nor long year" -body {
    $vtype validate P 333
} -returnCodes error -result {Expected a year for T "P", got "333"}

test vt-${vtype}-validate-2.7 "$vtype validate, fail, neither short nor long year" -body {
    $vtype validate P 33333
} -returnCodes error -result {Expected a year for T "P", got "33333"}

# # ## ### ##### ######## ############# #####################





test vt-${vtype}-validate-2.8 "$vtype validate, ok, zero, short year, current century" -body {
    $vtype validate P 0
} -result 2000


test vt-${vtype}-validate-2.9 "$vtype validate, ok, positive, short year, current century" -body {


    $vtype validate P 1
} -result 2001


test vt-${vtype}-validate-2.10 "$vtype validate, ok, positive, short year, current century" -body {
    $vtype validate P 33
} -result 2033


test vt-${vtype}-validate-2.11 "$vtype validate, ok, positive, short year, previous century" -body {
    $vtype validate P 37
} -result 2037

test vt-${vtype}-validate-2.12 "$vtype validate, ok, positive, short year, previous century" -body {
    $vtype validate P 38
} -result 1938

test vt-${vtype}-validate-2.13 "$vtype validate, ok, positive, short year, previous century" -body {
    $vtype validate P 99
} -result 1999

test vt-${vtype}-validate-2.14 "$vtype validate, ok, positive, long year" -body {
    $vtype validate P 1923
} -result 1923

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