Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't depend on file system ordering

  • Loading branch information...
commit b6162f868ea2a7db6bfdf7323ce9ece414516ab4 1 parent ba21fde
@Leont Leont authored committed
Showing with 12 additions and 11 deletions.
  1. +4 −4 t/autodie.t
  2. +8 −7 t/readdir.t
View
8 t/autodie.t
@@ -20,10 +20,10 @@ subtest 'autodie first' => sub {
use utf8::all;
opendir my $dh, 'corpus';
- my @files = grep { !m{^\.} } readdir $dh;
+ my @files = sort grep { !m{^\.} } readdir $dh;
closedir $dh;
- is_deeply \@files, ["\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testfile"];
+ is_deeply \@files, [sort "\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testfile"];
my $exception = exception { opendir my $no_dh, 'nonexistent' };
like $exception => qr/No such file or directory/;
@@ -35,10 +35,10 @@ subtest 'autodie last' => sub {
use autodie;
opendir my $dh, 'corpus';
- my @files = grep { !m{^\.} } readdir $dh;
+ my @files = sort grep { !m{^\.} } readdir $dh;
closedir $dh;
- is_deeply \@files, ["\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testfile"];
+ is_deeply \@files, [ sort "\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testfile"];
my $exception = exception { opendir my $no_dh, 'nonexistent' };
like $exception, qr/No such file or directory/;
View
15 t/readdir.t
@@ -1,6 +1,7 @@
use strict;
use warnings;
use Test::More 0.96 tests => 2;
+use Encode qw/decode FB_CROAK/;
subtest utf8 => sub {
plan tests => 3;
@@ -8,18 +9,18 @@ subtest utf8 => sub {
opendir my $dh, 'corpus'
or die "Couldn't open directory 'corpus'";
- my @files = grep { $_ ne '.' and $_ ne '..' } readdir $dh;
+ my @files = sort grep { $_ ne '.' and $_ ne '..' } readdir $dh;
my @utf8_files;
{
rewinddir $dh;
use utf8::all;
- @utf8_files = grep { $_ ne '.' and $_ ne '..' } readdir $dh;
+ @utf8_files = sort grep { $_ ne '.' and $_ ne '..' } readdir $dh;
}
closedir $dh;
- is_deeply \@utf8_files, ["\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testfile"];
- isnt $files[0] => $utf8_files[0];
- is $files[1] => $utf8_files[1];
+ is_deeply \@utf8_files, [sort "\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testfile"];
+ is $files[0] => $utf8_files[0];
+ isnt $files[1] => $utf8_files[1];
};
subtest context => sub {
@@ -34,6 +35,6 @@ subtest context => sub {
my $utf8 = readdir $dh;
rewinddir $dh;
- is $utf8 => $core;
+ is $utf8 => decode('UTF-8', $core, FB_CROAK) or diag "$utf8 : $core";
closedir $dh;
-};
+};
Please sign in to comment.
Something went wrong with that request. Please try again.