File: Zglob.pm

package info (click to toggle)
libcode-tidyall-perl 0.78~ds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,048 kB
  • sloc: perl: 5,061; lisp: 47; sh: 4; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 1,029 bytes parent folder | download | duplicates (3)
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;