File: 03-Parent-sanity.t

package info (click to toggle)
libfindbin-libs-perl 4.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 704 kB
  • sloc: perl: 1,323; sh: 38; makefile: 7
file content (97 lines) | stat: -rw-r--r-- 1,706 bytes parent folder | download
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package Testophile;

use v5.8;
use lib;

use Test::More;

my $madness = 'FindBin::Parents';
my @importz
= qw
(
    dir_paths
    clear_parent_cache
);

my $path    = '/foo/bar/bletch';
my $expect =
[
    qw
    (
        /foo/bar/bletch
        /foo/bar
        /foo
        /
    )
];

note "INC is:\n" => explain \@INC;

use_ok $madness => $_
for @importz;

ok __PACKAGE__->can( $_ ), "$madness exports $_"
for @importz;

SKIP:
{
    if( my @found = clear_parent_cache() )
    {
        fail 'clear_cached_parents returns data:';
        diag explain \@found;
    }
    else
    {
        pass 'clear_cached_parents returns empty.';
    }

    if( my @found = dir_paths( $path ) )
    {
        is_deeply \@found, $expect, "Parents of '/foo/bar/bletch'";
    }
    else
    {
        BAIL_OUT "parent_dirs returns empty list for /foo/bar/bletch";
    }

    if( my $found = dir_paths( $path ) )
    {
        is_deeply $found, $expect, "Parents of '/foo/bar/bletch'";
    }
    else
    {
        BAIL_OUT "parent_dirs returns empty scalar for /foo/bar/bletch";
    }

    shift @$expect;

    if( my @found = dir_paths( $path, '' ) )
    {
        is_deeply \@found, $expect, "Parents of '/foo/bar/bletch', ''";
    }
    else
    {
        fail 'Non-matching paths.';
        diag
          , "Expect:\n", explain \@expect
          , "Found:\n" , explain \@found
          ;
    }

    if( my $found = dir_paths( $path, '' ) )
    {
        is_deeply $found, $expect, "Parents of '/foo/bar/bletch', ''";
    }
    else
    {
        fail "Non-matching paths.";
        diag
          , "Expect:\n", explain \@expect
          , "Found:\n" , explain \@found
          ;
    }
}

done_testing;

__END__