On Tue, Nov 12, 2002 at 04:21:38PM +0000, Adrian Howard wrote:
> >At YAPC::Europe there was some discussion about Test::Builder->level,
> >$Test::Builder::Level and the fact that they don't really work well as
> >implemented. I know we reached some sort of consensus about how to do it
> >better, but I've forgotten it.
>
> Yet another suggestion to add to the list of possible options.
>
> Most of the time when I need to mess with level, the code that does
> the test is sitting in a different package from the one that is
> calling the test. How about having it walk up the call stack until it
> find a package that differs from the one it was called in?
>
> No nasty messing with numbers and you don't have to fiddle with it
> every time you add/remove a sub in the call chain.
ETOOMAGICAL and it makes it impossible to have something like this:
# Test code
use Test::Foo 'test_func';
test_func($stuff);
# Test/Foo.pm
package Test::Foo;
use Test::Foo::Bar 'real_test_func';
sub test_func {
...
real_test_func(@_);
...
}
# Test/Foo/Bar.pm
package Test::Foo::Bar
use Test::Builder;
my $TB = Test::Builder->new;
sub real_test_func {
...
$TB->ok($test);
...
}
a practical example would be an Exporter/Exporter::Heavy poor-man's
autoloader setup.
Of course, there's nothing stopping you from overriding level() to be
magical, once I implement your ideas about being able to change the default
object and stack them.
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
You'll do.