On 20/07/06, chromatic <[EMAIL PROTECTED]> wrote:
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.

I'm talking about line numbers so adding a name is not relevant.

Whether I add $T::B::L or not, I don't get any useful output. If you
disagree please show me your fixed version.

> 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.

I know what it says but that doesn't change the fact that the scheme
you described had nothing at all to do with 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.

What's your point?

> > 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."

I disagree that this is the usual meaning but that's a side issue,
I'll use your meaning.

There's no guessing involved, the method is extremely straight forward
and always gets the right answer. By that I mean that it always finds
the spot where test script jumped into the test library.

The problem is that a single position in the test script is not always
enough information to figure out what actually failed,

F

Reply via email to