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