1 # This file tests the tclWinTime.c file.
3 # This file contains a collection of tests for one or more of the Tcl
4 # built-in commands. Sourcing this file into Tcl runs the tests and
5 # generates output for errors. No output means no errors were found.
7 # Copyright (c) 1997 Sun Microsystems, Inc.
8 # Copyright (c) 1998-1999 by Scriptics Corporation.
10 # See the file "license.terms" for information on usage and redistribution
11 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15 if {[lsearch [namespace children] ::tcltest] == -1} {
16 package require tcltest
17 namespace import -force ::tcltest::*
20 # The next two tests will crash on Windows if the check for negative
21 # clock values is not done properly.
23 test winTime-1.1 {TclpGetDate} {pcOnly} {
25 set result [clock format -1 -format %Y]
29 test winTime-1.2 {TclpGetDate} {pcOnly} {
31 set result [clock format 1 -format %Y]
36 # Next test tries to make sure that the Tcl clock stays in step
37 # with the Windows clock. 3000 iterations really isn't enough,
38 # but how many does a tester have patience for?
40 test winTime-2.1 {Synchronization of Tcl and Windows clocks} {pcOnly} {
42 foreach { sys_sec sys_usec tcl_sec tcl_usec } [testwinclock] {}
43 set olddiff [expr { abs ( $tcl_sec - $sys_sec
44 + 1.0e-6 * ( $tcl_usec - $sys_usec ) ) }]
46 for { set i 0 } { $i < 3000 } { incr i } {
47 foreach { sys_sec sys_usec tcl_sec tcl_usec } [testwinclock] {}
48 set diff [expr { abs ( $tcl_sec - $sys_sec
49 + 1.0e-6 * ( $tcl_usec - $sys_usec ) ) }]
50 if { ( $diff > $olddiff + 1000 )
51 || ( $diff > 11000 ) } {
63 ::tcltest::cleanupTests