On 7/19/06, chromatic <[EMAIL PROTECTED]> wrote:
On Wednesday 19 July 2006 06:03, demerphq wrote:

> Excuse me? Where did I say the code was "broken"?

Wasn't that the implication when you said you've seen misleading line numbers
many times?

No. I didnt imply anything. I spelled it out quite clearly.

I said that the code to find the line number uses a heurisitic that
gets things wrong, and that I didn't see any way to improve the
heurisitc. And therefore that the line number information is an
unreliable way to find what code actually failed the test, which in my
experience is a problem properly solved by using test names.

> use Test::More tests => 3;
>
> sub my_ok {
> ok($_[0],$_[1]);
> }

I don't know why you'd expect this to report the right line numbers; this code
really *is* broken.

No, its not broken, using subroutines is not broken. And, even it were
broken, its a common mistake. The code is basically a stripped down
example of stuff i see in test files A LOT.

And even if i were to concede that my_ok() is broken (which I don't)
there is still Fergals example of a data driven tests in a loop:

my @tests=(....);

foreach my $test (@tests) {
 is($test->[0],$test->[1]);
}

how do you propose to get a useful line number out of that? Are you
going to say that its broken as well?

Now if  it was written

foreach my $test (@tests) {
 is($test->[0],$test->[1],$test->[2]);
}

Then i can find the test _easily_. No heurisitics, no BS with poorly
documented vars in Test::Builder. And speaking of
$Test::Builder::Level at me let me ask a question, how many are  going
to read Test::Builder to get the line numbers from tests in Test::More
right? Experience shows not very many people[1]. Heck the variable
isn't even mentioned in Test::More. And Test::Builder isn't mentioned
in Test::Simple at all (presumably because it doesnt use it, in which
case $Test::Builder::Level isnt going to help.)

[1] I might wager that a lot of test authors dont even notice the
problem. I say this because in my own experience of writing my own
test suites the line number is something I dont even look at. I know
what test failed because I wrote the test file and the code its
testing and I can find the relevent stuff in an instant. Finding the
code responsible for a failing test is something that IMO is done more
often by module consumers who for one reason or another are seeing
things go wrong. The author on the other hand is unlikey to have seen
the tests fail, and therefore might not even know the line numbers are
wrong.


--
perl -Mre=debug -e "/just|another|perl|hacker/"

Reply via email to