summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2003-06-25 23:02:10 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2003-06-25 23:02:10 (GMT)
commit43e3bcc7712f80d3c36696dbc1f9349f2819fe27 (patch)
tree9e458c1fda7815410cef063c83bd16dfb8e14927 /tests
parentb2985d83d53d176dc990188526b12b93860253c7 (diff)
downloadtcl-43e3bcc7712f80d3c36696dbc1f9349f2819fe27.zip
tcl-43e3bcc7712f80d3c36696dbc1f9349f2819fe27.tar.gz
tcl-43e3bcc7712f80d3c36696dbc1f9349f2819fe27.tar.bz2
Factored out the trace code - it's big enough to be its own maintenance area
and tricky enough to discourage non-specialists...
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.test64
-rw-r--r--tests/cmdMZ.test3
-rw-r--r--tests/trace.test61
3 files changed, 63 insertions, 65 deletions
diff --git a/tests/basic.test b/tests/basic.test
index 0257ded..fac8dbf 100644
--- a/tests/basic.test
+++ b/tests/basic.test
@@ -15,21 +15,16 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: basic.test,v 1.27 2003/05/05 16:48:54 dkf Exp $
+# RCS: @(#) $Id: basic.test,v 1.28 2003/06/25 23:02:11 dkf Exp $
#
package require tcltest 2
namespace import -force ::tcltest::*
testConstraint testcmdtoken [llength [info commands testcmdtoken]]
-testConstraint testcmdtrace [llength [info commands testcmdtrace]]
testConstraint testcreatecommand [llength [info commands testcreatecommand]]
testConstraint exec [llength [info commands exec]]
-# This variable needs to be changed when the major or minor version number for
-# Tcl changes.
-set tclvers 8.5
-
catch {namespace delete test_ns_basic}
catch {interp delete test_interp}
catch {rename p ""}
@@ -483,62 +478,7 @@ test basic-37.1 {Tcl_ExprString: see expr.test} {emptyTest} {
test basic-38.1 {Tcl_ExprObj} {emptyTest} {
} {}
-test basic-39.1 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {testcmdtrace} {
- testcmdtrace tracetest {set stuff [expr 14 + 16]}
-} {{expr 14 + 16} {expr 14 + 16} {set stuff [expr 14 + 16]} {set stuff 30}}
-test basic-39.2 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {testcmdtrace} {
- testcmdtrace tracetest {set stuff [info tclversion]}
-} [list {info tclversion} {info tclversion} {set stuff [info tclversion]} "set stuff $tclvers"]
-test basic-39.3 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {testcmdtrace} {
- testcmdtrace deletetest {set stuff [info tclversion]}
-} $tclvers
-test basic-39.4 {Tcl_CreateTrace, check that tracing doesn't cause memory faults} {testcmdtrace} {
- # Note that the proc call is the same as the variable name, and that
- # the call can be direct or indirect by way of another procedure
- proc tracer {args} {}
- proc tracedLoop {level} {
- incr level
- tracer
- foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}
- }
- testcmdtrace tracetest {tracedLoop 0}
-} {{tracedLoop 0} {tracedLoop 0} {incr level} {incr level} tracer {tracer} {expr {$level==1 ? {1 2} : {}}} {expr {$level==1 ? {1 2} : {}}} {foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}} {foreach tracer {1 2} {tracedLoop $level}} {tracedLoop $level} {tracedLoop 1} {incr level} {incr level} tracer {tracer} {expr {$level==1 ? {1 2} : {}}} {expr {$level==1 ? {1 2} : {}}} {foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}} {foreach tracer {} {tracedLoop $level}} {tracedLoop $level} {tracedLoop 1} {incr level} {incr level} tracer {tracer} {expr {$level==1 ? {1 2} : {}}} {expr {$level==1 ? {1 2} : {}}} {foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}} {foreach tracer {} {tracedLoop $level}}}
-catch {rename tracer {}}
-catch {rename tracedLoop {}}
-
-test basic-39.5 {Tcl_CreateObjTrace, status return TCL_ERROR} {testcmdtrace} {
- proc Error { args } { error "Shouldn't get here" }
- set x 1;
- list [catch {testcmdtrace resulttest {Error $x}} result] [set result]
-} {1 {Error $x}}
-
-test basic-39.6 {Tcl_CreateObjTrace, status return TCL_RETURN} {testcmdtrace} {
- proc Return { args } { error "Shouldn't get here" }
- set x 1;
- list [catch {testcmdtrace resulttest {Return $x}} result] [set result]
-} {2 {}}
-
-test basic-39.7 {Tcl_CreateObjTrace, status return TCL_BREAK} {testcmdtrace} {
- proc Break { args } { error "Shouldn't get here" }
- set x 1;
- list [catch {testcmdtrace resulttest {Break $x}} result] [set result]
-} {3 {}}
-
-test basic-39.8 {Tcl_CreateObjTrace, status return TCL_CONTINUE} {testcmdtrace} {
- proc Continue { args } { error "Shouldn't get here" }
- set x 1;
- list [catch {testcmdtrace resulttest {Continue $x}} result] [set result]
-} {4 {}}
-
-test basic-39.9 {Tcl_CreateObjTrace, status return unknown} {testcmdtrace} {
- proc OtherStatus { args } { error "Shouldn't get here" }
- set x 1;
- list [catch {testcmdtrace resulttest {OtherStatus $x}} result] [set result]
-} {6 {}}
-
-test basic-40.1 {Tcl_DeleteTrace} {emptyTest} {
- # the above tests have tested Tcl_DeleteTrace
-} {}
+# Tests basic-39.* and basic-40.* refactored into trace.test
test basic-41.1 {Tcl_AddErrorInfo} {emptyTest} {
} {}
diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test
index 4da945f..bcaa690 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.15 2003/05/12 20:15:28 dgp Exp $
+# RCS: @(#) $Id: cmdMZ.test,v 1.16 2003/06/25 23:02:11 dkf Exp $
if {[catch {package require tcltest 2.0.2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2.0.2 required."
@@ -307,7 +307,6 @@ test cmdMZ-5.7 {Tcl_TimeObjCmd: errors generate right trace} {
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
# cleanup
diff --git a/tests/trace.test b/tests/trace.test
index f757619..6f3dd9c 100644
--- a/tests/trace.test
+++ b/tests/trace.test
@@ -11,13 +11,15 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: trace.test,v 1.28 2003/05/07 21:15:44 dkf Exp $
+# RCS: @(#) $Id: trace.test,v 1.29 2003/06/25 23:02:11 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
}
+testConstraint testcmdtrace [llength [info commands testcmdtrace]]
+
proc traceScalar {name1 name2 op} {
global info
set info [list $name1 $name2 $op [catch {uplevel set $name1} msg] $msg]
@@ -2093,6 +2095,63 @@ test trace-28.10 {exec trace info nonsense} {
list [catch {trace remove execution} res] $res
} {1 {wrong # args: should be "trace remove execution name opList command"}}
+test trace-29.1 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {testcmdtrace} {
+ testcmdtrace tracetest {set stuff [expr 14 + 16]}
+} {{expr 14 + 16} {expr 14 + 16} {set stuff [expr 14 + 16]} {set stuff 30}}
+test trace-29.2 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {testcmdtrace} {
+ testcmdtrace tracetest {set stuff [info tclversion]}
+} [list {info tclversion} {info tclversion} {set stuff [info tclversion]} "set stuff [info tclversion]"]
+test trace-29.3 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {testcmdtrace} {
+ testcmdtrace deletetest {set stuff [info tclversion]}
+} [info tclversion]
+test trace-29.4 {Tcl_CreateTrace, check that tracing doesn't cause memory faults} {testcmdtrace} {
+ # Note that the proc call is the same as the variable name, and that
+ # the call can be direct or indirect by way of another procedure
+ proc tracer {args} {}
+ proc tracedLoop {level} {
+ incr level
+ tracer
+ foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}
+ }
+ testcmdtrace tracetest {tracedLoop 0}
+} {{tracedLoop 0} {tracedLoop 0} {incr level} {incr level} tracer {tracer} {expr {$level==1 ? {1 2} : {}}} {expr {$level==1 ? {1 2} : {}}} {foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}} {foreach tracer {1 2} {tracedLoop $level}} {tracedLoop $level} {tracedLoop 1} {incr level} {incr level} tracer {tracer} {expr {$level==1 ? {1 2} : {}}} {expr {$level==1 ? {1 2} : {}}} {foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}} {foreach tracer {} {tracedLoop $level}} {tracedLoop $level} {tracedLoop 1} {incr level} {incr level} tracer {tracer} {expr {$level==1 ? {1 2} : {}}} {expr {$level==1 ? {1 2} : {}}} {foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}} {foreach tracer {} {tracedLoop $level}}}
+catch {rename tracer {}}
+catch {rename tracedLoop {}}
+
+test trace-29.5 {Tcl_CreateObjTrace, status return TCL_ERROR} {testcmdtrace} {
+ proc Error { args } { error "Shouldn't get here" }
+ set x 1;
+ list [catch {testcmdtrace resulttest {Error $x}} result] [set result]
+} {1 {Error $x}}
+
+test trace-29.6 {Tcl_CreateObjTrace, status return TCL_RETURN} {testcmdtrace} {
+ proc Return { args } { error "Shouldn't get here" }
+ set x 1;
+ list [catch {testcmdtrace resulttest {Return $x}} result] [set result]
+} {2 {}}
+
+test trace-29.7 {Tcl_CreateObjTrace, status return TCL_BREAK} {testcmdtrace} {
+ proc Break { args } { error "Shouldn't get here" }
+ set x 1;
+ list [catch {testcmdtrace resulttest {Break $x}} result] [set result]
+} {3 {}}
+
+test trace-29.8 {Tcl_CreateObjTrace, status return TCL_CONTINUE} {testcmdtrace} {
+ proc Continue { args } { error "Shouldn't get here" }
+ set x 1;
+ list [catch {testcmdtrace resulttest {Continue $x}} result] [set result]
+} {4 {}}
+
+test trace-29.9 {Tcl_CreateObjTrace, status return unknown} {testcmdtrace} {
+ proc OtherStatus { args } { error "Shouldn't get here" }
+ set x 1;
+ list [catch {testcmdtrace resulttest {OtherStatus $x}} result] [set result]
+} {6 {}}
+
+test trace-30.1 {Tcl_DeleteTrace} {emptyTest} {
+ # the above tests have tested Tcl_DeleteTrace
+} {}
+
# Delete procedures when done, so we don't clash with other tests
# (e.g. foobar will clash with 'unknown' tests).
catch {rename foobar {}}