
cd $env(TEMP)

set pkg testpkg

# Set things up
file mkdir $pkg
cd $pkg

set ifneed "tclPkgSetup \$dir $pkg 1.0 {{testpkg.tcl source {::testpkg::one}}}"

set fout [open pkgIndex.tcl w]
puts $fout "package ifneeded $pkg 1.0 \[list $ifneed\]"
close $fout

set fout [open testpkg2.tcl w]
puts $fout {namespace eval testpkg {}}
puts $fout {proc ::testpkg::one {args} { return "one" }}
close $fout
set fout [open testpkg2.tcl w]
puts $fout {namespace eval testpkg {}}
puts $fout {proc ::testpkg::two {args} { return "two" }}
close $fout
cd ..
lappend auto_path [pwd]

# Now test
package require $pkg

set res {}

# Let's check whether we can and then load the first proc
lappend res [info exists auto_index(::testpkg::one)]
lappend res [info procs ::testpkg::one]
lappend res [auto_load testpkg::one]
lappend res [info procs ::testpkg::one]

auto_reset

# Let's check whether we can and then load the second proc
# This one fails.  We can never get hold of testpkg::two 
# without forgetting testpkg.
lappend res [info exists auto_index(::testpkg::two)]
lappend res [info procs ::testpkg::two]
lappend res [auto_load testpkg::two]
lappend res [info procs ::testpkg::two]

set res

