On Thursday 20 July 2006 02:59, Fergal Daly wrote:
> > There already exist two long-accepted, well-understood, coded, tested,
> > and debugged ways to answer both questions. I don't see the value in
> > adding a third, especially when it's not substantially better than either
> > and can be wrong in other circumstances!
>
> What circumstances? Example please.
In a deep call stack beyond the $Level.
> Without stack traces, here's the only way I know to use subroutines
> safely in test scripts.
> sub foo {
> my ($thing, $name) = @_;
> is($thing->x(), "x", "checking x in $name"); # line 4
> is($thing->y(), "y", "checking y in $name");
> }
You forgot $Level or :TestHelper. Was this an accident or deliberate?
> > Your patch relies on $Level too, as it calls the caller() *method* within
> > Test::Builder. If someone has not set it correctly, your patch will
> > report the wrong information.
>
> Someone? Who? If there's a bug in one of the Test::XXX modules then
> yes the stack trace could be wong but that's a bug that needs to be
> fixed and is not a problem with my patch.
I thought that was the problem you were trying to fix: reporting the wrong
location.
If your patch doesn't fix that, I'm not sure what the point is. Why report
extra information if you know it's not reliable?
> > sub an_extra_level
> > {
> > ok( $_[0], $_[1], $_[2] );
> > }
> >
> > sub another_extra_level
> > {
> > an_extra_level( @_ );
> > }
> >
> > sub yet_another_extra_level
> > {
> > another_extra_level( @_ );
> > }
> >
> > sub still_more_extra_levels
> > {
> > yet_another_extra_level( @_ );
> > }
> >
> > still_more_extra_levels( $have, $want, $diagnostic );
> >
> > Where do you start debugging that?
> With a stack trace it's pretty easy.
Yes, you *merely* check *every* level reported in the stack trace to find the
place that the call to the test function *may* have occurred, hoping that
someone set $Level appropriately.
I don't really want to grovel through extra information that I know probably
isn't useful by default. If Schwern is amenable, I wouldn't complain too
much if this were an option for the person running the test (probably set
through an environment variable), but it's too much information that I don't
trust to be useful for a default.
> > That's why there are test descriptions too.
> But some people don't like having to provide names
Yes, some people write bad code. I don't think there's an algorithmic way to
fix that.
-- c