This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fixes to compile Perl with g++ and DEBUGGING.
[perl5.git] / lib / Shell.t
CommitLineData
e66df073
JS
1#!./perl
2
dfcfdb64 3BEGIN {
ff5c8f2a
AF
4 if( $ENV{PERL_CORE} ) {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 }
dfcfdb64
IZ
8}
9
51947a20 10use Test::More tests => 7;
e66df073
JS
11
12BEGIN { use_ok('Shell'); }
13
51947a20
DB
14my $so = Shell->new;
15ok($so, 'Shell->new');
16
e66df073
JS
17my $Is_VMS = $^O eq 'VMS';
18my $Is_MSWin32 = $^O eq 'MSWin32';
19my $Is_NetWare = $^O eq 'NetWare';
20
51947a20 21$Shell::capture_stderr = 1;
e66df073
JS
22
23# Now test that that works ..
24
25my $tmpfile = 'sht0001';
51947a20
DB
26while ( -f $tmpfile ) {
27 $tmpfile++;
e66df073 28}
51947a20 29END { -f $tmpfile && (open STDERR, '>&SAVERR' and unlink $tmpfile) }
e66df073
JS
30
31
51947a20 32open(SAVERR, ">&STDERR");
e66df073
JS
33open(STDERR, ">$tmpfile");
34
670c206d 35xXx_not_there(); # Ok someone could have a program called this :(
e66df073 36
dfcfdb64 37# On os2 the warning is on by default...
51947a20 38ok(($^O eq 'os2' xor !(-s $tmpfile)), '$Shell::capture_stderr');
e66df073 39
51947a20 40$Shell::capture_stderr = 0;
e66df073
JS
41
42# someone will have to fill in the blanks for other platforms
43
51947a20
DB
44if ($Is_VMS) {
45 ok(directory(), 'Execute command');
72c157b0 46 my @files = directory('*.*');
51947a20
DB
47 ok(@files, 'Quoted arguments');
48
49 ok(eq_array(\@files, [$so->directory('*.*')]), 'object method');
50 eval { $so->directory };
51 ok(!$@, '2 methods calls');
52} elsif ($Is_MSWin32) {
53 ok(dir(), 'Execute command');
54 my @files = dir('*.*');
55 ok(@files, 'Quoted arguments');
56
57 ok(eq_array(\@files, [$so->dir('*.*')]), 'object method');
58 eval { $so->dir };
59 ok(!$@, '2 methods calls');
60} else {
61 ok(ls(), 'Execute command');
62 my @files = ls('*');
63 ok(@files, 'Quoted arguments');
64
65 ok(eq_array(\@files, [$so->ls('*')]), 'object method');
66 eval { $so->ls };
67 ok(!$@, '2 methods calls');
e66df073
JS
68
69}
51947a20 70open(STDERR, ">&SAVERR") ;