Note: the upper part was posted by David to http://rt.cpan.org/Ticket/Display.html?id=49617, the lower part was missing in that posting and is reconstructed by me, andk, 2009-11-18. From 24b52ff9542c56a7de8ac82a3eb600e21a73ec73 Mon Sep 17 00:00:00 2001 From: David Golden Date: Wed, 4 Nov 2009 17:04:55 -0500 Subject: [PATCH] blead Carp uses caller(); must load Sub::Uplevel first --- lib/Test/Exception.pm | 7 ++++--- t/stacktrace.t | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Test/Exception.pm b/lib/Test/Exception.pm index c5a077e..ae45dc2 100644 --- a/lib/Test/Exception.pm +++ b/lib/Test/Exception.pm @@ -6,7 +6,6 @@ use Test::Builder; use Sub::Uplevel qw( uplevel ); use base qw( Exporter ); use Scalar::Util 'blessed'; -use Carp; our $VERSION = '0.27_04'; our @EXPORT = qw(dies_ok lives_ok throws_ok lives_and); @@ -209,8 +208,10 @@ test description is passed. sub throws_ok (&$;$) { my ( $coderef, $expecting, $description ) = @_; - croak "throws_ok: must pass exception class/object or regex" - unless defined $expecting; + unless (defined $expecting) { + require Carp; + Carp::croak( "throws_ok: must pass exception class/object or regex" ); + } $description = _exception_as_string( "threw", $expecting ) unless defined $description; --- Test-Exception-0.27-kOUJtt/t/stacktrace.t~ 2009-11-18 05:23:39.000000000 +0100 +++ Test-Exception-0.27-kOUJtt/t/stacktrace.t 2009-11-18 05:18:51.000000000 +0100 @@ -2,6 +2,7 @@ use strict; use warnings; +use Sub::Uplevel; use Carp; use Test::Builder::Tester tests => 2; use Test::More;