Change 32665 by [EMAIL PROTECTED] on 2007/12/20 09:54:23
Subject: Re: [perl #48769] [PATCH] SelfLoader.pm 1.0904 - Whitespace in
subroutine
From: Steffen Mueller <[EMAIL PROTECTED]>
Date: Tue, 18 Dec 2007 11:58:19 +0100
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/lib/SelfLoader.pm#25 edit
... //depot/perl/lib/SelfLoader.t#2 edit
Differences ...
==== //depot/perl/lib/SelfLoader.pm#25 (text) ====
Index: perl/lib/SelfLoader.pm
--- perl/lib/SelfLoader.pm#24~30418~ 2007-02-27 06:07:28.000000000 -0800
+++ perl/lib/SelfLoader.pm 2007-12-20 01:54:23.000000000 -0800
@@ -6,7 +6,7 @@
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 @@
local($/) = "\n";
while(defined($line = <$fh>) and $line !~ m/^__END__/) {
- if ($line =~ m/^sub\s+([\w:]+)\s*((?:\([EMAIL
PROTECTED]&\*\;]*\))?(?:$attr_list)?)/) {
+ if ($line =~ m/^\s*sub\s+([\w:]+)\s*((?:\([EMAIL
PROTECTED]&\*\;]*\))?(?:$attr_list)?)/) {
push(@stubs, $self->_add_to_cache($name, $currpack, [EMAIL
PROTECTED], $protoype));
$protoype = $2;
@lines = ($line);
==== //depot/perl/lib/SelfLoader.t#2 (xtext) ====
Index: perl/lib/SelfLoader.t
--- perl/lib/SelfLoader.t#1~10676~ 2001-06-17 21:17:15.000000000 -0700
+++ perl/lib/SelfLoader.t 2007-12-20 01:54:23.000000000 -0800
@@ -13,7 +13,7 @@
@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 @@
package sheep;
sub bleat { shift; shift || "baa" }
-
__END__
sub never { die "D'oh" }
EOT
@@ -56,6 +55,7 @@
sub new { bless {}, shift }
sub a;
+sub with_whitespace_in_front;
1;
__DATA__
@@ -63,6 +63,10 @@
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 "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 @@
$foo->never;
};
if ($@ =~ /^Undefined subroutine/) {
- print "ok 16\n";
+ print "ok 17\n";
} else {
- print "not ok 16 [EMAIL PROTECTED]";
+ print "not ok 17 [EMAIL PROTECTED]";
}
# 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 @@
$bar->never;
};
if ($@ =~ /^Undefined subroutine/) {
- print "ok 18\n";
+ print "ok 19\n";
} else {
- print "not ok 18 [EMAIL PROTECTED]";
+ print "not ok 19 [EMAIL PROTECTED]";
}
# 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
End of Patch.