Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (44 sloc) 1.25 KB
use 5.006;
use strict;
use warnings;
use Test::More 0.92;
use File::Temp;
use File::pushd qw/pushd/;
use lib 't/lib';
use PCNTest;
use PIR;
#--------------------------------------------------------------------------#
{
my $td = make_tree(
qw(
empty/
data/file1.txt
)
);
my ( $iter, @files );
my $rule = PIR->new->file;
$iter = $rule->iter($td);
@files = ();
while ( my $f = $iter->() ) {
push @files, $f;
}
is( scalar @files, 1, "Iterator: one file" ) or diag explain \@files;
is( ref $files[0], '', "Iterator: returns string, not object" );
@files = ();
@files = $rule->all($td);
is( scalar @files, 1, "All: one file" ) or diag explain \@files;
$rule = PIR->new->dir;
@files = ();
@files = map { "$_" } $rule->all($td);
is( scalar @files, 3, "All: 3 directories" ) or diag explain \@files;
my $wd = pushd($td);
@files = ();
@files = map { "$_" } $rule->all();
is( scalar @files, 3, "All w/ cwd: 3 directories" ) or diag explain \@files;
$rule->skip_dirs(qw/data/);
@files = ();
@files = map { "$_" } $rule->all();
is( scalar @files, 2, "All w/ prune: 2 directories" ) or diag explain \@files;
}
done_testing;
# COPYRIGHT
Something went wrong with that request. Please try again.