On 4 Dec 2007, at 06:52, Michael G Schwern wrote:
Eric Wilhelm wrote:
# from David Golden
# on Monday 03 December 2007 19:55:
With some sugar, that could actually be quite handy for something
like
test blocks. E.g.:
{
plan add => 2;
ok( 1, "wibble" );
ok(1, "wobble" );
}
or maybe make the block a sub
block {
subplan 2;
ok(1, "wibble");
ok(1, "wobble");
};
I guess the unspoken benefit is block() can check the sub-plan when
the
subroutine ref is done?
I'm always wary of using subs-as-blocks for general testing as they
transparently mess up the call stack which will effect testing
anything that
plays with caller() (such as Carp). Then you have to introduce more
complexity, like Sub::Uplevel, to mask that.
[snip]
A general ++ Schwern's idea. I'm pretty sure this is exactly what
Ovid wanted in a recent thread, and I too would fine it trez useful.
As to APIs, not that I think it's totally wonderful, but Test::Block
gets around the subs-as-blocks callstack stuff by using some
moderately evil localisation/overload sneakyness.
Adrian