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. -- 'All anyone gets in a mirror is themselves,' she said. 'But what you gets in a good gumbo is everything.' -- "Witches Abroad" by Terry Prachett