summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchromatic <chromatic@wgz.org>2003-12-01 01:20:21 -0800
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-12-05 07:31:18 +0000
commita498340c5e9c95b1999816d3f8194563b91f0950 (patch)
tree5d6920192e48b8a123d3ab82e946240d0ebad917
parent47598e24a8afddc2c6eba0ff1187d371773c66c5 (diff)
downloadperl-a498340c5e9c95b1999816d3f8194563b91f0950.tar.gz
[REPATCH lib/AutoLoader.t] Test can() with AutoLoader
Message-Id: <1070299221.1275.19.camel@localhost> p4raw-id: //depot/perl@21844
-rwxr-xr-xlib/AutoLoader.t11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/AutoLoader.t b/lib/AutoLoader.t
index 408b281126..9ed79e3f4a 100755
--- a/lib/AutoLoader.t
+++ b/lib/AutoLoader.t
@@ -16,7 +16,7 @@ BEGIN
unshift @INC, $dir;
}
-use Test::More tests => 14;
+use Test::More tests => 17;
# First we must set up some autoloader files
my $fulldir = File::Spec->catdir( $dir, 'auto', 'Foo' );
@@ -73,19 +73,28 @@ require AutoLoader;
AutoLoader->import( 'AUTOLOAD' );
sub new { bless {}, shift };
+sub foo;
+sub bar;
+sub bazmarkhianish;
package main;
my $foo = new Foo;
+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' );
eval {
$foo->will_fail;
};
like( $@, qr/^Can't locate/, 'undefined method' );
+$result = $foo->can( 'will_fail' );
+ok( ! $result, 'can() should fail on undefined methods' );
+
# Used to be trouble with this
eval {
my $foo = new Foo;