From: Steffen Müller <0mgwtfbbq@sneakemail.com> Date: Fri, 30 Nov 2007 23:02:03 +0000 (+0100) Subject: AutoLoader: Remove AutoLoader::can X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=536daee00bd7944e598743396417656c3a6557b3;p=p5sagit%2Fp5-mst-13.2.git AutoLoader: Remove AutoLoader::can Message-ID: <20071130220203.26939.qmail@lists.develooper.com> p4raw-id: //depot/perl@32903 --- diff --git a/lib/AutoLoader.pm b/lib/AutoLoader.pm index 215a9ff..636bb5a 100644 --- a/lib/AutoLoader.pm +++ b/lib/AutoLoader.pm @@ -15,7 +15,7 @@ BEGIN { $is_epoc = $^O eq 'epoc'; $is_vms = $^O eq 'VMS'; $is_macos = $^O eq 'MacOS'; - $VERSION = '5.64'; + $VERSION = '5.64_01'; } AUTOLOAD { @@ -51,21 +51,6 @@ AUTOLOAD { goto &$sub; } -sub can { - my ($self, $method) = @_; - - my $parent = $self->SUPER::can( $method ); - return $parent if $parent; - - my $package = ref( $self ) || $self; - my $filename = AutoLoader::find_filename( $package . '::' . $method ); - local $@; - return unless eval { require $filename }; - - no strict 'refs'; - return \&{ $package . '::' . $method }; -} - sub find_filename { my $sub = shift; my $filename; @@ -152,7 +137,6 @@ sub import { if ( @_ and $_[0] =~ /^&?AUTOLOAD$/ ) { no strict 'refs'; *{ $callpkg . '::AUTOLOAD' } = \&AUTOLOAD; - *{ $callpkg . '::can' } = \&can; } } @@ -198,7 +182,7 @@ sub unimport { no strict 'refs'; - for my $exported (qw( AUTOLOAD can )) { + for my $exported (qw( AUTOLOAD )) { my $symname = $callpkg . '::' . $exported; undef *{ $symname } if \&{ $symname } == \&{ $exported }; *{ $symname } = \&{ $symname }; diff --git a/lib/AutoLoader/t/01AutoLoader.t b/lib/AutoLoader/t/01AutoLoader.t index 2b6ef9a..21125ae 100755 --- a/lib/AutoLoader/t/01AutoLoader.t +++ b/lib/AutoLoader/t/01AutoLoader.t @@ -18,7 +18,7 @@ BEGIN unshift @INC, $dir; } -use Test::More tests => 22; +use Test::More tests => 17; # First we must set up some autoloader files my $fulldir = File::Spec->catdir( $dir, 'auto', 'Foo' ); @@ -33,15 +33,6 @@ sub foo { shift; shift || "foo" } EOT close(FOO); -open(BAR, '>', File::Spec->catfile( $fulldir, 'bar.al' )) - or die "Can't open bar file: $!"; -print BAR <<'EOT'; -package Foo; -sub bar { shift; shift || "bar" } -1; -EOT -close(BAR); - open(BAZ, '>', File::Spec->catfile( $fulldir, 'bazmarkhian.al' )) or die "Can't open bazmarkhian file: $!"; print BAZ <<'EOT'; @@ -87,10 +78,6 @@ ok( $result, 'can() first time' ); is( $foo->foo, 'foo', 'autoloaded first time' ); is( $foo->foo, 'foo', 'regular call' ); is( $result, \&Foo::foo, 'can() returns ref to regular installed sub' ); -$result = $foo->can( 'bar' ); -ok( $result, 'can() should work when importing AUTOLOAD too' ); -is( $foo->bar, 'bar', 'regular call' ); -is( $result, \&Foo::bar, '... returning ref to regular installed sub' ); eval { $foo->will_fail; @@ -112,9 +99,7 @@ like( $@, qr/oops/, 'indirect method call' ); # autoloaded filename. 'foo' =~ /(\w+)/; -is( $foo->bar($1), 'foo', 'autoloaded method should not stomp match vars' ); -is( $foo->bar($1), 'foo', '(again)' ); -is( $foo->bazmarkhianish($1), 'foo', 'for any method call' ); +is( $foo->bazmarkhianish($1), 'foo', 'autoloaded method should not stomp match vars' ); is( $foo->bazmarkhianish($1), 'foo', '(again)' ); # Used to retry long subnames with shorter filenames on any old