summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2018-11-12 09:53:47 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2018-11-12 09:53:47 (GMT)
commit237b0edf0d2fdc3583165a76a0e92598b9df75d9 (patch)
tree1c74ab753460186733e62b8f6cc90b70512ae8ba /tests
parentfa2ceeffffa5a2d4e4de3648f253bedc3d95e22d (diff)
parent77a9cc76b1beb1ebd8682d4ef2d06a850a124965 (diff)
downloadtcl-237b0edf0d2fdc3583165a76a0e92598b9df75d9.zip
tcl-237b0edf0d2fdc3583165a76a0e92598b9df75d9.tar.gz
tcl-237b0edf0d2fdc3583165a76a0e92598b9df75d9.tar.bz2
merge 8.6 to get Travis fixes
Diffstat (limited to 'tests')
-rw-r--r--tests/clock.test42
1 files changed, 23 insertions, 19 deletions
diff --git a/tests/clock.test b/tests/clock.test
index 4ec4db2..3ad5c9f 100644
--- a/tests/clock.test
+++ b/tests/clock.test
@@ -250,6 +250,16 @@ proc ::testClock::registry { cmd path key } {
return [dict get $reg $path $key]
}
+proc timeWithinDuration {duration start end} {
+ regexp {([\d.]+)(s|ms|us)} $duration -> duration unit
+ set delta [expr {$end - $start}]
+ expr {
+ ($delta > 0) && ($delta <= $duration) ?
+ "ok" :
+ "test should have taken 0-$duration $unit, actually took $delta"}
+}
+
+
# Test some of the basics of [clock format]
test clock-1.0 "clock format - wrong # args" {
@@ -35425,7 +35435,7 @@ test clock-33.2 {clock clicks tests} {
set start [clock clicks]
after 10
set end [clock clicks]
- expr "$end > $start"
+ expr {$end > $start}
} {1}
test clock-33.3 {clock clicks tests} {
list [catch {clock clicks foo} msg] $msg
@@ -35440,27 +35450,21 @@ test clock-33.4a {clock milliseconds} {
} {}
test clock-33.5 {clock clicks tests, millisecond timing test} {
# This test can fail on a system that is so heavily loaded that
- # the test takes >60 ms to run.
+ # the test takes >120 ms to run.
set start [clock clicks -milli]
after 10
set end [clock clicks -milli]
- # 60 msecs seems to be the max time slice under Windows 95/98
- expr {
- ($end > $start) && (($end - $start) <= 60) ?
- "ok" :
- "test should have taken 0-60 ms, actually took [expr $end - $start]"}
+ # 60 msecs seems to be the max time slice under Windows 95/98;
+ timeWithinDuration 120ms $start $end
} {ok}
test clock-33.5a {clock tests, millisecond timing test} {
# This test can fail on a system that is so heavily loaded that
- # the test takes >60 ms to run.
+ # the test takes >120 ms to run.
set start [clock milliseconds]
after 10
set end [clock milliseconds]
# 60 msecs seems to be the max time slice under Windows 95/98
- expr {
- ($end > $start) && (($end - $start) <= 60) ?
- "ok" :
- "test should have taken 0-60 ms, actually took [expr $end - $start]"}
+ timeWithinDuration 120ms $start $end
} {ok}
test clock-33.6 {clock clicks, milli with too much abbreviation} {
list [catch { clock clicks ? } msg] $msg
@@ -35471,20 +35475,20 @@ test clock-33.7 {clock clicks, milli with too much abbreviation} {
test clock-33.8 {clock clicks test, microsecond timing test} {
# This test can fail on a system that is so heavily loaded that
- # the test takes >60 ms to run.
+ # the test takes >120 ms to run.
set start [clock clicks -micro]
after 10
set end [clock clicks -micro]
- expr {($end > $start) && (($end - $start) <= 60000)}
-} {1}
+ timeWithinDuration 120000us $start $end
+} {ok}
test clock-33.8a {clock test, microsecond timing test} {
# This test can fail on a system that is so heavily loaded that
- # the test takes >60 ms to run.
+ # the test takes >120 ms to run.
set start [clock microseconds]
after 10
set end [clock microseconds]
- expr {($end > $start) && (($end - $start) <= 60000)}
-} {1}
+ timeWithinDuration 120000us $start $end
+} {ok}
test clock-33.9 {clock clicks test, millis align with seconds} {
set t1 [clock seconds]
@@ -35826,7 +35830,7 @@ test clock-35.3 {clock seconds tests} {
set start [clock seconds]
after 2000
set end [clock seconds]
- expr "$end > $start"
+ expr {$end > $start}
} {1}