summaryrefslogtreecommitdiffstats
path: root/tests/clock.test
diff options
context:
space:
mode:
authorstanton <stanton>1999-04-16 00:46:29 (GMT)
committerstanton <stanton>1999-04-16 00:46:29 (GMT)
commit97464e6cba8eb0008cf2727c15718671992b913f (patch)
treece9959f2747257d98d52ec8d18bf3b0de99b9535 /tests/clock.test
parenta8c96ddb94d1483a9de5e340b740cb74ef6cafa7 (diff)
downloadtcl-97464e6cba8eb0008cf2727c15718671992b913f.zip
tcl-97464e6cba8eb0008cf2727c15718671992b913f.tar.gz
tcl-97464e6cba8eb0008cf2727c15718671992b913f.tar.bz2
merged tcl 8.1 branch back into the main trunk
Diffstat (limited to 'tests/clock.test')
-rw-r--r--tests/clock.test74
1 files changed, 62 insertions, 12 deletions
diff --git a/tests/clock.test b/tests/clock.test
index 5fbee3a..d0072ad 100644
--- a/tests/clock.test
+++ b/tests/clock.test
@@ -4,14 +4,17 @@
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
-# Copyright (c) 1995-1997 Sun Microsystems, Inc.
+# Copyright (c) 1995-1998 Sun Microsystems, Inc.
+# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# 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.2 1998/09/14 18:40:07 stanton Exp $
+# RCS: @(#) $Id: clock.test,v 1.3 1999/04/16 00:47:24 stanton Exp $
-if {[string compare test [info procs test]] == 1} then {source defs}
+if {[lsearch [namespace children] ::tcltest] == -1} {
+ source [file join [pwd] [file dirname [info script]] defs.tcl]
+}
test clock-1.1 {clock tests} {
list [catch {clock} msg] $msg
@@ -41,29 +44,60 @@ test clock-3.1 {clock format tests} {unixOnly} {
clock format $clockval -format {%a %b %d %I:%M:%S %p %Y} -gmt true
} {Sun Nov 04 03:02:46 AM 1990}
test clock-3.2 {clock format tests} {
+ # TCL_USE_TIMEZONE_VAR
+
+ catch {set oldtz $env(TZ)}
+ set env(TZ) PST
+ set x {}
+ append x [clock format 863800000 -format %Z -gmt 1]
+ append x [set env(TZ)]
+ catch {unset env(TZ); set env(TZ) $oldtz}
+ set x
+} {GMTPST}
+test clock-3.3 {clock format tests} {
+ # tzset() under Borland doesn't seem to set up tzname[] for local
+ # timezone, which caused "clock format" to think that %Z was an invalid
+ # string. Don't care about answer, just that test runs w/o error.
+
+ clock format 863800000 -format %Z
+ set x {}
+} {}
+test clock-3.4 {clock format tests} {
+ # tzset() under Borland doesn't seem to set up tzname[] for gmt timezone.
+ # tzset() under MSVC has the following weird observed behavior:
+ # First time we call "clock format [clock seconds] -format %Z -gmt 1"
+ # we get "GMT", but on all subsequent calls we get the current time
+ # zone string, even though env(TZ) is GMT and the variable _timezone
+ # is 0.
+
+ set x {}
+ append x [clock format 863800000 -format %Z -gmt 1]
+ append x [clock format 863800000 -format %Z -gmt 1]
+} {GMTGMT}
+test clock-3.5 {clock format tests} {
list [catch {clock format} msg] $msg
} {1 {wrong # args: should be "clock format clockval ?-format string? ?-gmt boolean?"}}
-test clock-3.3 {clock format tests} {
+test clock-3.6 {clock format tests} {
list [catch {clock format foo} msg] $msg
} {1 {expected integer but got "foo"}}
-test clock-3.4 {clock format tests} {unixOrPc} {
+test clock-3.7 {clock format tests} {unixOrPc} {
set clockval 657687766
clock format $clockval -format "%a %b %d %I:%M:%S %p %Y" -gmt true
} "Sun Nov 04 03:02:46 AM 1990"
-test clock-3.5 {clock format tests} {
+test clock-3.8 {clock format tests} {
list [catch {clock format a b c d e g} msg] $msg
} {1 {wrong # args: should be "clock format clockval ?-format string? ?-gmt boolean?"}}
-test clock-3.6 {clock format tests} {unixOrPc nonPortable} {
+test clock-3.9 {clock format tests} {unixOrPc nonPortable} {
set clockval -1
clock format $clockval -format "%a %b %d %I:%M:%S %p %Y" -gmt true
} "Wed Dec 31 11:59:59 PM 1969"
-test clock-3.7 {clock format tests} {
+test clock-3.10 {clock format tests} {
list [catch {clock format 123 -bad arg} msg] $msg
-} {1 {bad switch "-bad": must be -format, or -gmt}}
-test clock-3.8 {clock format tests} {
+} {1 {bad switch "-bad": must be -format or -gmt}}
+test clock-3.11 {clock format tests} {
clock format 123 -format "x"
} x
-test clock-3.9 {clock format tests} {
+test clock-3.12 {clock format tests} {
clock format 123 -format ""
} ""
@@ -101,7 +135,7 @@ test clock-4.8 {clock scan tests} {
} {Oct 23,1992 15:00 GMT}
test clock-4.9 {clock scan tests} {
list [catch {clock scan "Jan 12" -bad arg} msg] $msg
-} {1 {bad switch "-bad": must be -base, or -gmt}}
+} {1 {bad switch "-bad": must be -base or -gmt}}
# The following two two tests test the two year date policy
test clock-4.10 {clock scan tests} {
set time [clock scan "1/1/71" -gmt true]
@@ -173,3 +207,19 @@ test clock-6.11 {clock roll over dates} {
set time [clock scan "March 1, 2001" -gmt true]
clock format $time -format %j -gmt true
} {060}
+
+# cleanup
+::tcltest::cleanupTests
+return
+
+
+
+
+
+
+
+
+
+
+
+