Debian Codegraph @

t/07_is_in_dir.t

raw symbols SCIP
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use File::Basename;
7 use File::Spec;
8 use Test::More;
9 use Test::CheckManifest;
10
11 use Cwd;
12
13 my $sub = Test::CheckManifest->can('_is_in_dir');
14 ok $sub;
15
16 my $dir = Cwd::realpath( dirname __FILE__ );
17 $dir =~ s{.t\z}{};
18 my $t_dir = File::Spec->catdir( $dir, 't' );
19 my $abs_t_file = File::Spec->rel2abs( __FILE__ );
20
21 my @tests = (
22 [ '/t/test.txt', '/t', 1 ],
23 [ '/t/sub/test.txt', '/t', 1 ],
24 [ '/t/test.txt', '/t2', undef ],
25 [ '', '/t2', undef ],
26 [ '/t/test.txt', '', undef ],
27 [ undef, '', undef ],
28 [ undef, '/t', undef ],
29 [ undef, undef, undef ],
30 [ '/t/test.txt', undef, undef ],
31 [ '', undef, undef ],
32 [ '/t/sub/', '/t', 1 ],
33 [ '/t/sub/test', '/t/sub/', 1 ],
34 [ '/t/test', '/t/sub/', undef ],
35 [ __FILE__, dirname( __FILE__ ), 1 ],
36 [ $abs_t_file, $t_dir, 1 ],
37 );
38
39 for my $test ( @tests ) {
40 my ($file, $excludes, $expected) = @{$test};
41 my $result = $sub->( $file, [$excludes] );
42
43 is $result, $expected, sprintf "%s -> %s",
44 ( defined $file ? $file : '<undef>' ),
45 ( defined $excludes ? $excludes : '<undef>' );
46 }
47
48 done_testing();