Change 18044 by [EMAIL PROTECTED] on 2002/10/22 15:43:55
Subject: [PATCH] Shell.pm object methods broken
From: Dan Brook <[EMAIL PROTECTED]>
Date: Thu, 17 Oct 2002 16:05:04 +0100
Message-Id: <[EMAIL PROTECTED]>
Affected files ...
.... //depot/perl/lib/Shell.pm#15 edit
.... //depot/perl/lib/Shell.t#5 edit
Differences ...
==== //depot/perl/lib/Shell.pm#15 (text) ====
Index: perl/lib/Shell.pm
--- perl/lib/Shell.pm#14~12113~ Fri Sep 21 10:08:24 2001
+++ perl/lib/Shell.pm Tue Oct 22 08:43:55 2002
@@ -30,6 +30,7 @@
$cmd =~ s/^.*:://;
eval <<"*END*";
sub $AUTOLOAD {
+ shift if ref \$_[0] && \$_[0]->isa( 'Shell' );
if (\@_ < 1) {
\$Shell::capture_stderr ? `$cmd 2>&1` : `$cmd`;
} elsif ('$^O' eq 'os2') {
==== //depot/perl/lib/Shell.t#5 (text) ====
Index: perl/lib/Shell.t
--- perl/lib/Shell.t#4~13805~ Wed Dec 19 07:04:03 2001
+++ perl/lib/Shell.t Tue Oct 22 08:43:55 2002
@@ -5,62 +5,64 @@
@INC = '../lib';
}
-use Test::More tests => 4;
+use Test::More tests => 7;
BEGIN { use_ok('Shell'); }
+my $so = Shell->new;
+ok($so, 'Shell->new');
+
my $Is_VMS = $^O eq 'VMS';
my $Is_MSWin32 = $^O eq 'MSWin32';
my $Is_NetWare = $^O eq 'NetWare';
-$Shell::capture_stderr = 1; #
+$Shell::capture_stderr = 1;
# Now test that that works ..
my $tmpfile = 'sht0001';
-
-while ( -f $tmpfile )
-{
- $tmpfile++;
+while ( -f $tmpfile ) {
+ $tmpfile++;
}
-
-END { -f $tmpfile && (open STDERR, '>&SAVERR' and unlink $tmpfile) };
+END { -f $tmpfile && (open STDERR, '>&SAVERR' and unlink $tmpfile) }
-
-open(SAVERR,">&STDERR") ;
+open(SAVERR, ">&STDERR");
open(STDERR, ">$tmpfile");
xXx(); # Ok someone could have a program called this :(
# On os2 the warning is on by default...
-ok( ($^O eq 'os2' xor !(-s $tmpfile)) ,'$Shell::capture_stderr');
+ok(($^O eq 'os2' xor !(-s $tmpfile)), '$Shell::capture_stderr');
-$Shell::capture_stderr = 0; #
+$Shell::capture_stderr = 0;
# someone will have to fill in the blanks for other platforms
-if ( $Is_VMS )
-{
- ok(directory(),'Execute command');
+if ($Is_VMS) {
+ ok(directory(), 'Execute command');
my @files = directory('*.*');
- ok(@files,'Quoted arguments');
-}
-elsif( $Is_MSWin32 )
-{
- ok(dir(),'Execute command');
-
- my @files = dir('*.*');
-
- ok(@files, 'Quoted arguments');
-}
-else
-{
- ok(ls(),'Execute command');
-
- my @files = ls('*');
+ ok(@files, 'Quoted arguments');
- ok(@files,'Quoted arguments');
+ ok(eq_array(\@files, [$so->directory('*.*')]), 'object method');
+ eval { $so->directory };
+ ok(!$@, '2 methods calls');
+} elsif ($Is_MSWin32) {
+ ok(dir(), 'Execute command');
+ my @files = dir('*.*');
+ ok(@files, 'Quoted arguments');
+
+ ok(eq_array(\@files, [$so->dir('*.*')]), 'object method');
+ eval { $so->dir };
+ ok(!$@, '2 methods calls');
+} else {
+ ok(ls(), 'Execute command');
+ my @files = ls('*');
+ ok(@files, 'Quoted arguments');
+
+ ok(eq_array(\@files, [$so->ls('*')]), 'object method');
+ eval { $so->ls };
+ ok(!$@, '2 methods calls');
}
-open(STDERR,">&SAVERR") ;
+open(STDERR, ">&SAVERR") ;
End of Patch.