diff options
Diffstat (limited to 'tests/clock.test')
-rw-r--r-- | tests/clock.test | 107 |
1 files changed, 74 insertions, 33 deletions
diff --git a/tests/clock.test b/tests/clock.test index 745c095..a78f58f 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: clock.test,v 1.22 2003/02/01 21:27:55 kennykb Exp $ +# RCS: @(#) $Id: clock.test,v 1.23 2003/04/12 19:08:55 kennykb Exp $ set env(LC_TIME) POSIX @@ -39,7 +39,7 @@ test clock-2.2 {clock clicks tests} { } {1} test clock-2.3 {clock clicks tests} { list [catch {clock clicks foo} msg] $msg -} {1 {bad switch "foo": must be -milliseconds}} +} {1 {bad option "foo": must be -milliseconds or -microseconds}} test clock-2.4 {clock clicks tests} { expr [clock clicks -milliseconds]+1 concat {} @@ -53,10 +53,51 @@ test clock-2.5 {clock clicks tests, millisecond timing test} { } {1} test clock-2.6 {clock clicks, milli with too much abbreviation} { list [catch { clock clicks {} } msg] $msg -} {1 {bad switch "": must be -milliseconds}} +} {1 {bad option "": must be -milliseconds or -microseconds}} test clock-2.7 {clock clicks, milli with too much abbreviation} { list [catch { clock clicks - } msg] $msg -} {1 {bad switch "-": must be -milliseconds}} +} {1 {ambiguous option "-": must be -milliseconds or -microseconds}} + +test clock-2.8 {clock clicks test, microsecond timing test} { + set start [clock clicks -micro] + after 10 + set end [clock clicks -micro] + expr {($end > $start) && (($end - $start) <= 60000)} +} {1} + +test clock-2.9 {clock clicks test, millis align with seconds} { + set t1 [clock seconds] + while { 1 } { + set t2 [clock clicks -millis] + set t3 [clock seconds] + if { $t3 == $t1 } break + set t1 $t3 + } + expr { $t2 / 1000 == $t3 } +} {1} + +test clock-2.10 {clock clicks test, micros align with seconds} { + set t1 [clock seconds] + while { 1 } { + set t2 [clock clicks -micros] + set t3 [clock seconds] + if { $t3 == $t1 } break + set t1 $t3 + } + expr { $t2 / 1000000 == $t3 } +} {1} + +test clock-2.11 {clock clicks test, millis align with micros} { + set t1 [clock clicks -millis] + while { 1 } { + set t2 [clock clicks -micros] + set t3 [clock clicks -millis] + if { $t3 == $t1 } break + set t1 $t3 + } + expr { $t2 / 1000 == $t3 } +} {1} + # clock format test clock-3.1 {clock format tests} {unixOnly} { @@ -207,7 +248,7 @@ test clock-4.18 {clock scan, ISO 8601 point in time format} { # We use 5am PST, 31-12-1999 as the base for these scans because irrespective # of your local timezone it should always give us times on December 31, 1999 set 5amPST 946645200 -test clock-4.18 {clock scan, number meridian} { +test clock-4.19 {clock scan, number meridian} { set t1 [clock scan "5 am" -base $5amPST -gmt true] set t2 [clock scan "5 pm" -base $5amPST -gmt true] set t3 [clock scan "5 a.m." -base $5amPST -gmt true] @@ -219,86 +260,86 @@ test clock-4.18 {clock scan, number meridian} { [clock format $t4 -format {%b %d, %Y %H:%M:%S} -gmt true] } [list "Dec 31, 1999 05:00:00" "Dec 31, 1999 17:00:00" \ "Dec 31, 1999 05:00:00" "Dec 31, 1999 17:00:00"] -test clock-4.19 {clock scan, number:number meridian} { +test clock-4.20 {clock scan, number:number meridian} { clock format [clock scan "5:30 pm" -base $5amPST -gmt true] \ -format {%b %d, %Y %H:%M:%S} -gmt true } "Dec 31, 1999 17:30:00" -test clock-4.20 {clock scan, number:number-timezone} { +test clock-4.21 {clock scan, number:number-timezone} { clock format [clock scan "00:00-0800" -gmt true -base $5amPST] \ -format {%b %d, %Y %H:%M:%S} -gmt true } "Dec 31, 1999 08:00:00" -test clock-4.21 {clock scan, number:number:number o_merid} { +test clock-4.22 {clock scan, number:number:number o_merid} { clock format [clock scan "8:00:00" -gmt true -base $5amPST] \ -format {%b %d, %Y %H:%M:%S} -gmt true } "Dec 31, 1999 08:00:00" -test clock-4.22 {clock scan, number:number:number o_merid} { +test clock-4.23 {clock scan, number:number:number o_merid} { clock format [clock scan "8:00:00 am" -gmt true -base $5amPST] \ -format {%b %d, %Y %H:%M:%S} -gmt true } "Dec 31, 1999 08:00:00" -test clock-4.23 {clock scan, number:number:number o_merid} { +test clock-4.24 {clock scan, number:number:number o_merid} { clock format [clock scan "8:00:00 pm" -gmt true -base $5amPST] \ -format {%b %d, %Y %H:%M:%S} -gmt true } "Dec 31, 1999 20:00:00" -test clock-4.24 {clock scan, number:number:number-timezone} { +test clock-4.25 {clock scan, number:number:number-timezone} { clock format [clock scan "00:00:30-0800" -gmt true -base $5amPST] \ -format {%b %d, %Y %H:%M:%S} -gmt true } "Dec 31, 1999 08:00:30" -test clock-4.25 {clock scan, DST for days} { +test clock-4.26 {clock scan, DST for days} { clock scan "tomorrow" -base [clock scan "19991031 00:00:00"] } [clock scan "19991101 00:00:00"] -test clock-4.26 {clock scan, DST for days} { +test clock-4.27 {clock scan, DST for days} { clock scan "yesterday" -base [clock scan "19991101 00:00:00"] } [clock scan "19991031 00:00:00"] -test clock-4.27 {clock scan, day} knownBug { +test clock-4.28 {clock scan, day} knownBug { clock format [clock scan "Monday" -gmt true -base 946627200] \ -format {%b %d, %Y %H:%M:%S} -gmt true } "Jan 03, 2000 00:00:00" -test clock-4.28 {clock scan, number/number} { +test clock-4.29 {clock scan, number/number} { clock format [clock scan "1/1" -gmt true -base 946627200] \ -format {%b %d, %Y %H:%M:%S} -gmt true } "Jan 01, 1999 00:00:00" -test clock-4.28 {clock scan, number/number} { +test clock-4.30 {clock scan, number/number} { clock format [clock scan "1/1/1999" -gmt true -base 946627200] \ -format {%b %d, %Y %H:%M:%S} -gmt true } "Jan 01, 1999 00:00:00" -test clock-4.28 {clock scan, number/number} { +test clock-4.31 {clock scan, number/number} { clock format [clock scan "19990101" -gmt true -base 946627200] \ -format {%b %d, %Y %H:%M:%S} -gmt true } "Jan 01, 1999 00:00:00" -test clock-4.29 {clock scan, relative minutes} { +test clock-4.32 {clock scan, relative minutes} { clock scan "now + 1 minute" -base 946627200 } 946627260 -test clock-4.30 {clock scan, relative minutes} { +test clock-4.33 {clock scan, relative minutes} { clock scan "now +1 minute" -base 946627200 } 946627260 -test clock-4.31 {clock scan, relative minutes} { +test clock-4.34 {clock scan, relative minutes} { clock scan "now 1 minute" -base 946627200 } 946627260 -test clock-4.32 {clock scan, relative minutes} { +test clock-4.35 {clock scan, relative minutes} { clock scan "now - 1 minute" -base 946627200 } 946627140 -test clock-4.33 {clock scan, relative minutes} { +test clock-4.36 {clock scan, relative minutes} { clock scan "now -1 minute" -base 946627200 } 946627140 -test clock-4.34 {clock scan, day of week} { +test clock-4.37 {clock scan, day of week} { clock format [clock scan "wednesday" -base [clock scan 20000112]] \ -format {%b %d, %Y} } "Jan 12, 2000" -test clock-4.35 {clock scan, next day of week} { +test clock-4.38 {clock scan, next day of week} { clock format [clock scan "next wednesday" -base [clock scan 20000112]] \ -format {%b %d, %Y} } "Jan 19, 2000" -test clock-4.36 {clock scan, day of week} { +test clock-4.39 {clock scan, day of week} { clock format [clock scan "thursday" -base [clock scan 20000112]] \ -format {%b %d, %Y} } "Jan 13, 2000" -test clock-4.37 {clock scan, next day of week} { +test clock-4.40 {clock scan, next day of week} { clock format [clock scan "next thursday" -base [clock scan 20000112]] \ -format {%b %d, %Y} } "Jan 20, 2000" # weekday specification and base. -test clock-4.38 {2nd monday in november} { +test clock-4.41 {2nd monday in november} { set res {} foreach i {91 92 93 94 95 96} { set nov8th [clock scan 11/8/$i] @@ -307,7 +348,7 @@ test clock-4.38 {2nd monday in november} { } set res } {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11} -test clock-4.39 {2nd monday in november (2nd try)} { +test clock-4.42 {2nd monday in november (2nd try)} { set res {} foreach i {91 92 93 94 95 96} { set nov1th [clock scan 11/1/$i] @@ -316,7 +357,7 @@ test clock-4.39 {2nd monday in november (2nd try)} { } set res } {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11} -test clock-4.40 {last monday in november} { +test clock-4.43 {last monday in november} { set res {} foreach i {91 92 93 94 95 96} { set dec1th [clock scan 12/1/$i] @@ -326,7 +367,7 @@ test clock-4.40 {last monday in november} { set res } {1991-11-25 1992-11-30 1993-11-29 1994-11-28 1995-11-27 1996-11-25} -test clock-4.40 {2nd monday in november} knownBug { +test clock-4.44 {2nd monday in november} knownBug { set res {} foreach i {91 92 93 94 95 96} { set nov8th [clock scan 11/8/$i -gmt 1] @@ -335,7 +376,7 @@ test clock-4.40 {2nd monday in november} knownBug { } set res } {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11} -test clock-4.41 {2nd monday in november (2nd try)} knownBug { +test clock-4.45 {2nd monday in november (2nd try)} knownBug { set res {} foreach i {91 92 93 94 95 96} { set nov1th [clock scan 11/1/$i -gmt 1] @@ -344,7 +385,7 @@ test clock-4.41 {2nd monday in november (2nd try)} knownBug { } set res } {1991-11-11 1992-11-09 1993-11-08 1994-11-14 1995-11-13 1996-11-11} -test clock-4.40 {last monday in november} knownBug { +test clock-4.46 {last monday in november} knownBug { set res {} foreach i {91 92 93 94 95 96} { set dec1th [clock scan 12/1/$i -gmt 1] @@ -353,7 +394,7 @@ test clock-4.40 {last monday in november} knownBug { } set res } {1991-11-25 1992-11-30 1993-11-29 1994-11-28 1995-11-27 1996-11-25} -test clock-4.41 {ago with multiple relative units} { +test clock-4.47 {ago with multiple relative units} { set base [clock scan "12/31/1999 00:00:00"] set res [clock scan "2 days 2 hours ago" -base $base] expr {$base - $res} |