diff options
author | sergey.brester <sergey.brester> | 2019-02-12 20:37:11 (GMT) |
---|---|---|
committer | sergey.brester <sergey.brester> | 2019-02-12 20:37:11 (GMT) |
commit | f7183b361eac28e93e37b226ab5fd1b1166b882c (patch) | |
tree | 25cbfba9f96e0dbd47ef556bc9fddbcb80782ab4 /tests/cmdMZ.test | |
parent | e0587d15645be0b1c8a11d3b4ea82a23ecebf595 (diff) | |
download | tcl-f7183b361eac28e93e37b226ab5fd1b1166b882c.zip tcl-f7183b361eac28e93e37b226ab5fd1b1166b882c.tar.gz tcl-f7183b361eac28e93e37b226ab5fd1b1166b882c.tar.bz2 |
few test cases for timerate command
Diffstat (limited to 'tests/cmdMZ.test')
-rw-r--r-- | tests/cmdMZ.test | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test index 7fe4fda..fcb09df 100644 --- a/tests/cmdMZ.test +++ b/tests/cmdMZ.test @@ -347,6 +347,51 @@ test cmdMZ-5.7 {Tcl_TimeObjCmd: errors generate right trace} { invoked from within "time {error foo}"}} +test cmdMZ-6.1 {Tcl_TimeRateObjCmd: basic format of command} { + list [catch {timerate} msg] $msg +} {1 {wrong # args: should be "timerate ?-direct? ?-calibrate? ?-overhead double? command ?time?"}} +test cmdMZ-6.2 {Tcl_TimeRateObjCmd: basic format of command} { + list [catch {timerate a b c} msg] $msg +} {1 {wrong # args: should be "timerate ?-direct? ?-calibrate? ?-overhead double? command ?time?"}} +test cmdMZ-6.3 {Tcl_TimeRateObjCmd: basic format of command} { + list [catch {timerate a b} msg] $msg +} {1 {expected integer but got "b"}} +test cmdMZ-6.4 {Tcl_TimeRateObjCmd: compile of script happens even with negative iteration counts} { + list [catch {timerate "foreach a {c d e} \{" -12456} msg] $msg +} {1 {missing close-brace}} +test cmdMZ-6.5 {Tcl_TimeRateObjCmd: result format and one iteration} { + regexp {^\d+.\d+ [.]s/# 1 # \d+ #/sec \d+.\d+ nett-ms$} [timerate {} 0] +} 1 +test cmdMZ-6.6 {Tcl_TimeRateObjCmd: slower commands take longer, but it remains almost the same time of measument} { + set m1 [timerate {after 0} 20] + set m2 [timerate {after 1} 20] + list \ + [expr {[lindex $m1 0] < [lindex $m2 0]}] \ + [expr {[lindex $m1 0] < 100}] \ + [expr {[lindex $m2 0] >= 500}] \ + [expr {[lindex $m1 2] > 1000}] \ + [expr {[lindex $m2 2] <= 50}] \ + [expr {[lindex $m1 4] > 10000}] \ + [expr {[lindex $m2 4] < 10000}] \ + [expr {[lindex $m1 6] > 10 && [lindex $m1 6] < 50}] \ + [expr {[lindex $m2 6] > 10 && [lindex $m2 6] < 50}] +} [lrepeat 9 1] +test cmdMZ-6.7 {Tcl_TimeRateObjCmd: errors generate right trace} { + list [catch {timerate {error foo} 1} msg] $msg $::errorInfo +} {1 foo {foo + while executing +"error foo" + invoked from within +"timerate {error foo} 1"}} +test cmdMZ-6.8 {Tcl_TimeRateObjCmd: allow (conditional) break from timerate} { + set m1 [timerate {break}] + list \ + [expr {[lindex $m1 0] < 1000}] \ + [expr {[lindex $m1 2] == 1}] \ + [expr {[lindex $m1 4] > 1000}] \ + [expr {[lindex $m1 6] < 10}] +} {1 1 1 1} + # The tests for Tcl_WhileObjCmd are in while.test # cleanup |