[Catalyst-commits] r7429 - in Catalyst-Runtime/5.70/trunk:
lib/Catalyst t
castaway at dev.catalyst.perl.org
castaway at dev.catalyst.perl.org
Sat Feb 2 15:32:22 GMT 2008
Author: castaway
Date: 2008-02-02 15:32:22 +0000 (Sat, 02 Feb 2008)
New Revision: 7429
Modified:
Catalyst-Runtime/5.70/trunk/lib/Catalyst/Utils.pm
Catalyst-Runtime/5.70/trunk/t/unit_utils_load_class.t
Log:
Steal class loading code from Class::MOP, which isnt confused by __PACKAGE__
Modified: Catalyst-Runtime/5.70/trunk/lib/Catalyst/Utils.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/lib/Catalyst/Utils.pm 2008-02-02 06:46:44 UTC (rev 7428)
+++ Catalyst-Runtime/5.70/trunk/lib/Catalyst/Utils.pm 2008-02-02 15:32:22 UTC (rev 7429)
@@ -264,7 +264,9 @@
my $error;
{
local $@;
- eval "require $class;";
+ my $file = $class . '.pm';
+ $file =~ s{::}{/}g;
+ eval { CORE::require($file) };
$error = $@;
}
Modified: Catalyst-Runtime/5.70/trunk/t/unit_utils_load_class.t
===================================================================
--- Catalyst-Runtime/5.70/trunk/t/unit_utils_load_class.t 2008-02-02 06:46:44 UTC (rev 7428)
+++ Catalyst-Runtime/5.70/trunk/t/unit_utils_load_class.t 2008-02-02 15:32:22 UTC (rev 7429)
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 14;
+use Test::More tests => 16;
use lib "t/lib";
@@ -41,6 +41,11 @@
ok( $@, "doesn't defatalize" );
like( $@, qr/There\.pm.*\@INC/, "error looks right" );
+undef $@;
+eval { Catalyst::Utils::ensure_class_loaded("__PACKAGE__") };
+ok( $@, "doesn't defatalize" );
+like( $@, qr/__PACKAGE__\.pm.*\@INC/, "errors sanely on __PACKAGE__.pm" );
+
$@ = "foo";
Catalyst::Utils::ensure_class_loaded("TestApp::View::Dump::Response");
is( $@, "foo", '$@ is untouched' );
More information about the Catalyst-commits
mailing list