From: Shawn M Moore Date: Sun, 28 Sep 2008 16:25:54 +0000 (+0000) Subject: Fixes for $Test::Builder::Tester, we want to invoke new to get our own instance X-Git-Tag: 0.19~194 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9458ce953e5a50ba3b5f8ac134a860d6e8f7119f;p=gitmo%2FMouse.git Fixes for $Test::Builder::Tester, we want to invoke new to get our own instance --- diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 1314acd..0796cf0 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -121,6 +121,9 @@ our %dependencies = ( }, # VVVVV CODE TAKEN FROM TEST::EXCEPTION VVVVV 'Test::Exception' => do { + + my $Tester = Test::Builder->new; + my $is_exception = sub { my $exception = shift; return ref $exception || $exception ne ''; @@ -150,16 +153,16 @@ our %dependencies = ( unless defined $description; my $exception = $try_as_caller->($coderef); - my $regex = $Test::Builder::Tester->maybe_regex( $expecting ); + my $regex = $Tester->maybe_regex( $expecting ); my $ok = $regex ? ( $exception =~ m/$regex/ ) : eval { $exception->isa( ref $expecting ? ref $expecting : $expecting ) }; - $Test::Builder::Tester->ok( $ok, $description ); + $Tester->ok( $ok, $description ); unless ( $ok ) { - $Test::Builder::Tester->diag( $exception_as_string->( "expecting:", $expecting ) ); - $Test::Builder::Tester->diag( $exception_as_string->( "found:", $exception ) ); + $Tester->diag( $exception_as_string->( "expecting:", $expecting ) ); + $Tester->diag( $exception_as_string->( "found:", $exception ) ); }; $@ = $exception; return $ok; @@ -167,8 +170,8 @@ our %dependencies = ( 'lives_ok' => sub (&;$) { my ( $coderef, $description ) = @_; my $exception = $try_as_caller->( $coderef ); - my $ok = $Test::Builder::Tester->ok( ! $is_exception->( $exception ), $description ); - $Test::Builder::Tester->diag( $exception_as_string->( "died:", $exception ) ) unless $ok; + my $ok = $Tester->ok( ! $is_exception->( $exception ), $description ); + $Tester->diag( $exception_as_string->( "died:", $exception ) ) unless $ok; $@ = $exception; return $ok; },