/
01_unix.t
65 lines (55 loc) · 2.45 KB
/
01_unix.t
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
use lib 'lib';
use Test;
use File::Spec;
plan 27;
if $*OS ~~ any(<MacOS MSWin32 os2 VMS epoc NetWare symbian dos cygwin>) {
skip_rest 'this is not Unix\'ish'
}
else {
my %canonpath = (
'///../../..//./././a//b/.././c/././' => '/a/b/../c',
'' => '',
'a/../../b/c' => 'a/../../b/c',
'/.' => '/',
'/./' => '/',
'/a/./' => '/a',
'/a/.' => '/a',
'/../../' => '/',
'/../..' => '/',
'/..' => '/',
);
for %canonpath.kv -> $get, $want {
is File::Spec.canonpath( $get ), $want, "canonpath: '$get' -> '$want'";
}
is File::Spec.catdir( ), '', "catdir: no arg -> ''";
is File::Spec.catdir( '' ), '/', "catdir: '' -> '/'";
is File::Spec.catdir( '/' ), '/', "catdir: '/' -> '/'";
is File::Spec.catdir( '','d1','d2','d3','' ), '/d1/d2/d3', "catdir: ('','d1','d2','d3','') -> '/d1/d2/d3'";
is File::Spec.catdir( 'd1','d2','d3','' ), 'd1/d2/d3', "catdir: ('d1','d2','d3','') -> 'd1/d2/d3'";
is File::Spec.catdir( '','d1','d2','d3' ), '/d1/d2/d3', "catdir: ('','d1','d2','d3') -> '/d1/d2/d3'";
is File::Spec.catdir( 'd1','d2','d3' ), 'd1/d2/d3', "catdir: ('d1','d2','d3') -> 'd1/d2/d3'";
is File::Spec.catdir( '/','d2/d3' ), '/d2/d3', "catdir: ('/','d2/d3') -> '/d2/d3'";
is File::Spec.catfile('a','b','c'), 'a/b/c', "catfile: ('a','b','c') -> 'a/b/c'";
is File::Spec.catfile('a','b','./c'), 'a/b/c', "catfile: ('a','b','./c') -> 'a/b/c'";
is File::Spec.catfile('./a','b','c'), 'a/b/c', "catfile: ('./a','b','c') -> 'a/b/c'";
is File::Spec.catfile('c'), 'c', "catfile: 'c' -> 'c'";
is File::Spec.catfile('./c'), 'c', "catfile: './c' -> 'c'";
is File::Spec.curdir, '.', 'curdir is "."';
is File::Spec.devnull, '/dev/null', 'devnull is /dev/null';
is File::Spec.rootdir, '/', 'rootdir is "/"';
#tmpdir
is File::Spec.updir, '..', 'updir is ".."';
my @get = <. .. .git blib lib t>;
my @want = <.git blib lib t>;
is_deeply File::Spec.no_upwards( @get ), @want, 'no_upwards: (. .. .git blib lib t) -> (.git blib lib t)';
#case_tolerant
#file_name_is_absolute
#path
#join
#splitpath
#splitdir
#catpath
#abs2rel
#rel2ab
}
done;