On Thu, Jul 20, 2006 at 12:39:11AM +0100, Fergal Daly wrote:

> Simple question. Given this code:
> 
> sub foo {
>   my $thing;
>   is($thing->x(), "x"); # line 4
>   is($thing->y(), "y");
> }
> 
> $t1 = Thing->new(1);
> foo($t1); # line 9
> $t2 = Thing->new(2);
> foo($t2);
> 
> lets say the first is() is going to fail for $t1. What's the correct
> line number to print? If we print line 9 then we don't know which is()
> failed. If we print line 4 then we don't know which Thing failed.
> 
> There is no right line to print, the only right thing to print is a stack 
> trace.
> 
> Or maybe my subroutine is broken but I don't see how.
 
It's missing the local $Test::Builder::Level line or the attribute as well as
meaningful test names.  If you don't use either approach, you'll get the wrong
line number in the failure report, if you care about the line number.

> What on earth are you talking about? This is *NOT* how Test::Builder
> figures out the line number for the diagnostics.

Yes, I know...

> Please go and read the code.

... please go and read the credits for the code.
 
> Aristotle's solution doesn't make any difference to whether stack
> traces are required. All it does is eliminate the need for boiler
> plate code.

That boiler plate code tells Test::Builder *where* to report the call of the
test.
 
> > Again, that depends on how far you push the heuristic.
> Again, read the code, there is no "heuristic",

I don't know what you mean by "heuristic" then, as I have no other name for
"some sort of automated way to guess and hope you can give a useful answer,
because there's no single right answer."

-- c

Reply via email to