At 16:47 +0000 1/12/04, Fergal Daly wrote:
You can just do Test::Builder->new to get the Test::Builder object. It will
be the same one used by Test::More because it's a singleton. That way you
should need no patches,

In the end I came up with this code. It's pretty simple and straightforward and maybe would be nice to include with Test::More.


======================================================
=head2 todo_some

Execute given test subroutine while setting $TODO flag for given
test numbers.

  IN: 1 hash reference, with testnumber / reason strings pairs
      2 reference to subroutine to execute test
      3..N parameters to pass to test subroutine
 OUT: 1 whatever test sub returns

Sometimes when writing tests, some tests may fail. You can mark these tests as TODO but this is only convenient for a single range of tests.

Sometimes a few tests may fail inside a set of nested loops. But marking them in the flow of the program is very complicated.

The C<todo_some> method allows you to specify which tests are supposed to fail, specified by test number and reason for the failure.

Example:

 my %todo = (
   1023 => "d f g still fails, but it's not that important",
   1567 => 'yikes, we need to fix this one!',
 );

foreach my $foo (@foo) {
foreach my $bar (@bar) {
foreach my $car (@car) {
todo_some( \%todo,\&ok,func($foo,$bar,$car),"check result of func()" );
}
}
}


=cut

sub todo_some {
    local $TODO = shift->{$Test->current_test + 1} || '';
    no strict 'subs'; # allow test func specification by name
    my $sub = shift;
    $sub->( @_ );
} #todo_some
======================================================

Liz

Reply via email to