* Paul LeoNerd Evans <[EMAIL PROTECTED]> [2006-12-31 12:35]: > On Sun, Dec 31, 2006 at 04:59:16AM +0100, A. Pagaltzis wrote: > > You’re not using enough magic. If you *really* want to make > > your tests run even if Test::Exception isn’t installed, stick > > the test in a BEGIN block that conditionally installs a > > `dies_ok` stub. Something like > > > > BEGIN { > > unless( eval "use Test::Exception; 1" ) { > > *dies_ok = sub { SKIP: { > > skip "Need Test::Exception for: $_[1]", 1; > > } }; > > } > > } > > > > Something like that anyway; untested. > > Well, that looks a good start; but maybe we can go one better: > > BEGIN { > unless( eval "use Test::Exception; 1" ) { > *dies_ok = sub(&$) { > my ( $code, $msg ) = @_; > eval { $code->(); 1 } and fail( $msg ); > }; > } > } > > Is this "as good" as T::E's version?
T::E performs quite a bit more magic than what you have there. I have no idea if it’s actually necessary or just an artifact of making the code module-packagable. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>