Created
June 22, 2015 15:07
-
-
Save dagolden/e983bf8f1d72a48fe94d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.008001; | |
use strict; | |
use warnings; | |
package Subtest; | |
# XXX must be used with no_plan or done_testing | |
use Test::More 0.88; | |
use base 'Exporter'; | |
our @EXPORT; | |
unless ( Test::More->can("subtest") ) { | |
*subtest = sub { | |
my ( $label, $code ) = @_; | |
note "BEGIN SUBTEST $label"; | |
local $Test::Builder::Level = $Test::Builder::Level + 2; | |
eval { $code->() }; | |
if ( my $err = $@ ) { | |
fail($label); | |
diag($err); | |
} | |
else { | |
pass($label); | |
} | |
}; | |
push @EXPORT, 'subtest'; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment