Debian Codegraph @

t/02_validate_args.t

raw symbols SCIP
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use File::Spec;
6 use File::Basename;
7 use Test::More;
8 use Test::CheckManifest;
9
10 # create a directory and a file
11 my $sub = Test::CheckManifest->can('_validate_args');
12 ok $sub;
13
14 my $default = {
15 filter => [],
16 exclude => [ qw!/blib /_blib! ],
17 bool => 'or',
18 };
19
20 is_deeply [ $sub->( [], "hallo" ) ], [ $default, "hallo" ], 'Empty Arrayref';
21 is_deeply [ $sub->( { exclude => {} }, "hallo" ) ], [ $default, "hallo" ], 'exclude => {}';
22 is_deeply [ $sub->( { exclude => [] }, "hallo" ) ], [ $default, "hallo" ], 'exclude => []';
23 is_deeply [ $sub->( { exclude => 'test' }, "hallo" ) ], [ $default, "hallo" ], 'exclude => "test"';
24
25 is_deeply [ $sub->( { bool => {} }, "hallo" ) ], [ $default, "hallo" ], 'bool => {}';
26 is_deeply [ $sub->( { bool => 'or' }, "hallo" )], [ $default, "hallo" ], 'bool => "or"';
27 is_deeply [ $sub->( { bool => 'and' }, "hallo" )], [ { %$default, bool => 'and' }, "hallo" ], 'bool => "and"';
28 is_deeply [ $sub->( { bool => '1' }, "hallo" )], [ $default, "hallo" ], 'bool => "1"';
29
30 is_deeply [ $sub->( { filter => [] }, "hallo" ) ], [ $default, "hallo" ], 'filter -> arrayref';
31 is_deeply [ $sub->( { filter => {} }, "hallo" ) ], [ $default, "hallo" ], 'filter -> empty hashref';
32 is_deeply [ $sub->( { filter => 'test' }, "hallo" ) ], [ $default, "hallo" ], 'filter -> string';
33 is_deeply [ $sub->( { filter => [ 'hallo' ] }, "hallo" ) ], [ $default, "hallo" ], 'filter -> no regex';
34
35 {
36 my $error;
37 eval {
38 $sub->( { exclude => ['testing'] } );
39 1;
40 } or do {
41 $error = $@;
42 };
43
44 like $error, qr/path in excluded array must be "absolute"/, 'relative paths';
45 }
46
47 done_testing();