build: Fix out-of-tree build with json ext
[jimtcl.git] / tests / clock.test
blob4e32df48caf095fc208731ec4ee93cfc28fc5a15
1 source [file dirname [info script]]/testing.tcl
3 needs cmd clock
5 if {[catch {clock scan 2000 -format %Y}]} {
6     testConstraint clockscan 0
7 } else {
8     testConstraint clockscan 1
11 test clock-1.1 {clock usage} -body {
12     clock
13 } -returnCodes error -match glob -result {wrong # args: should be "clock command ..."*}
15 test clock-1.2 {clock usage} -body {
16     clock blah
17 } -returnCodes error -match glob -result {clock, unknown command "blah": should be clicks, format, microseconds, milliseconds, *seconds}
19 # clock format
20 test clock-3.1 {clock format tests} {
21     set clockval 657687766
22     clock format $clockval -format {%a %b %d %I:%M:%S %p %Y} -gmt true
23 } {Sun Nov 04 03:02:46 AM 1990}
25 test clock-3.5 {clock format tests} -body {
26     clock format
27 } -returnCodes error -result {wrong # args: should be "clock format seconds ?-format string? ?-gmt boolean?"}
29 test clock-3.6 {clock format tests} -body {
30     clock format foo
31 } -returnCodes error -result {expected integer but got "foo"}
33 test clock-3.8 {clock format tests} -body {
34     clock format a b c d e g
35 } -returnCodes error -result {wrong # args: should be "clock format seconds ?-format string? ?-gmt boolean?"}
37 test clock-3.9 {clock format tests} {
38     set clockval 0
39     clock format $clockval -format "%a %b %d %I:%M:%S %p %Y" -gmt true
40 } "Thu Jan 01 12:00:00 AM 1970"
42 test clock-3.10 {clock format tests} -body {
43     clock format 123 -bad arg
44 } -returnCodes error -result {bad option "-bad": must be -format, or -gmt}
46 test clock-3.11 {clock format tests} {
47     clock format 123 -format "x"
48 } x
50 test clock-4.1 {clock scan tests} clockscan {
51     clock scan {Sun Nov 04 03:02:46 AM 1990} -format {%a %b %d %I:%M:%S %p %Y} -gmt true
52 } 657687766
54 testreport