On 20 Jul 2006, at 00:38, demerphq wrote:
[snip]
The whole reason this thread started was that i suggested that test
descriptions be mandatory, as they were in my opinion the best way to
resolve this problem.
[snip]

How about something like:

---
package Test::StrictName;
use Test::Builder;
use Carp qw( croak );

my $original_ok = \&Test::Builder::ok;

no warnings 'redefine';
*Test::Builder::ok = sub {
    my ( $self, $test, $name ) = @_;
    my ( $pack, $file, $line ) = Test::Builder->new->caller;
croak "attempted to run test without a name at line $line of $file" unless $name;
    local $Test::Builder::Level = $Test::Builder::Level + 1;
    $original_ok->( $self, $test, $name );
};

1;
---

Then the people who want mandatory test names can have them, everybody else can continue as they are, the lion will lay down with the lamb, everybody will be happy, group hug, etc. :-)

Cheers,

Adrian

Reply via email to