diff options
author | welch <welch> | 1999-03-31 19:54:25 (GMT) |
---|---|---|
committer | welch <welch> | 1999-03-31 19:54:25 (GMT) |
commit | d091c4b289fb135d5d7b70eac3302557a8f5cd0f (patch) | |
tree | aba270b39c7766f9c8449b3f4238ea630f676007 /tests/autoMkindex.test | |
parent | 4b19bd088d5b7499f08fd3186f42b55b1a197988 (diff) | |
download | tcl-d091c4b289fb135d5d7b70eac3302557a8f5cd0f.zip tcl-d091c4b289fb135d5d7b70eac3302557a8f5cd0f.tar.gz tcl-d091c4b289fb135d5d7b70eac3302557a8f5cd0f.tar.bz2 |
Tests for quoting bugs in auto_mkindex slavehook: BUGID 1657
Diffstat (limited to 'tests/autoMkindex.test')
-rw-r--r-- | tests/autoMkindex.test | 129 |
1 files changed, 117 insertions, 12 deletions
diff --git a/tests/autoMkindex.test b/tests/autoMkindex.test index b48e88d..bd11ee5 100644 --- a/tests/autoMkindex.test +++ b/tests/autoMkindex.test @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: autoMkindex.test,v 1.1.2.5 1999/03/24 02:48:57 hershey Exp $ +# RCS: @(#) $Id: autoMkindex.test,v 1.1.2.6 1999/03/31 19:54:25 welch Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -22,6 +22,23 @@ if {![catch {file copy $origMkindexFile $newMkindexFile}]} { set removeAutoMkindex 1 } +# Save initial state of auto_mkindex_parser + +auto_load auto_mkindex +if {[info exist auto_mkindex_parser::initCommands]} { + set saveCommands $auto_mkindex_parser::initCommands +} +proc AutoMkindexTestReset {} { + global saveCommands + if {[info exist saveCommands]} { + set auto_mkindex_parser::initCommands $saveCommands + } elseif {[info exist auto_mkindex_parser::initCommands]} { + unset auto_mkindex_parser::initCommands + } +} + +set result "" + test autoMkindex-1.1 {remove any existing tclIndex file} { file delete tclIndex file exists tclIndex @@ -35,21 +52,25 @@ test autoMkindex-1.2 {build tclIndex based on a test file} { set element "{source [file join . autoMkindex.tcl]}" test autoMkindex-1.3 {examine tclIndex} { + file delete tclIndex + auto_mkindex . autoMkindex.tcl namespace eval tcl_autoMkindex_tmp { set dir "." variable auto_index source tclIndex - set result "" + set ::result "" foreach elem [lsort [array names auto_index]] { - lappend result [list $elem $auto_index($elem)] + lappend ::result [list $elem $auto_index($elem)] } - set result } -} "{::buried::explicit $element} {::buried::inside $element} {::buried::pub_one $element} {::buried::pub_two $element} {::buried::relative $element} {::buried::under::neath $element} {::buried::within $element} {indented $element} {normal $element} {top $element}" + namespace delete tcl_autoMkindex_tmp + set ::result +} "{::buried::explicit $element} {::buried::inside $element} {{::buried::my proc} $element} {::buried::mycmd1 $element} {::buried::mycmd4 $element} {::buried::myproc $element} {::buried::pub_one $element} {::buried::pub_two $element} {::buried::relative $element} {::buried::under::neath $element} {::buried::within $element} {indented $element} {normal $element} {top $element}" -namespace delete tcl_autoMkindex_tmp test autoMkindex-2.1 {commands on the autoload path can be imported} { + file delete tclIndex + auto_mkindex . autoMkindex.tcl set interp [interp create] set final [$interp eval { namespace eval blt {} @@ -64,21 +85,105 @@ test autoMkindex-2.1 {commands on the autoload path can be imported} { set final } "0 {} pub_one ::buried::pub_one pub_two ::buried::pub_two" -# cleanup -if {[info exists removeAutoMkindex]} { - catch {file delete $newMkindexFile} -} -catch {file delete -force tclIndex} -::tcltest::cleanupTests +# Test auto_mkindex hooks +# Slave hook executes interesting code in the interp used to watch code. +test autoMkindex-3.1 {slaveHook} { + auto_mkindex_parser::slavehook { + _%@namespace eval ::blt { + proc foo {} {} + _%@namespace export foo + } + } + auto_mkindex_parser::slavehook { _%@namespace import -force ::blt::* } + file delete tclIndex + auto_mkindex . autoMkindex.tcl + + # Reset initCommands to avoid trashing other tests + AutoMkindexTestReset + file exists tclIndex +} 1 +# The auto_mkindex_parser::command is used to register commands +# that create new commands. +test autoMkindex-3.2 {auto_mkindex_parser::command} { + auto_mkindex_parser::command buried::myproc {name args} { + variable index + variable scriptFile + append index [list set auto_index([fullname $name])] \ + " \[list source \[file join \$dir [list $scriptFile]\]\]\n" + } + file delete tclIndex + auto_mkindex . autoMkindex.tcl + namespace eval tcl_autoMkindex_tmp { + set dir "." + variable auto_index + source tclIndex + set ::result "" + foreach elem [lsort [array names auto_index]] { + lappend ::result [list $elem $auto_index($elem)] + } + } + namespace delete tcl_autoMkindex_tmp + # Reset initCommands to avoid trashing other tests + AutoMkindexTestReset + set ::result +} "{::buried::explicit $element} {::buried::inside $element} {{::buried::my proc} $element} {::buried::mycmd1 $element} {::buried::mycmd2 $element} {::buried::mycmd4 $element} {::buried::myproc $element} {::buried::pub_one $element} {::buried::pub_two $element} {::buried::relative $element} {::buried::under::neath $element} {::buried::within $element} {indented $element} {mycmd3 $element} {normal $element} {top $element}" +test autoMkindex-3.3 {auto_mkindex_parser::command} {knownBug} { + auto_mkindex_parser::command {buried::my proc} {name args} { + variable index + variable scriptFile + puts "my proc $name" + append index [list set auto_index([fullname $name])] \ + " \[list source \[file join \$dir [list $scriptFile]\]\]\n" + } + file delete tclIndex + auto_mkindex . autoMkindex.tcl + namespace eval tcl_autoMkindex_tmp { + set dir "." + variable auto_index + source tclIndex + set ::result "" + foreach elem [lsort [array names auto_index]] { + lappend ::result [list $elem $auto_index($elem)] + } + } + namespace delete tcl_autoMkindex_tmp + + # Reset initCommands to avoid trashing other tests + + AutoMkindexTestReset + proc lvalue {list pattern} { + set ix [lsearch $list $pattern] + if {$ix >= 0} { + return [lindex $list $ix] + } else { + return {} + } + } + list [lvalue $::result *mycmd4*] [lvalue $::result *mycmd5*] [lvalue $::result *mycmd6*] +} "{::buried::mycmd4 $element} {::buried::mycmd5 $element} {mycmd6 $element}" +# Clean up. +unset result +AutoMkindexTestReset +if {[info exist saveCommands]} { + unset saveCommands +} +rename AutoMkindexTestReset "" +if {[info exists removeAutoMkindex]} { + catch {file delete $newMkindexFile} +} +if {[file exists tclIndex]} { + file delete -force tclIndex +} +::tcltest::cleanupTests |