diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2016-10-30 08:22:13 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2016-10-30 08:22:13 (GMT) |
commit | df54f23b9fdd17bc3eb02a15f3fd9513e6261b7e (patch) | |
tree | 9489c28b23fbc0776089d0eae84daa8addbd0f44 /tests | |
parent | 4ebcee3015caa6c14ae484220d113c943bc1f736 (diff) | |
download | tcl-df54f23b9fdd17bc3eb02a15f3fd9513e6261b7e.zip tcl-df54f23b9fdd17bc3eb02a15f3fd9513e6261b7e.tar.gz tcl-df54f23b9fdd17bc3eb02a15f3fd9513e6261b7e.tar.bz2 |
[1ae12987cb] Ensure that deleting the [history] command deletes its storage.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/history.test | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/tests/history.test b/tests/history.test index 7549beb..3201ad7 100644 --- a/tests/history.test +++ b/tests/history.test @@ -11,8 +11,8 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest +if {"::tcltest" ni [namespace children]} { + package require tcltest 2 namespace import -force ::tcltest::* } @@ -245,6 +245,60 @@ test history-9.2 {miscellaneous} history { catch {history gorp} msg set msg } {unknown or ambiguous subcommand "gorp": must be add, change, clear, event, info, keep, nextid, or redo} + +# History retains references; Bug 1ae12987cb +test history-10.1 {references kept by history} -constraints history -setup { + interp create histtest + histtest eval { + # Trigger any autoloading that might be present + catch {history} + proc refcount {x} { + set rep [::tcl::unsupported::representation $x] + regexp {with a refcount of (\d+)} $rep -> rc + # Ignore the references due to calling this procedure + return [expr {$rc - 3}] + } + } +} -body { + histtest eval { + # A fresh object, refcount 1 from the variable we write it to + set obj [expr rand()] + set baseline [refcount $obj] + lappend result [refcount $obj] + history add [list list $obj] + lappend result [refcount $obj] + history clear + lappend result [refcount $obj] + } +} -cleanup { + interp delete histtest +} -result {1 2 1} +test history-10.2 {references kept by history} -constraints history -setup { + interp create histtest + histtest eval { + # Trigger any autoloading that might be present + catch {history} + proc refcount {x} { + set rep [::tcl::unsupported::representation $x] + regexp {with a refcount of (\d+)} $rep -> rc + # Ignore the references due to calling this procedure + return [expr {$rc - 3}] + } + } +} -body { + histtest eval { + # A fresh object, refcount 1 from the variable we write it to + set obj [expr rand()] + set baseline [refcount $obj] + lappend result [refcount $obj] + history add [list list $obj] + lappend result [refcount $obj] + rename history {} + lappend result [refcount $obj] + } +} -cleanup { + interp delete histtest +} -result {1 2 1} # cleanup ::tcltest::cleanupTests |