summaryrefslogtreecommitdiff
path: root/t/normalize.t
blob: 9dd8364e4da697f3c418bff8125fa1caf6e45ab4 (plain)
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
use 5.008001;
use strict;
use warnings;
use Test::More 0.96;

use lib 't/lib';
use TestUtils qw/exception/;

use Path::Tiny;

my @cases = (
#<<<
    [ '.'   => '.'  ],
    [ './'  => '.'  ],
    [ '/'   => '/'  ],
    [ '/.'  => '/'  ],
    [ '..'  => '..' ],
    [ '/..'  => '/' ],
    [ '../'  => '..' ],
    [ '../..'  => '../..' ],
    [ '/./'  => '/' ],
    [ '/foo/'  => '/foo' ],
    [ 'foo/'  => 'foo' ],
    [ './foo'  => 'foo' ],
    [ 'foo/.'  => 'foo' ],
#>>>
);

for my $c (@cases) {
    my ( $in, $out ) = @$c;
    my $label = defined($in) ? $in : "undef";
    $label = "empty" unless length $label;
    is( path($in)->stringify, $out, sprintf( "%5s -> %-5s", $label, $out ) );
}

done_testing;
#
# This file is part of Path-Tiny
#
# This software is Copyright (c) 2014 by David Golden.
#
# This is free software, licensed under:
#
#   The Apache License, Version 2.0, January 2004
#