summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteffen Müller <0mgwtfbbq@sneakemail.com>2007-12-18 12:58:19 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-12-20 09:54:23 +0000
commit1163f0e44f6a46cda7ec19270939fa383e5709cd (patch)
tree26930cae1398ef970af801a8688ebd060e5cd621
parent764458a485991146e9f694d103d4ce6c736a5aaa (diff)
downloadperl-1163f0e44f6a46cda7ec19270939fa383e5709cd.tar.gz
Re: [perl #48769] [PATCH] SelfLoader.pm 1.0904 - Whitespace in subroutine
Message-ID: <4767A7CB.5030607@sneakemail.com> p4raw-id: //depot/perl@32665
-rw-r--r--lib/SelfLoader.pm4
-rwxr-xr-xlib/SelfLoader.t34
2 files changed, 23 insertions, 15 deletions
diff --git a/lib/SelfLoader.pm b/lib/SelfLoader.pm
index 1136cf0909..da8909433c 100644
--- a/lib/SelfLoader.pm
+++ b/lib/SelfLoader.pm
@@ -6,7 +6,7 @@ use strict;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(AUTOLOAD);
-our $VERSION = "1.11";
+our $VERSION = "1.12";
sub Version {$VERSION}
sub DEBUG () { 0 }
@@ -88,7 +88,7 @@ sub _load_stubs {
local($/) = "\n";
while(defined($line = <$fh>) and $line !~ m/^__END__/) {
- if ($line =~ m/^sub\s+([\w:]+)\s*((?:\([\\\$\@\%\&\*\;]*\))?(?:$attr_list)?)/) {
+ if ($line =~ m/^\s*sub\s+([\w:]+)\s*((?:\([\\\$\@\%\&\*\;]*\))?(?:$attr_list)?)/) {
push(@stubs, $self->_add_to_cache($name, $currpack, \@lines, $protoype));
$protoype = $2;
@lines = ($line);
diff --git a/lib/SelfLoader.t b/lib/SelfLoader.t
index 6987f6592b..feadd3d1dc 100755
--- a/lib/SelfLoader.t
+++ b/lib/SelfLoader.t
@@ -13,7 +13,7 @@ BEGIN {
@INC = $dir;
push @INC, '../lib';
- print "1..19\n";
+ print "1..20\n";
# First we must set up some selfloader files
mkdir $dir, 0755 or die "Can't mkdir $dir: $!";
@@ -40,7 +40,6 @@ sub bazmarkhianish { shift; shift || "baz" }
package sheep;
sub bleat { shift; shift || "baa" }
-
__END__
sub never { die "D'oh" }
EOT
@@ -56,6 +55,7 @@ use SelfLoader;
sub new { bless {}, shift }
sub a;
+sub with_whitespace_in_front;
1;
__DATA__
@@ -63,6 +63,10 @@ __DATA__
sub a { 'a Bar'; }
sub b { 'b Bar' }
+ sub with_whitespace_in_front {
+ "with_whitespace_in_front Bar"
+}
+
__END__ DATA
sub never { die "D'oh" }
EOT
@@ -147,16 +151,20 @@ print "ok 11\n";
print "not " unless $bar->c() eq 'c Baz';
print "ok 12\n";
+# check that subs with whitespace in front work
+print "not " unless $bar->with_whitespace_in_front() eq 'with_whitespace_in_front Bar';
+print "ok 13\n";
+
# This selfloads Bar::a because it is stubbed. It also stubs Bar::b as a side
# effect
print "not " unless $bar->a() eq 'a Bar';
-print "ok 13\n";
+print "ok 14\n";
print "not " unless $bar->b() eq 'b Bar';
-print "ok 14\n";
+print "ok 15\n";
print "not " unless $bar->c() eq 'c Baz';
-print "ok 15\n";
+print "ok 16\n";
@@ -166,18 +174,18 @@ eval {
$foo->never;
};
if ($@ =~ /^Undefined subroutine/) {
- print "ok 16\n";
+ print "ok 17\n";
} else {
- print "not ok 16 $@\n";
+ print "not ok 17 $@\n";
}
# Try to read from the data file handle
my $foodata = <Foo::DATA>;
close Foo::DATA;
if (defined $foodata) {
- print "not ok 17 # $foodata\n";
+ print "not ok 18 # $foodata\n";
} else {
- print "ok 17\n";
+ print "ok 18\n";
}
# Check that __END__ DATA is honoured
@@ -186,18 +194,18 @@ eval {
$bar->never;
};
if ($@ =~ /^Undefined subroutine/) {
- print "ok 18\n";
+ print "ok 19\n";
} else {
- print "not ok 18 $@\n";
+ print "not ok 19 $@\n";
}
# Try to read from the data file handle
my $bardata = <Bar::DATA>;
close Bar::DATA;
if ($bardata ne "sub never { die \"D'oh\" }\n") {
- print "not ok 19 # $bardata\n";
+ print "not ok 20 # $bardata\n";
} else {
- print "ok 19\n";
+ print "ok 20\n";
}
# cleanup