summaryrefslogtreecommitdiff
path: root/lib/AutoLoader.t
diff options
context:
space:
mode:
authorchromatic <chromatic@wgz.org>2006-05-20 04:40:27 -0700
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-05-24 07:27:47 +0000
commit00bb01c7233bf772ebf55cca8a616f81a2c29810 (patch)
tree7791d7a8d305ebed325d6c3d0bba04a3be6e463f /lib/AutoLoader.t
parentade55ef48b26f40fc7a848c0ee1b6c616d1a3911 (diff)
downloadperl-00bb01c7233bf772ebf55cca8a616f81a2c29810.tar.gz
Export can() with AUTOLOAD()
Message-Id: <200605201140.27789.chromatic@wgz.org> With tweaks: use built-in ref() instead of Scalar::Util::blessed p4raw-id: //depot/perl@28295
Diffstat (limited to 'lib/AutoLoader.t')
-rwxr-xr-xlib/AutoLoader.t12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/AutoLoader.t b/lib/AutoLoader.t
index 9ed79e3f4a..9f0804b004 100755
--- a/lib/AutoLoader.t
+++ b/lib/AutoLoader.t
@@ -16,7 +16,7 @@ BEGIN
unshift @INC, $dir;
}
-use Test::More tests => 17;
+use Test::More tests => 21;
# First we must set up some autoloader files
my $fulldir = File::Spec->catdir( $dir, 'auto', 'Foo' );
@@ -74,18 +74,21 @@ AutoLoader->import( 'AUTOLOAD' );
sub new { bless {}, shift };
sub foo;
-sub bar;
sub bazmarkhianish;
package main;
-my $foo = new Foo;
+my $foo = Foo->new();
my $result = $foo->can( 'foo' );
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;
@@ -97,7 +100,7 @@ ok( ! $result, 'can() should fail on undefined methods' );
# Used to be trouble with this
eval {
- my $foo = new Foo;
+ my $foo = Foo->new();
die "oops";
};
like( $@, qr/oops/, 'indirect method call' );
@@ -144,6 +147,7 @@ Foo::a();
package Bar;
AutoLoader->import();
::ok( ! defined &AUTOLOAD, 'AutoLoader should not export AUTOLOAD by default' );
+::ok( ! defined &can, '... nor can()' );
package Foo;
AutoLoader->unimport();