diff options
author | Rafael Garcia-Suarez <rgs@consttype.org> | 2009-10-22 22:39:45 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2009-10-22 22:39:45 +0200 |
commit | d1c21cecdd89e9b092d8df4a520111183a1d537a (patch) | |
tree | be2320ef1942b7cd539af703c515e60f73173a7c /t | |
parent | 114c60ecb1f775ef1deb4fdc8fb8e3a6f343d13d (diff) | |
download | perl-d1c21cecdd89e9b092d8df4a520111183a1d537a.tar.gz |
Remove file t/0 added by last commit
Make the test create it instead
Diffstat (limited to 't')
-rw-r--r-- | t/0 | 6 | ||||
-rw-r--r-- | t/op/while_readdir.t | 105 |
2 files changed, 57 insertions, 54 deletions
@@ -1,6 +0,0 @@ -This file is here for testing - -while(readdir $dir){...} -... while readdir $dir - -etc diff --git a/t/op/while_readdir.t b/t/op/while_readdir.t index 740bfdd70a..851c6d751a 100644 --- a/t/op/while_readdir.t +++ b/t/op/while_readdir.t @@ -9,14 +9,26 @@ BEGIN { use strict; use warnings; -opendir my $dirhandle, '.' or die "Failed test: unable to open directory\n"; +open my $fh, ">", "0" or die "Can't open '0' for writing: $!\n"; +print $fh <<'FILE0'; +This file is here for testing -my @dir = readdir $dirhandle; -rewinddir $dirhandle; +while(readdir $dir){...} +... while readdir $dir -plan 9; +etc +FILE0 +close $fh; +plan 10; +ok(-f '0', "'0' file is here"); + +opendir my $dirhandle, '.' + or die "Failed test: unable to open directory: $!\n"; + +my @dir = readdir $dirhandle; +rewinddir $dirhandle; { my @list; @@ -62,54 +74,51 @@ plan 9; rewinddir $dirhandle; } -SKIP:{ - skip ('No file named "0"',4) unless (scalar grep{ defined $_ && $_ eq '0' } @dir ); - - { - my $works = 0; - while(readdir $dirhandle){ - if( defined $_ && $_ eq '0'){ - $works = 1; - last; - } - } - ok( $works, 'while(readdir){} with file named "0"' ); - rewinddir $dirhandle; - } - - { - my $works = 0; - my $sub = sub{ - if( defined $_ && $_ eq '0' ){ - $works = 1; - } - }; - $sub->($_) while readdir $dirhandle; - ok( $works, '$sub->($_) while readdir; with file named "0"' ); - rewinddir $dirhandle; - } - - { - my $works = 0; - while( my $dir = readdir $dirhandle ){ - if( defined $dir && $dir eq '0'){ - $works = 1; - last; - } - } - ok( $works, 'while($dir=readdir){} with file named "0"'); - rewinddir $dirhandle; +{ + my $works = 0; + while(readdir $dirhandle){ + if( defined $_ && $_ eq '0'){ + $works = 1; + last; + } } + ok( $works, 'while(readdir){} with file named "0"' ); + rewinddir $dirhandle; +} - { - my $tmp; - my $ok; - my @list; - defined($tmp)&& !$tmp && ($ok=1) while $tmp = readdir $dirhandle; - ok( $ok, '$dir while $dir = readdir; with file named "0"' ); - rewinddir $dirhandle; +{ + my $works = 0; + my $sub = sub{ + if( defined $_ && $_ eq '0' ){ + $works = 1; + } + }; + $sub->($_) while readdir $dirhandle; + ok( $works, '$sub->($_) while readdir; with file named "0"' ); + rewinddir $dirhandle; +} + +{ + my $works = 0; + while( my $dir = readdir $dirhandle ){ + if( defined $dir && $dir eq '0'){ + $works = 1; + last; + } } + ok( $works, 'while($dir=readdir){} with file named "0"'); + rewinddir $dirhandle; +} +{ + my $tmp; + my $ok; + my @list; + defined($tmp)&& !$tmp && ($ok=1) while $tmp = readdir $dirhandle; + ok( $ok, '$dir while $dir = readdir; with file named "0"' ); + rewinddir $dirhandle; } closedir $dirhandle; + +END { 1 while unlink "0" } |