summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/autouse.pm5
-rw-r--r--lib/autouse.t12
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/autouse.pm b/lib/autouse.pm
index 68646a4720..a5efaaca7f 100644
--- a/lib/autouse.pm
+++ b/lib/autouse.pm
@@ -73,9 +73,10 @@ sub import {
sub vet_import ($) {
my $module = shift;
if (my $import = $module->can('import')) {
- croak "autoused module has unique import() method"
+ croak "autoused module $module has unique import() method"
unless defined(&Exporter::import)
- && $import == \&Exporter::import;
+ && ($import == \&Exporter::import ||
+ $import == \&UNIVERSAL::import)
}
}
diff --git a/lib/autouse.t b/lib/autouse.t
index 0a2d68003f..bdd2fba883 100644
--- a/lib/autouse.t
+++ b/lib/autouse.t
@@ -6,7 +6,7 @@ BEGIN {
}
use Test;
-BEGIN { plan tests => 10; }
+BEGIN { plan tests => 12; }
BEGIN {
require autouse;
@@ -55,3 +55,13 @@ ok( !exists $INC{$mod_file} );
ok( soundex('Basset'), 'B230' );
ok( exists $INC{$mod_file} );
+use autouse Env => "something";
+eval { something() };
+ok( $@, qr/^\Qautoused module Env has unique import() method/ );
+
+# Check that UNIVERSAL.pm doesn't interfere with modules that don't use
+# Exporter and have no import() of their own.
+require UNIVERSAL;
+autouse->import("Class::ISA" => 'self_and_super_versions');
+my %versions = self_and_super_versions("Class::ISA");
+ok( $versions{"Class::ISA"}, $Class::ISA::VERSION );