1N/A#!./perl
1N/A
1N/ABEGIN {
1N/A chdir 't' if -d 't';
1N/A @INC = '../lib';
1N/A}
1N/A
1N/Aprint "1..10\n";
1N/A
1N/A@oops = @ops = <op/*>;
1N/A
1N/Aif ($^O eq 'MSWin32') {
1N/A map { $files{lc($_)}++ } <op/*>;
1N/A map { delete $files{"op/$_"} } split /[\s\n]/, `dir /b /l op & dir /b /l /ah op 2>nul`,
1N/A}
1N/Aelsif ($^O eq 'VMS') {
1N/A map { $files{lc($_)}++ } <[.op]*>;
1N/A map { s/;.*$//; delete $files{lc($_)}; } split /[\n]/, `directory/noheading/notrailing/versions=1 [.op]`,
1N/A}
1N/Aelsif ($^O eq 'MacOS') {
1N/A @oops = @ops = <:op:*>;
1N/A map { $files{$_}++ } <:op:*>;
1N/A map { delete $files{$_} } split /[\s\n]/, `echo :op:\xc5`;
1N/A}
1N/Aelse {
1N/A map { $files{$_}++ } <op/*>;
1N/A map { delete $files{$_} } split /[\s\n]/, `echo op/*`;
1N/A}
1N/Aif (keys %files) {
1N/A print "not ok 1\t(",join(' ', sort keys %files),"\n";
1N/A} else { print "ok 1\n"; }
1N/A
1N/Aprint $/ eq "\n" ? "ok 2\n" : "not ok 2\n";
1N/A
1N/Aif ($^O eq 'MacOS') {
1N/A while (<jskdfjskdfj* :op:* jskdjfjkosvk*>) {
1N/A $not = "not " unless $_ eq shift @ops;
1N/A $not = "not at all " if $/ eq "\0";
1N/A }
1N/A} else {
1N/A while (<jskdfjskdfj* op/* jskdjfjkosvk*>) {
1N/A $not = "not " unless $_ eq shift @ops;
1N/A $not = "not at all " if $/ eq "\0";
1N/A }
1N/A}
1N/Aprint "${not}ok 3\n";
1N/A
1N/Aprint $/ eq "\n" ? "ok 4\n" : "not ok 4\n";
1N/A
1N/A# test the "glob" operator
1N/A$_ = $^O eq 'MacOS' ? ":op:*" : "op/*";
1N/A@glops = glob $_;
1N/Aprint "@glops" eq "@oops" ? "ok 5\n" : "not ok 5\n";
1N/A
1N/A@glops = glob;
1N/Aprint "@glops" eq "@oops" ? "ok 6\n" : "not ok 6\n";
1N/A
1N/A# glob should still work even after the File::Glob stash has gone away
1N/A# (this used to dump core)
1N/Amy $i = 0;
1N/Afor (1..2) {
1N/A eval "<.>";
1N/A undef %File::Glob::;
1N/A ++$i;
1N/A}
1N/Aprint $i == 2 ? "ok 7\n" : "not ok 7\n";
1N/A
1N/A# ... while ($var = glob(...)) should test definedness not truth
1N/A
1N/Aif( $INC{'File/Glob.pm'} ) {
1N/A my $ok = "not ok 8\n";
1N/A $ok = "ok 8\n" while my $var = glob("0");
1N/A print $ok;
1N/A}
1N/Aelse {
1N/A print "ok 8 # skip: File::Glob emulated Unixism\n";
1N/A}
1N/A
1N/A
1N/A# The formerly-broken test for the situation above would accidentally
1N/A# test definedness for an assignment with a LOGOP on the right:
1N/Amy $f=0;
1N/A$ok="ok 9\n";
1N/A$ok="not ok 9\n", undef $f while $x = $f||$f;
1N/Aprint $ok;
1N/A
1N/A# Better check that glob actually returned some entries
1N/A{
1N/A my $not = (scalar @oops > 0) ? '' : 'not ';
1N/A print "${not}ok 10\n";
1N/A}