resilient in the face of global destruction's random garbage
collection order.
+ * Moose::Exporter
+ - If you "also" a module that isn't loaded, the error message
+ now acknowledges that (Sartak)
+
0.78 Tue, May 12, 2009
* Moose::Cookbook::FAQ and Moose::Cookbook::WTF
- Merged these documents into what is now Moose::Manual::FAQ
sub _follow_also_real {
my $exporting_package = shift;
- die "Package in also ($exporting_package) does not seem to use Moose::Exporter"
- unless exists $EXPORT_SPEC{$exporting_package};
+ if (!exists $EXPORT_SPEC{$exporting_package}) {
+ my $loaded = Class::MOP::is_class_loaded($exporting_package);
+
+ die "Package in also ($exporting_package) does not seem to "
+ . "use Moose::Exporter"
+ . ($loaded ? "" : " (is it loaded?)");
+ }
my $also = $EXPORT_SPEC{$exporting_package}{also};
BEGIN {
eval "use Test::Output;";
plan skip_all => "Test::Output is required for this test" if $@;
- plan tests => 45;
+ plan tests => 47;
}
}
{
- package MooseX::CircularAlso;
+ package MooseX::NoAlso;
use Moose ();
::like(
$@,
- qr/\QPackage in also (NoSuchThing) does not seem to use Moose::Exporter/,
+ qr/\QPackage in also (NoSuchThing) does not seem to use Moose::Exporter (is it loaded?) at /,
+ 'got the expected error from a reference in also to a package which is not loaded'
+ );
+}
+
+{
+ package MooseX::NotExporter;
+
+ use Moose ();
+
+ ::dies_ok(
+ sub {
+ Moose::Exporter->setup_import_methods(
+ also => [ 'Moose::Meta::Method' ],
+ );
+ },
+ 'a package which does not use Moose::Exporter in also dies with an error'
+ );
+
+ ::like(
+ $@,
+ qr/\QPackage in also (Moose::Meta::Method) does not seem to use Moose::Exporter at /,
'got the expected error from a reference in also to a package which does not use Moose::Exporter'
);
}