diff options
author | Dan Brook <dbrook@easyspace.com> | 2002-10-17 17:05:04 +0100 |
---|---|---|
committer | hv <hv@crypt.org> | 2002-10-22 15:43:55 +0000 |
commit | 51947a20dc2d93fe0888ee6d69de8ae4aca4aef4 (patch) | |
tree | ff486cccc86fe2337a1953d0ba9bade48d944c96 | |
parent | 66fbe8fb06e4bc8631604373e6a099f620f92dcf (diff) | |
download | perl-51947a20dc2d93fe0888ee6d69de8ae4aca4aef4.tar.gz |
Shell.pm object methods broken
Message-Id: <20021017160504.63926a1b.dbrook@easyspace.com>
p4raw-id: //depot/perl@18044
-rw-r--r-- | lib/Shell.pm | 1 | ||||
-rw-r--r-- | lib/Shell.t | 68 |
2 files changed, 36 insertions, 33 deletions
diff --git a/lib/Shell.pm b/lib/Shell.pm index 9762a3aa0b..81b25985a5 100644 --- a/lib/Shell.pm +++ b/lib/Shell.pm @@ -30,6 +30,7 @@ sub AUTOLOAD { $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') { diff --git a/lib/Shell.t b/lib/Shell.t index b2d3d67aa0..c7c45d3f2c 100644 --- a/lib/Shell.t +++ b/lib/Shell.t @@ -5,62 +5,64 @@ BEGIN { @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") ; |