On Mon, Jul 23, 2001 at 02:47:24PM -0400, Uri Guttman wrote:
>
> i proposed a similar solution to schwern last night and he shot it down
> as he doesn't want the test coder to do any more work than necessary. i
> said, if he uses the test suite he is signing a contract and if he wants
> the block TODO feature, he must obey the rules. schwern didn't
> agree. later this week i will clobber him with a blunt contract and we
> shall see if he won't change his mind. :)
Here. All the magic in a package, with the "user" only having to make
a TODO: {} block.
package Abigail;
use strict;
use Exporter;
use vars qw /@ISA @EXPORT/;
@ISA = qw /Exporter/;
@EXPORT = qw /ok/;
$Abigail::trailer = "";
use Filter::Simple
sub {s'TODO:\s*\{'TODO:{local $Abigail::trailer = " # TODO";'g;};
# The Magical Mystery Tour boards here.
BEGIN {
no strict 'refs';
my $coderef = *{"Abigail::import"}{CODE};
no warnings 'redefine';
*{"Abigail::import"} = sub {
$coderef -> (@_) if "CODE" eq ref $coderef;
goto &Exporter::import;
}
}
my $count = 0;
sub ok {
print $_ [0] ? "ok " : "not ok ", ++ $count, $Abigail::trailer, "\n"
}
1;
__END__
#!/usr/bin/perl -w
use Abigail;
use strict;
ok (1);
ok (0);
TODO: {
ok (1);
ok (0);
}
ok (1);
ok (0);
__END__
ok 1
not ok 2
ok 3 # TODO
not ok 4 # TODO
ok 5
not ok 6
Abigail