summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2008-08-11 19:01:54 (GMT)
committerandreas_kupries <akupries@shaw.ca>2008-08-11 19:01:54 (GMT)
commit49f30082dd3c2a494c7a7bca131dbd509953c961 (patch)
tree83c9f82292818dd1c83e3e39efb972d185a0e914 /tests
parent7f38194f5e9dc40e7cff32fa65af88021011cfab (diff)
downloadtcl-49f30082dd3c2a494c7a7bca131dbd509953c961.zip
tcl-49f30082dd3c2a494c7a7bca131dbd509953c961.tar.gz
tcl-49f30082dd3c2a494c7a7bca131dbd509953c961.tar.bz2
* generic/tclProc.c (Tcl_ProcObjCmd): Fixed memory leak triggered
* tests/proc.test: by procbody::test::proc. See [Bug 2043636]. Added a test case demonstrating the leak before the fix. Fixed a few spelling errors in test descriptions as well.
Diffstat (limited to 'tests')
-rw-r--r--tests/proc.test36
1 files changed, 31 insertions, 5 deletions
diff --git a/tests/proc.test b/tests/proc.test
index 8fdc159..bb50979 100644
--- a/tests/proc.test
+++ b/tests/proc.test
@@ -13,7 +13,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: proc.test,v 1.19 2006/11/03 00:34:53 hobbs Exp $
+# RCS: @(#) $Id: proc.test,v 1.19.4.1 2008/08/11 19:02:02 andreas_kupries Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -26,6 +26,8 @@ if {[catch {package require procbodytest}]} {
testConstraint procbodytest 1
}
+testConstraint memory [llength [info commands memory]]
+
catch {namespace delete {*}[namespace children :: test_ns_*]}
catch {rename p ""}
catch {rename {} ""}
@@ -233,7 +235,7 @@ test proc-4.3 {TclCreateProc, procbody obj, too many args} procbodytest {
catch {rename t ""}
set result
} {procedure "t": arg list contains 3 entries, precompiled header expects 1}
-test proc-4.4 {TclCreateProc, procbody obj, inconsitent arg name} procbodytest {
+test proc-4.4 {TclCreateProc, procbody obj, inconsistent arg name} procbodytest {
catch {
proc p {x y z} {
set v [join [list $x $y $z]]
@@ -249,7 +251,7 @@ test proc-4.4 {TclCreateProc, procbody obj, inconsitent arg name} procbodytest {
catch {rename t ""}
set result
} {procedure "t": formal parameter 1 is inconsistent with precompiled body}
-test proc-4.5 {TclCreateProc, procbody obj, inconsitent arg default type} procbodytest {
+test proc-4.5 {TclCreateProc, procbody obj, inconsistent arg default type} procbodytest {
catch {
proc p {x y {z Z}} {
set v [join [list $x $y $z]]
@@ -265,7 +267,7 @@ test proc-4.5 {TclCreateProc, procbody obj, inconsitent arg default type} procbo
catch {rename t ""}
set result
} {procedure "t": formal parameter 2 is inconsistent with precompiled body}
-test proc-4.6 {TclCreateProc, procbody obj, inconsitent arg default type} procbodytest {
+test proc-4.6 {TclCreateProc, procbody obj, inconsistent arg default type} procbodytest {
catch {
proc p {x y z} {
set v [join [list $x $y $z]]
@@ -281,7 +283,7 @@ test proc-4.6 {TclCreateProc, procbody obj, inconsitent arg default type} procbo
catch {rename t ""}
set result
} {procedure "t": formal parameter 2 is inconsistent with precompiled body}
-test proc-4.7 {TclCreateProc, procbody obj, inconsitent arg default value} procbodytest {
+test proc-4.7 {TclCreateProc, procbody obj, inconsistent arg default value} procbodytest {
catch {
proc p {x y {z Z}} {
set v [join [list $x $y $z]]
@@ -297,6 +299,30 @@ test proc-4.7 {TclCreateProc, procbody obj, inconsitent arg default value} procb
catch {rename t ""}
set result
} {procedure "t": formal parameter "z" has default value inconsistent with precompiled body}
+test proc-4.8 {TclCreateProc, procbody obj, no leak on multiple iterations} -setup {
+ proc getbytes {} {
+ set lines [split [memory info] "\n"]
+ lindex $lines 3 3
+ }
+ proc px x {
+ set y [string tolower $x]
+ return "$x:$y"
+ }
+ px x
+} -constraints {procbodytest memory} -body {
+
+ set end [getbytes]
+ for {set i 0} {$i < 5} {incr i} {
+
+ procbodytest::proc tx x px
+
+ set tmp $end
+ set end [getbytes]
+ }
+ set leakedBytes [expr {$end - $tmp}]
+} -cleanup {
+ rename getbytes {}
+} -result 0
test proc-5.1 {Bytecompiling noop; test for correct argument substitution} {
proc p args {} ; # this will be bytecompiled into t