From: Steffen Müller <0mgwtfbbq@sneakemail.com> Date: Tue, 18 Dec 2007 11:58:19 +0000 (+0100) Subject: Re: [perl #48769] [PATCH] SelfLoader.pm 1.0904 - Whitespace in subroutine X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1163f0e44f6a46cda7ec19270939fa383e5709cd;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #48769] [PATCH] SelfLoader.pm 1.0904 - Whitespace in subroutine Message-ID: <4767A7CB.5030607@sneakemail.com> p4raw-id: //depot/perl@32665 --- diff --git a/lib/SelfLoader.pm b/lib/SelfLoader.pm index 1136cf0..da89094 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 6987f65..feadd3d 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 = ; 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 = ; 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