Subject: | patch to fix t/synopsis2.t by ordering directory entries |
The test 't/synopsis2.t' fails on my system. The following line:
while (my $io = $dir->next) {
gets $io objects in this order:
# t/mydir/file2
# t/mydir/dir2
# t/mydir/dir1
# t/mydir/file3
# t/mydir/file1
which causes three tests to fail, since it is expecting to first see file1, then file2, then file3 (dir1 and dir2 are ignored in this loop).
The attached patch fixes this using the following:
foreach my $io ($dir->all) {
IO::Dir->all sorts the $io objects by pathname before returning the list of $io objects, so the tests completes successfully.
Hope this helps,
-Adam
--- IO-All-0.33/t/synopsis2.t 2004-11-29 23:30:41.000000000 -0800
+++ IO-All-0.33/t/synopsis2.t 2005-05-26 10:17:51.000000000 -0700
@@ -8,7 +8,7 @@
# Print name and first line of all files in a directory
my $dir = io('t/mydir');
ok($dir->is_dir);
-while (my $io = $dir->next) {
+foreach my $io ($dir->all) {
if ($io->is_file) {
my $line = $io->name . ' - ' . $io->getline;
is($line, flip_slash scalar <DATA>);