On Sun, Jul 22, 2001 at 10:52:44AM -0400, [EMAIL PROTECTED] wrote:
> On Sun, Jul 22, 2001 at 02:19:25AM -0700, Randal L. Schwartz wrote:
> > Can't you just make:
> >
> > sub TODO (\&) {
> > local($INSIDE_TODO) = 1;
> > TODO: shift->();
> > }
>
> That was my original plan, problem is it modifies the results of
> caller() (so things like carp() would be altered). Since it's a
> general testing function, I'm trying to keep its effects on the
> surrounding code at near 0.
>
> I've actually got this working for skip...
>
> SKIP: {
> skip("A serious lack of foo") unless $have_foo;
> ok( foo() eq 'bar' );
> }
>
> sub skip {
> my($why) = shift;
> _skipped($why);
>
> no warnings;
> last SKIP;
> }
>
> using that horrible desperation feature of last(). So I *know*
> functions can tell what labeled block they're enclosed in, I just
> don't want to dive out to XS to do it.
>
> It's too bad I can't do some combination of last/next/redo/goto and
> eval that will *try* to jump out of the loop but not actually do it.
Well, you can always use caller() to find out the file and line number
you were called from, then open the file, find 'FOO:', use Text::Balanced
to find the matching brace and decide whether you were in or out of
the block.
But, if all you want to do is add a '# TODO' trailer, wouldn't the
following do the trick?
local $trailer = "";
sub ok {
my $result = shift;
$count ++;
print $result ? "ok " : "not ok ", $count, $trailer, "\n";
}
ok (...);
FOO: {
local $trailer = "# TODO";
ok (...);
}
ok (...);
Abigail