From: Michael G. Schwern Date: Sat, 1 Nov 2003 22:57:45 +0000 (-0800) Subject: Re: [perl #24384] 21418 (UNIVERSAL.pm patch) breaks autouse.pm X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=03699e8e149475044b8cf43118cce81b4d360dfb;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #24384] 21418 (UNIVERSAL.pm patch) breaks autouse.pm Message-ID: <20031102065745.GN3659@localhost.comcast.net> (goes with change #21418) p4raw-link: @21418 on //depot/perl: 2bfd56816acd10b1f958d1dde1769bafd756cbea p4raw-id: //depot/perl@21650 --- diff --git a/lib/autouse.pm b/lib/autouse.pm index 68646a4..a5efaac 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 0a2d680..bdd2fba 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 );