diff options
Diffstat (limited to 'tests/autoMkindex.test')
-rw-r--r-- | tests/autoMkindex.test | 102 |
1 files changed, 96 insertions, 6 deletions
diff --git a/tests/autoMkindex.test b/tests/autoMkindex.test index c03fdae..562454b 100644 --- a/tests/autoMkindex.test +++ b/tests/autoMkindex.test @@ -8,10 +8,13 @@ # 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.3 1998/10/06 19:12:06 rjohnson Exp $ +# RCS: @(#) $Id: autoMkindex.test,v 1.4 1999/03/31 18:58:50 welch Exp $ if {[string compare test [info procs test]] == 1} then {source defs} +set saveCommands $auto_mkindex_parser::initCommands +set result "" + test autoMkindex-1.1 {remove any existing tclIndex file} { file delete tclIndex file exists tclIndex @@ -29,15 +32,15 @@ test autoMkindex-1.3 {examine tclIndex} { 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} { set interp [interp create] @@ -54,8 +57,95 @@ 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" +# 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::* } + auto_mkindex . autoMkindex.tcl + + # Reset initCommands to avoid trashing other tests + + set auto_mkindex_parser::initCommands $saveCommands + 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" + } + 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 + + set auto_mkindex_parser::initCommands $saveCommands + 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" + } + 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 + + set auto_mkindex_parser::initCommands $saveCommands + 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. # +set auto_mkindex_parser::initCommands $saveCommands +unset result +unset saveCommands catch {file delete tclIndex} |