For miniperl, disable PERL_UNICODE and -C.
[p5sagit/p5-mst-13.2.git] / ext / Shell / t / Shell.t
CommitLineData
e66df073 1#!./perl
2
51947a20 3use Test::More tests => 7;
e66df073 4
5BEGIN { use_ok('Shell'); }
6
51947a20 7my $so = Shell->new;
8ok($so, 'Shell->new');
9
e66df073 10my $Is_VMS = $^O eq 'VMS';
11my $Is_MSWin32 = $^O eq 'MSWin32';
12my $Is_NetWare = $^O eq 'NetWare';
13
51947a20 14$Shell::capture_stderr = 1;
e66df073 15
16# Now test that that works ..
17
18my $tmpfile = 'sht0001';
51947a20 19while ( -f $tmpfile ) {
20 $tmpfile++;
e66df073 21}
51947a20 22END { -f $tmpfile && (open STDERR, '>&SAVERR' and unlink $tmpfile) }
e66df073 23
ad9da128 24no warnings 'once';
25# no false warning about Name "main::SAVERR" used only once: possible typo
e66df073 26
51947a20 27open(SAVERR, ">&STDERR");
e66df073 28open(STDERR, ">$tmpfile");
29
670c206d 30xXx_not_there(); # Ok someone could have a program called this :(
e66df073 31
dfcfdb64 32# On os2 the warning is on by default...
51947a20 33ok(($^O eq 'os2' xor !(-s $tmpfile)), '$Shell::capture_stderr');
e66df073 34
51947a20 35$Shell::capture_stderr = 0;
e66df073 36
37# someone will have to fill in the blanks for other platforms
38
51947a20 39if ($Is_VMS) {
40 ok(directory(), 'Execute command');
72c157b0 41 my @files = directory('*.*');
51947a20 42 ok(@files, 'Quoted arguments');
43
44 ok(eq_array(\@files, [$so->directory('*.*')]), 'object method');
45 eval { $so->directory };
46 ok(!$@, '2 methods calls');
47} elsif ($Is_MSWin32) {
48 ok(dir(), 'Execute command');
49 my @files = dir('*.*');
50 ok(@files, 'Quoted arguments');
51
52 ok(eq_array(\@files, [$so->dir('*.*')]), 'object method');
53 eval { $so->dir };
54 ok(!$@, '2 methods calls');
55} else {
56 ok(ls(), 'Execute command');
57 my @files = ls('*');
58 ok(@files, 'Quoted arguments');
59
60 ok(eq_array(\@files, [$so->ls('*')]), 'object method');
61 eval { $so->ls };
62 ok(!$@, '2 methods calls');
e66df073 63
64}
51947a20 65open(STDERR, ">&SAVERR") ;