1*0Sstevel@tonic-gate#!./perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateBEGIN { 4*0Sstevel@tonic-gate chdir 't' if -d 't'; 5*0Sstevel@tonic-gate @INC = '../lib'; 6*0Sstevel@tonic-gate} 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gateprint "1..10\n"; 9*0Sstevel@tonic-gate 10*0Sstevel@tonic-gate@oops = @ops = <op/*>; 11*0Sstevel@tonic-gate 12*0Sstevel@tonic-gateif ($^O eq 'MSWin32') { 13*0Sstevel@tonic-gate map { $files{lc($_)}++ } <op/*>; 14*0Sstevel@tonic-gate map { delete $files{"op/$_"} } split /[\s\n]/, `dir /b /l op & dir /b /l /ah op 2>nul`, 15*0Sstevel@tonic-gate} 16*0Sstevel@tonic-gateelsif ($^O eq 'VMS') { 17*0Sstevel@tonic-gate map { $files{lc($_)}++ } <[.op]*>; 18*0Sstevel@tonic-gate map { s/;.*$//; delete $files{lc($_)}; } split /[\n]/, `directory/noheading/notrailing/versions=1 [.op]`, 19*0Sstevel@tonic-gate} 20*0Sstevel@tonic-gateelsif ($^O eq 'MacOS') { 21*0Sstevel@tonic-gate @oops = @ops = <:op:*>; 22*0Sstevel@tonic-gate map { $files{$_}++ } <:op:*>; 23*0Sstevel@tonic-gate map { delete $files{$_} } split /[\s\n]/, `echo :op:\xc5`; 24*0Sstevel@tonic-gate} 25*0Sstevel@tonic-gateelse { 26*0Sstevel@tonic-gate map { $files{$_}++ } <op/*>; 27*0Sstevel@tonic-gate map { delete $files{$_} } split /[\s\n]/, `echo op/*`; 28*0Sstevel@tonic-gate} 29*0Sstevel@tonic-gateif (keys %files) { 30*0Sstevel@tonic-gate print "not ok 1\t(",join(' ', sort keys %files),"\n"; 31*0Sstevel@tonic-gate} else { print "ok 1\n"; } 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gateprint $/ eq "\n" ? "ok 2\n" : "not ok 2\n"; 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gateif ($^O eq 'MacOS') { 36*0Sstevel@tonic-gate while (<jskdfjskdfj* :op:* jskdjfjkosvk*>) { 37*0Sstevel@tonic-gate $not = "not " unless $_ eq shift @ops; 38*0Sstevel@tonic-gate $not = "not at all " if $/ eq "\0"; 39*0Sstevel@tonic-gate } 40*0Sstevel@tonic-gate} else { 41*0Sstevel@tonic-gate while (<jskdfjskdfj* op/* jskdjfjkosvk*>) { 42*0Sstevel@tonic-gate $not = "not " unless $_ eq shift @ops; 43*0Sstevel@tonic-gate $not = "not at all " if $/ eq "\0"; 44*0Sstevel@tonic-gate } 45*0Sstevel@tonic-gate} 46*0Sstevel@tonic-gateprint "${not}ok 3\n"; 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gateprint $/ eq "\n" ? "ok 4\n" : "not ok 4\n"; 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate# test the "glob" operator 51*0Sstevel@tonic-gate$_ = $^O eq 'MacOS' ? ":op:*" : "op/*"; 52*0Sstevel@tonic-gate@glops = glob $_; 53*0Sstevel@tonic-gateprint "@glops" eq "@oops" ? "ok 5\n" : "not ok 5\n"; 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate@glops = glob; 56*0Sstevel@tonic-gateprint "@glops" eq "@oops" ? "ok 6\n" : "not ok 6\n"; 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate# glob should still work even after the File::Glob stash has gone away 59*0Sstevel@tonic-gate# (this used to dump core) 60*0Sstevel@tonic-gatemy $i = 0; 61*0Sstevel@tonic-gatefor (1..2) { 62*0Sstevel@tonic-gate eval "<.>"; 63*0Sstevel@tonic-gate undef %File::Glob::; 64*0Sstevel@tonic-gate ++$i; 65*0Sstevel@tonic-gate} 66*0Sstevel@tonic-gateprint $i == 2 ? "ok 7\n" : "not ok 7\n"; 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate# ... while ($var = glob(...)) should test definedness not truth 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gateif( $INC{'File/Glob.pm'} ) { 71*0Sstevel@tonic-gate my $ok = "not ok 8\n"; 72*0Sstevel@tonic-gate $ok = "ok 8\n" while my $var = glob("0"); 73*0Sstevel@tonic-gate print $ok; 74*0Sstevel@tonic-gate} 75*0Sstevel@tonic-gateelse { 76*0Sstevel@tonic-gate print "ok 8 # skip: File::Glob emulated Unixism\n"; 77*0Sstevel@tonic-gate} 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate# The formerly-broken test for the situation above would accidentally 81*0Sstevel@tonic-gate# test definedness for an assignment with a LOGOP on the right: 82*0Sstevel@tonic-gatemy $f=0; 83*0Sstevel@tonic-gate$ok="ok 9\n"; 84*0Sstevel@tonic-gate$ok="not ok 9\n", undef $f while $x = $f||$f; 85*0Sstevel@tonic-gateprint $ok; 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate# Better check that glob actually returned some entries 88*0Sstevel@tonic-gate{ 89*0Sstevel@tonic-gate my $not = (scalar @oops > 0) ? '' : 'not '; 90*0Sstevel@tonic-gate print "${not}ok 10\n"; 91*0Sstevel@tonic-gate} 92