On 19/07/06, chromatic <[EMAIL PROTECTED]> wrote:
On Wednesday 19 July 2006 09:28, Fergal Daly wrote:

> On 19/07/06, chromatic <[EMAIL PROTECTED]> wrote:

> > On Wednesday 19 July 2006 06:03, demerphq wrote:

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

> What's wrong with that code?

It causes Test::Builder to report the wrong line numbers of failure and it
prevents the use of test diagnostics.

Let me rephrase that. What's wrong with the author's expectation that
he can use the his standard programming toolkit and get sensible
results?

Something is broken but I don't see why it must be the test script.

> It doesn't do anything useful right now
> but you can't argue that a system that stops being useful when you use
> subroutines is good.

That's not my point.  My point is that there's a one-line fix that's been
around and documented since the genesis of Test::Builder.

You mean local $Test::Builder::Level = $Test::Builder::Level + 1 ?

That's fine for Test::XXX module authors, but it's hack when used by
test script writers. It's way too verbose and easy to forget. Module
authors can forget too but they can write tests to make sure they
haven't forgotten. Test script authors shouldn't be forced to write
tests fortheir test scripts just so they can be confident that the
output from the testing framework will be useful.

Also, if my_ok runs 2 tests then there's no way to tell them apart
because they'll both be attributed to the line that calls my_ok().

Basically, it's too hard to write modular testing code.

> If Test::Builder gave a stack trace rather than a single line number
> then this wouldn't be broken,

That's a *lot* of information to vomit for a failing test.  How easily can you
pick out the right call frame out of ten or more?

10 lines? There's only 1 sub call, so that's 2 lines.

If the person writing the subroutine adds one line of code (and this person is
in the position to *know* the test level), it's not an issue.

Extra boilerplate code just to be able to use subroutines is an issue
(especially when it's this verbose),

F

Reply via email to