diff options
author | Steffen Müller <0mgwtfbbq@sneakemail.com> | 2007-12-01 00:02:03 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2008-01-08 22:12:56 +0000 |
commit | 536daee00bd7944e598743396417656c3a6557b3 (patch) | |
tree | df15b310c782caea9ad343451f7c4e988d53f5a3 | |
parent | 86d2c25d57d36407551f0841eab018075f2188bf (diff) | |
download | perl-536daee00bd7944e598743396417656c3a6557b3.tar.gz |
AutoLoader: Remove AutoLoader::can
Message-ID: <20071130220203.26939.qmail@lists.develooper.com>
p4raw-id: //depot/perl@32903
-rw-r--r-- | lib/AutoLoader.pm | 20 | ||||
-rwxr-xr-x | lib/AutoLoader/t/01AutoLoader.t | 19 |
2 files changed, 4 insertions, 35 deletions
diff --git a/lib/AutoLoader.pm b/lib/AutoLoader.pm index 215a9ff250..636bb5a52c 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 2b6ef9ae21..21125aef8f 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 |