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
|
package TestFor::Code::TidyAll::Util::Zglob;
use Test::Class::Most parent => 'TestHelper::Test::Class';
use Code::TidyAll::Util::Zglob qw(zglob_to_regex);
sub test_match : Tests {
my ( $zglob, $regex );
$zglob = '**/*.txt';
$regex = zglob_to_regex($zglob);
foreach my $path (qw(foo.txt foo/baz.txt foo/bar/baz.txt)) {
like( $path, $regex, "$path matches $zglob" );
}
foreach my $path (qw(foo/bar/baz.tx)) {
unlike( $path, $regex, "$path does not match $zglob" );
}
$zglob = '**/*';
$regex = zglob_to_regex($zglob);
foreach my $path (qw(foo foo.txt foo/bar foo/baz.txt)) {
like( $path, $regex, "$path matches $zglob" );
}
$zglob = 'foo/**/*.txt';
$regex = zglob_to_regex($zglob);
foreach my $path (qw(foo/baz.txt foo/bar/baz.txt foo/bar/baz/blargh.txt)) {
like( $path, $regex, "$path matches $zglob" );
}
foreach my $path (qw(foo.txt foo/bar/baz.tx)) {
unlike( $path, $regex, "$path does not match $zglob" );
}
}
1;
|