diff options
author | David Landgren <david@landgren.net> | 2006-04-29 17:32:07 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-05-02 10:39:01 +0000 |
commit | 9b38b30791d5c3d84f35037508a73dd07542022f (patch) | |
tree | 2bfeabaf8e3197d3272e70fd890dbaf058c71dc2 /t/op/glob.t | |
parent | 6647cf4edb2b5f87e78f9df85deeb68eccb8a090 (diff) | |
download | perl-9b38b30791d5c3d84f35037508a73dd07542022f.tar.gz |
Re: [PATCH] t/op/glob.t using test.pl
Message-ID: <44536AD7.4060608@landgren.net>
p4raw-id: //depot/perl@28057
Diffstat (limited to 't/op/glob.t')
-rwxr-xr-x | t/op/glob.t | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/t/op/glob.t b/t/op/glob.t index d03d75fc43..03302dcf6f 100755 --- a/t/op/glob.t +++ b/t/op/glob.t @@ -2,10 +2,11 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; + @INC = qw(. ../lib); } -print "1..10\n"; +require 'test.pl'; +plan( tests => 12 ); @oops = @ops = <op/*>; @@ -26,12 +27,11 @@ else { map { $files{$_}++ } <op/*>; map { delete $files{$_} } split /[\s\n]/, `echo op/*`; } -if (keys %files) { - print "not ok 1\t(",join(' ', sort keys %files),"\n"; -} else { print "ok 1\n"; } +ok( !(keys(%files)),'leftover op/* files' ) or diag(join(' ',sort keys %files)); -print $/ eq "\n" ? "ok 2\n" : "not ok 2\n"; +cmp_ok($/,'eq',"\n",'sane input record separator'); +$not = ''; if ($^O eq 'MacOS') { while (<jskdfjskdfj* :op:* jskdjfjkosvk*>) { $not = "not " unless $_ eq shift @ops; @@ -43,49 +43,45 @@ if ($^O eq 'MacOS') { $not = "not at all " if $/ eq "\0"; } } -print "${not}ok 3\n"; +ok(!$not,"glob amid garbage [$not]"); -print $/ eq "\n" ? "ok 4\n" : "not ok 4\n"; +cmp_ok($/,'eq',"\n",'input record separator still sane'); -# test the "glob" operator $_ = $^O eq 'MacOS' ? ":op:*" : "op/*"; @glops = glob $_; -print "@glops" eq "@oops" ? "ok 5\n" : "not ok 5\n"; +cmp_ok("@glops",'eq',"@oops",'glob operator 1'); @glops = glob; -print "@glops" eq "@oops" ? "ok 6\n" : "not ok 6\n"; +cmp_ok("@glops",'eq',"@oops",'glob operator 2'); # glob should still work even after the File::Glob stash has gone away # (this used to dump core) my $i = 0; for (1..2) { eval "<.>"; + ok(!length($@),"eval'ed a glob $_"); undef %File::Glob::; ++$i; } -print $i == 2 ? "ok 7\n" : "not ok 7\n"; +cmp_ok($i,'==',2,'remore File::Glob stash'); # ... while ($var = glob(...)) should test definedness not truth -if( $INC{'File/Glob.pm'} ) { - my $ok = "not ok 8\n"; - $ok = "ok 8\n" while my $var = glob("0"); - print $ok; +SKIP: { + skip('no File::Glob to emulate Unix-ism', 1) + unless $INC{'File/Glob.pm'}; + my $ok = 0; + $ok = 1 while my $var = glob("0"); + ok($ok,'define versus truth'); } -else { - print "ok 8 # skip: File::Glob emulated Unixism\n"; -} - # The formerly-broken test for the situation above would accidentally # test definedness for an assignment with a LOGOP on the right: -my $f=0; -$ok="ok 9\n"; -$ok="not ok 9\n", undef $f while $x = $f||$f; -print $ok; - -# Better check that glob actually returned some entries { - my $not = (scalar @oops > 0) ? '' : 'not '; - print "${not}ok 10\n"; + my $f = 0; + my $ok = 1; + $ok = 0, undef $f while $x = $f||$f; + ok($ok,'test definedness with LOGOP'); } + +cmp_ok(scalar(@oops),'>',0,'glob globbed something'); |