From 3c65ba95ecb75cd18f050d33187a2f7e61dcb370 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 19 Jul 2002 08:52:27 +0000 Subject: Added tests for the [time] command. --- ChangeLog | 2 ++ tests/cmdMZ.test | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9eb7dd..9b3a8e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2002-07-19 Donal K. Fellows * tests/cmdMZ.test: Renamed constraint for clarity. [Bug#583427] + Added tests for the [time] command, which was previously only + indirectly tested! 2002-07-18 Vince Darley diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test index a948a21..0e65229 100644 --- a/tests/cmdMZ.test +++ b/tests/cmdMZ.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: cmdMZ.test,v 1.12 2002/07/19 08:36:51 dkf Exp $ +# RCS: @(#) $Id: cmdMZ.test,v 1.13 2002/07/19 08:52:27 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -166,7 +166,33 @@ test cmdMZ-4.13 {Tcl_SplitObjCmd: basic split commands} { # The tests for Tcl_StringObjCmd are in string.test # The tests for Tcl_SubstObjCmd are in subst.test # The tests for Tcl_SwitchObjCmd are in switch.test -# There are no tests for Tcl_TimeObjCmd + +test cmdMZ-5.1 {Tcl_TimeObjCmd: basic format of command} { + list [catch {time} msg] $msg +} {1 {wrong # args: should be "time command ?count?"}} +test cmdMZ-5.2 {Tcl_TimeObjCmd: basic format of command} { + list [catch {time a b c} msg] $msg +} {1 {wrong # args: should be "time command ?count?"}} +test cmdMZ-5.3 {Tcl_TimeObjCmd: basic format of command} { + list [catch {time a b} msg] $msg +} {1 {expected integer but got "b"}} +test cmdMZ-5.4 {Tcl_TimeObjCmd: nothing happens with negative iteration counts} { + time bogusCmd -12456 +} {0 microseconds per iteration} +test cmdMZ-5.5 {Tcl_TimeObjCmd: result format} { + regexp {^\d+ microseconds per iteration} [time {format 1}] +} 1 +test cmdMZ-5.6 {Tcl_TimeObjCmd: slower commands take longer} { + expr {[lindex [time {after 2}] 0] < [lindex [time {after 1000}] 0]} +} 1 +test cmdMZ-5.7 {Tcl_TimeObjCmd: errors generate right trace} { + list [catch {time {error foo}} msg] $msg $::errorInfo +} {1 foo {foo + while executing +"error foo" + invoked from within +"time {error foo}"}} + # The tests for Tcl_TraceObjCmd and TraceVarProc are in trace.test # The tests for Tcl_WhileObjCmd are in while.test -- cgit v0.12