package require tcltest 2
namespace import tcltest::*

# Author: Bradley C. Harder, Method Logic Digital
#
# Purpose: This test suite is to demonstrate a bug in Tcl 8.5.7 whereby a xxxx
#	newly defined proc seems unnoticed (when called immediately after
#	definition) within a namespace when [namespace path] is also defined.
#	Subsequent calls to proc from within same namespace work as
#	advertised.
#
# Permission is hereby granted to use and distribute these tests under same
# license as Tcl itself.

test ns-res-epoch-1.0 {Resolution epoch handling: Bug 2898722} -setup {
    set result {}
} -body {
    namespace eval ::a {
	proc c {} {lappend ::result [namespace current]}
	c
	namespace eval b {
	    variable d c
	    lappend ::result [catch { $d } msg]
	}
	namespace eval b {
	    namespace path [namespace parent]
	    $d
	}
	namespace eval b {
	    proc c {} {lappend ::result [namespace current]}
	    $d
	}
    }
    namespace eval ::a::b {
	$d
	c
    }
} -cleanup {
    namespace delete ::a
    unset result
} -result {::a 1 ::a ::a::b ::a::b ::a::b}

cleanupTests
