summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/autoMkindex.tcl21
-rw-r--r--tests/autoMkindex.test102
-rw-r--r--tests/platform.test20
3 files changed, 137 insertions, 6 deletions
diff --git a/tests/autoMkindex.tcl b/tests/autoMkindex.tcl
index 7a72fbe..2756358 100644
--- a/tests/autoMkindex.tcl
+++ b/tests/autoMkindex.tcl
@@ -50,3 +50,24 @@ namespace eval buried {
proc ::buried::explicit {args} {return "explicit: $args"}
}
}
+
+# With proper hooks, we should be able to support other commands
+# that create procedures
+
+proc buried::myproc {name body args} {
+ ::proc $name $body $args
+}
+namespace eval ::buried {
+ proc mycmd1 args {return "mycmd"}
+ myproc mycmd2 args {return "mycmd"}
+}
+::buried::myproc mycmd3 args {return "another"}
+
+proc {buried::my proc} {name body args} {
+ ::proc $name $body $args
+}
+namespace eval ::buried {
+ proc mycmd4 args {return "mycmd"}
+ {my proc} mycmd5 args {return "mycmd"}
+}
+{::buried::my proc} mycmd6 args {return "another"}
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}
diff --git a/tests/platform.test b/tests/platform.test
new file mode 100644
index 0000000..f5273b2
--- /dev/null
+++ b/tests/platform.test
@@ -0,0 +1,20 @@
+# The file tests the tcl_platform variable
+#
+# This file contains a collection of tests for one or more of the Tcl
+# built-in commands. Sourcing this file into Tcl runs the tests and
+# generates output for errors. No output means no errors were found.
+#
+# Copyright (c) 1999 by Scriptics Corporation
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#
+# RCS: @(#)
+
+if {[info procs test] != "test"} {source defs}
+
+test platform-1.1 {TclpSetVariables: tcl_platform} {
+ lsort [array names tcl_platform]
+} {byteOrder machine os osVersion platform}
+
+return