OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [tests/] [clock.test] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Commands covered:  clock
2
#
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.
6
#
7
# Copyright (c) 1995-1997 Sun Microsystems, Inc.
8
#
9
# See the file "license.terms" for information on usage and redistribution
10
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11
#
12
# RCS: @(#) $Id: clock.test,v 1.1.1.1 2002-01-16 10:25:35 markom Exp $
13
 
14
if {[string compare test [info procs test]] == 1} then {source defs}
15
 
16
test clock-1.1 {clock tests} {
17
    list [catch {clock} msg] $msg
18
} {1 {wrong # args: should be "clock option ?arg ...?"}}
19
test clock-1.2 {clock tests} {
20
    list [catch {clock foo} msg] $msg
21
} {1 {bad option "foo": must be clicks, format, scan, or seconds}}
22
 
23
# clock clicks
24
test clock-2.1 {clock clicks tests} {
25
    expr [clock clicks]+1
26
    concat {}
27
} {}
28
test clock-2.2 {clock clicks tests} {
29
    list [catch {clock clicks foo} msg] $msg
30
} {1 {wrong # args: should be "clock clicks"}}
31
test clock-2.3 {clock clicks tests} {
32
    set start [clock clicks]
33
    after 10
34
    set end [clock clicks]
35
    expr "$end > $start"
36
} {1}
37
 
38
# clock format
39
test clock-3.1 {clock format tests} {unixOnly} {
40
    set clockval 657687766
41
    clock format $clockval -format {%a %b %d %I:%M:%S %p %Y} -gmt true
42
} {Sun Nov 04 03:02:46 AM 1990}
43
test clock-3.2 {clock format tests} {
44
    list [catch {clock format} msg] $msg
45
} {1 {wrong # args: should be "clock format clockval ?-format string? ?-gmt boolean?"}}
46
test clock-3.3 {clock format tests} {
47
    list [catch {clock format foo} msg] $msg
48
} {1 {expected integer but got "foo"}}
49
test clock-3.4 {clock format tests} {unixOrPc} {
50
    set clockval 657687766
51
    clock format $clockval -format "%a %b %d %I:%M:%S %p %Y" -gmt true
52
} "Sun Nov 04 03:02:46 AM 1990"
53
test clock-3.5 {clock format tests} {
54
    list [catch {clock format a b c d e g} msg] $msg
55
} {1 {wrong # args: should be "clock format clockval ?-format string? ?-gmt boolean?"}}
56
test clock-3.6 {clock format tests} {unixOrPc nonPortable} {
57
    set clockval -1
58
    clock format $clockval -format "%a %b %d %I:%M:%S %p %Y" -gmt true
59
} "Wed Dec 31 11:59:59 PM 1969"
60
test clock-3.7 {clock format tests} {
61
    list [catch {clock format 123 -bad arg} msg] $msg
62
} {1 {bad switch "-bad": must be -format, or -gmt}}
63
test clock-3.8 {clock format tests} {
64
    clock format 123 -format "x"
65
} x
66
test clock-3.9 {clock format tests} {
67
    clock format 123 -format ""
68
} ""
69
 
70
# clock scan
71
test clock-4.1 {clock scan tests} {
72
    list [catch {clock scan} msg] $msg
73
} {1 {wrong # args: should be "clock scan dateString ?-base clockValue? ?-gmt boolean?"}}
74
test clock-4.2 {clock scan tests} {
75
    list [catch {clock scan "bad-string"} msg] $msg
76
} {1 {unable to convert date-time string "bad-string"}}
77
test clock-4.3 {clock scan tests} {
78
    clock format [clock scan "14 Feb 92" -gmt true] \
79
      -format {%m/%d/%y %I:%M:%S %p} -gmt true
80
} {02/14/92 12:00:00 AM}
81
test clock-4.4 {clock scan tests} {
82
    clock format [clock scan "Feb 14, 1992 12:20 PM" -gmt true] \
83
      -format {%m/%d/%y %I:%M:%S %p} -gmt true
84
} {02/14/92 12:20:00 PM}
85
test clock-4.5 {clock scan tests} {
86
    clock format \
87
      [clock scan "Feb 14, 1992 12:20 PM" -base 319363200 -gmt true] \
88
      -format {%m/%d/%y %I:%M:%S %p} -gmt true
89
} {02/14/92 12:20:00 PM}
90
test clock-4.6 {clock scan tests} {
91
    set time [clock scan "Oct 23,1992 15:00"]
92
    clock format $time -format {%b %d,%Y %H:%M}
93
} {Oct 23,1992 15:00}
94
test clock-4.7 {clock scan tests} {
95
    set time [clock scan "Oct 23,1992 15:00 GMT"]
96
    clock format $time -format {%b %d,%Y %H:%M GMT} -gmt true
97
} {Oct 23,1992 15:00 GMT}
98
test clock-4.8 {clock scan tests} {
99
    set time [clock scan "Oct 23,1992 15:00" -gmt true]
100
    clock format $time -format {%b %d,%Y %H:%M GMT} -gmt true
101
} {Oct 23,1992 15:00 GMT}
102
test clock-4.9 {clock scan tests} {
103
    list [catch {clock scan "Jan 12" -bad arg} msg] $msg
104
} {1 {bad switch "-bad": must be -base, or -gmt}}
105
# The following two two tests test the two year date policy
106
test clock-4.10 {clock scan tests} {
107
    set time [clock scan "1/1/71" -gmt true]
108
    clock format $time -format {%b %d,%Y %H:%M GMT} -gmt true
109
} {Jan 01,1971 00:00 GMT}
110
test clock-4.11 {clock scan tests} {
111
    set time [clock scan "1/1/37" -gmt true]
112
    clock format $time -format {%b %d,%Y %H:%M GMT} -gmt true
113
} {Jan 01,2037 00:00 GMT}
114
 
115
# clock seconds
116
test clock-5.1 {clock seconds tests} {
117
    expr [clock seconds]+1
118
    concat {}
119
} {}
120
test clock-5.2 {clock seconds tests} {
121
    list [catch {clock seconds foo} msg] $msg
122
} {1 {wrong # args: should be "clock seconds"}}
123
test clock-5.3 {clock seconds tests} {
124
    set start [clock seconds]
125
    after 2000
126
    set end [clock seconds]
127
    expr "$end > $start"
128
} {1}
129
 
130
# The following dates check certain roll over dates
131
set day [expr 24 * 60 * 60]
132
test clock-6.1 {clock roll over dates} {
133
    set time [clock scan "12/31/1998" -gmt true]
134
    clock format [expr $time + $day] -format {%b %d,%Y %H:%M GMT} -gmt true
135
} {Jan 01,1999 00:00 GMT}
136
test clock-6.2 {clock roll over dates} {
137
    set time [clock scan "12/31/1999" -gmt true]
138
    clock format [expr $time + $day] -format {%b %d,%Y %H:%M GMT} -gmt true
139
} {Jan 01,2000 00:00 GMT}
140
test clock-6.3 {clock roll over dates} {
141
    set time [clock scan "2/28/2000" -gmt true]
142
    clock format [expr $time + $day] -format {%b %d,%Y %H:%M GMT} -gmt true
143
} {Feb 29,2000 00:00 GMT}
144
test clock-6.4 {clock roll over dates} {
145
    set time [clock scan "2/29/2000" -gmt true]
146
    clock format [expr $time + $day] -format {%b %d,%Y %H:%M GMT} -gmt true
147
} {Mar 01,2000 00:00 GMT}
148
test clock-6.5 {clock roll over dates} {
149
    set time [clock scan "January 1, 2000" -gmt true]
150
    clock format $time -format %A -gmt true
151
} {Saturday}
152
test clock-6.6 {clock roll over dates} {
153
    set time [clock scan "January 1, 2000" -gmt true]
154
    clock format $time -format %j -gmt true
155
} {001}
156
test clock-6.7 {clock roll over dates} {
157
    set time [clock scan "February 29, 2000" -gmt true]
158
    clock format $time -format %A -gmt true
159
} {Tuesday}
160
test clock-6.8 {clock roll over dates} {
161
    set time [clock scan "February 29, 2000" -gmt true]
162
    clock format $time -format %j -gmt true
163
} {060}
164
test clock-6.9 {clock roll over dates} {
165
    set time [clock scan "March 1, 2000" -gmt true]
166
    clock format $time -format %A -gmt true
167
} {Wednesday}
168
test clock-6.10 {clock roll over dates} {
169
    set time [clock scan "March 1, 2000" -gmt true]
170
    clock format $time -format %j -gmt true
171
} {061}
172
test clock-6.11 {clock roll over dates} {
173
    set time [clock scan "March 1, 2001" -gmt true]
174
    clock format $time -format %j -gmt true
175
} {060}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.