/
breadth-depth.t
82 lines (68 loc) · 1.53 KB
/
breadth-depth.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use 5.006;
use strict;
use warnings;
use Test::More 0.92;
use Path::Class;
use File::Temp;
use Test::Deep qw/cmp_deeply/;
use File::pushd qw/pushd/;
use lib 't/lib';
use PCNTest;
use Path::Class::Rule;
#--------------------------------------------------------------------------#
{
my @tree = qw(
aaaa.txt
bbbb.txt
cccc/dddd.txt
cccc/eeee/ffff.txt
gggg.txt
);
my @breadth = qw(
.
aaaa.txt
bbbb.txt
cccc
gggg.txt
cccc/dddd.txt
cccc/eeee
cccc/eeee/ffff.txt
);
my @depth_pre = qw(
.
aaaa.txt
bbbb.txt
cccc
cccc/dddd.txt
cccc/eeee
cccc/eeee/ffff.txt
gggg.txt
);
my @depth_post = qw(
aaaa.txt
bbbb.txt
cccc/dddd.txt
cccc/eeee/ffff.txt
cccc/eeee
cccc
gggg.txt
.
);
my $td = make_tree(@tree);
my ($iter, @files);
my $rule = Path::Class::Rule->new;
@files = map { $_->relative($td)->as_foreign("Unix")->stringify }
$rule->all({depthfirst => 0}, $td);
cmp_deeply( \@files, \@breadth, "Breadth first iteration")
or diag explain \@files;
@files = map { $_->relative($td)->as_foreign("Unix")->stringify }
$rule->all({depthfirst => -1}, $td);
cmp_deeply( \@files, \@depth_pre, "Depth first iteration (pre)")
or diag explain \@files;
@files = map { $_->relative($td)->as_foreign("Unix")->stringify }
$rule->all({depthfirst => 1}, $td);
cmp_deeply( \@files, \@depth_post, "Depth first iteration (post)")
or diag explain \@files;
}
done_testing;
# COPYRIGHT