diff options
author | Kevin B Kenny <kennykb@acm.org> | 2003-04-12 19:08:33 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2003-04-12 19:08:33 (GMT) |
commit | d9d5ceb548007b7defbb5645b67360bab19d188a (patch) | |
tree | 10de907612fc1a0378ac5d6c42cee184ae2785ff /tests | |
parent | 1e3d8de94601b1efb0a694e0f756a0beeeded462 (diff) | |
download | tcl-d9d5ceb548007b7defbb5645b67360bab19d188a.zip tcl-d9d5ceb548007b7defbb5645b67360bab19d188a.tar.gz tcl-d9d5ceb548007b7defbb5645b67360bab19d188a.tar.bz2 |
Implemented TIP #124 (clock clicks -microseconds and Tcl_WideInt
return values). Fixed Bug 710310 (duplicate test numbers in
clock.test). Made major changes to tclWinTime.c and related code
to improve loop filter stability.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/clock.test | 107 | ||||
-rw-r--r-- | tests/winTime.test | 28 |
2 files changed, 83 insertions, 52 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} diff --git a/tests/winTime.test b/tests/winTime.test index 8645fc8..787fb58 100644 --- a/tests/winTime.test +++ b/tests/winTime.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: winTime.test,v 1.8 2003/02/27 23:47:01 hobbs Exp $ +# RCS: @(#) $Id: winTime.test,v 1.9 2003/04/12 19:08:55 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -36,24 +36,26 @@ test winTime-1.2 {TclpGetDate} {pcOnly} { } {1969} # Next test tries to make sure that the Tcl clock stays in step -# with the Windows clock. 3000 iterations really isn't enough, -# but how many does a tester have patience for? +# with the Windows clock. 30 sec really isn't enough, +# but how much time does a tester have patience for? test winTime-2.1 {Synchronization of Tcl and Windows clocks} {testwinclock} { # May fail due to OS/hardware discrepancies. See: # http://support.microsoft.com/default.aspx?scid=kb;en-us;274323 set failed {} set ok 1 - for { set i 0 } { $i < 3000 } { incr i } { - foreach { sys_sec sys_usec tcl_sec tcl_usec } [testwinclock] {} + foreach start_sec [testwinclock] break + while { 1 } { + foreach { sys_sec sys_usec tcl_sec tcl_usec } [testwinclock] break set diff [expr { $tcl_sec - $sys_sec + 1.0e-6 * ( $tcl_usec - $sys_usec ) }] - if { abs($diff) > 0.02 } { + if { abs($diff) > 0.06 } { set failed "Tcl clock differs from system clock by $diff sec" break } else { - after 10 + testwinsleep 1 } + if { $sys_sec - $start_sec >= 30 } break } set failed } {} @@ -61,15 +63,3 @@ test winTime-2.1 {Synchronization of Tcl and Windows clocks} {testwinclock} { # cleanup ::tcltest::cleanupTests return - - - - - - - - - - - - |