Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 84 lines (65 sloc) 4.317 kb
7c4e0b5 @labster IO::Path::Cygwin tests
labster authored
1 use v6;
2 use Test;
3 # L<S32::IO/IO::Path>
4
d13c1a2 @lizmat Make IO::Path's test environment controlled
lizmat authored
5 plan 50;
6
7 # Make sure we have a controlled environment
8 my $*SPEC = IO::Spec::Cygwin;
9a78867 @lizmat Oops, forgot an .IO
lizmat authored
9 my $*CWD = '\\zip\\loc'.IO;
7c4e0b5 @labster IO::Path::Cygwin tests
labster authored
10
11 my $relpath = IO::Path::Cygwin.new('foo/bar' );
12 my $abspath = IO::Path::Cygwin.new('/foo/bar');
13
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
14 isa-ok $abspath, IO::Path, "Can create IO::Path::Cygwin";
01dd57f @lizmat Replace deprecated .directory by .dirname
lizmat authored
15 is $abspath.volume, "", 'volume "/foo/bar" -> ""';
16 is $abspath.dirname, "/foo", 'dirname "/foo/bar" -> "/foo"';
17 is $abspath.basename, "bar", 'basename "/foo/bar" -> "bar"';
d9596f7 @lizmat Test adaptations for new S16|S32/IO changes
lizmat authored
18
7c4e0b5 @labster IO::Path::Cygwin tests
labster authored
19
20 my $path = IO::Path::Cygwin.new('C:foo\\\\bar\\');
01dd57f @lizmat Replace deprecated .directory by .dirname
lizmat authored
21 is $path.volume, "C:", 'volume "C:foo\\\\bar\\" -> "C:"';
22 is $path.dirname, "foo", 'dirname "C:foo\\\\bar\\" -> "foo"';
d9596f7 @lizmat Test adaptations for new S16|S32/IO changes
lizmat authored
23 is $path.basename, "bar", 'basename "C:foo\\\\bar\\" -> "bar"';
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
24 isa-ok $path.path, Str, ".path returns Str of path";
d13c1a2 @lizmat Make IO::Path's test environment controlled
lizmat authored
25
26 is $path.perl.EVAL, $path, ".perl loopback";
7c4e0b5 @labster IO::Path::Cygwin tests
labster authored
27
28 my $uncpath = IO::Path::Cygwin.new("\\\\server\\share\\");
d9596f7 @lizmat Test adaptations for new S16|S32/IO changes
lizmat authored
29 is $uncpath.volume, "//server/share", 'volume "//server/share/" -> ""/server/share"';
01dd57f @lizmat Replace deprecated .directory by .dirname
lizmat authored
30 is $uncpath.dirname, "/", 'dirname "\\\\server\\share\\" -> "\\"';
d9596f7 @lizmat Test adaptations for new S16|S32/IO changes
lizmat authored
31 is $uncpath.basename, "/", 'basename "\\\\server\\share\\" -> "\\"';
bad1a99 @labster io-path no longer magically changes paths on you
labster authored
32 is $uncpath.Str, "\\\\server\\share\\", '"\\\\server\\share" restringifies to itself';
7c4e0b5 @labster IO::Path::Cygwin tests
labster authored
33
34 my $uncpath2 = IO::Path::Cygwin.new("//server/share/a");
d9596f7 @lizmat Test adaptations for new S16|S32/IO changes
lizmat authored
35 is $uncpath2.volume, "//server/share", 'volume "//server/share/a" -> ""//server/share"';
01dd57f @lizmat Replace deprecated .directory by .dirname
lizmat authored
36 is $uncpath2.dirname, "/", 'dirname "//server/share/a" -> "/"';
37 is $uncpath2.basename, "a", 'basename "//server/share/a" -> "a"';
7c4e0b5 @labster IO::Path::Cygwin tests
labster authored
38 is $uncpath2.Str, "//server/share/a", '"//server/share/a" restringifies to itself';
39
d9596f7 @lizmat Test adaptations for new S16|S32/IO changes
lizmat authored
40 is IO::Path::Cygwin.new(".").Str, ".", "current directory";
41 is IO::Path::Cygwin.new("..").Str, "..", "parent directory";
42 is IO::Path::Cygwin.new('').Str, "", "empty is empty";
7c4e0b5 @labster IO::Path::Cygwin tests
labster authored
43
44 is IO::Path::Cygwin.new("/usr/////local/./bin/.\\./perl/").cleanup, "/usr/local/bin/perl",
d9596f7 @lizmat Test adaptations for new S16|S32/IO changes
lizmat authored
45 "cleanup '/usr/////local/./bin/.\\./perl/' -> '/usr/local/bin/perl'";
46
47 ok $relpath.is-relative, "relative path is-relative";
48 nok $relpath.is-absolute, "relative path ! is-absolute";
49 nok $abspath.is-relative, "absolute path ! is-relative";
50 ok $abspath.is-absolute, "absolute path is-absolute";
51 ok $uncpath.is-absolute, "UNC path is-absolute";
52 ok $uncpath2.is-absolute, "UNC path with forward slash is-absolute";
53 ok IO::Path::Cygwin.new("\\foo").is-absolute, "path beginning with backslash is absolute";
54 ok IO::Path::Cygwin.new("A:\\").is-absolute, '"A:\\" is absolute';
55 ok IO::Path::Cygwin.new("A:b").is-relative, '"A:b" is relative';
56
57
58 is $relpath.absolute, IO::Spec::Cygwin.canonpath("$*CWD/foo/bar"), "absolute path from \$*CWD";
59 is $relpath.absolute("/usr"), "/usr/foo/bar", "absolute path specified";
60 is IO::Path::Cygwin.new("/usr/bin").relative("/usr"), "bin", "relative path specified";
d13c1a2 @lizmat Make IO::Path's test environment controlled
lizmat authored
61
62 is $relpath.absolute.IO.relative, "foo/bar", "relative inverts absolute";
63 is $relpath.absolute("/foo").IO.relative("\\foo"), "foo/bar", "absolute inverts relative";
64 #?rakudo 1 todo 'resolve NYI, needs nqp::readlink'
65 is $abspath.relative.IO.absolute.IO.resolve, "\\foo\\bar", "absolute inverts relative with resolve";
d9596f7 @lizmat Test adaptations for new S16|S32/IO changes
lizmat authored
66
67 is IO::Path::Cygwin.new("foo/bar").parent, "foo", "parent of 'foo/bar' is 'foo'";
68 is IO::Path::Cygwin.new("foo").parent, ".", "parent of 'foo' is '.'";
69 is IO::Path::Cygwin.new(".").parent, "..", "parent of '.' is '..'";
70 is IO::Path::Cygwin.new("..").parent, "../..", "parent of '..' is '../..'";
71 is IO::Path::Cygwin.new("/foo").parent, "/", "parent at top level is '/'";
72 is IO::Path::Cygwin.new("/").parent, "/", "parent of root is '/'";
73 is IO::Path::Cygwin.new("\\").parent, "/", "parent of root ('\\') is '/'";
74
75 is IO::Path::Cygwin.new("/").child('foo'), "/foo", "append to root";
76 is IO::Path::Cygwin.new(".").child('foo'), "foo", "append to cwd";
7c4e0b5 @labster IO::Path::Cygwin tests
labster authored
77
f3b450b @labster io-path.t is platform aware now, path tests for .succ and .pred
labster authored
78 my $numfile = IO::Path::Unix.new("foo/file01.txt");
d9596f7 @lizmat Test adaptations for new S16|S32/IO changes
lizmat authored
79 is $numfile.succ, "foo/file02.txt", "succ basic";
80 is $numfile.succ.succ, "foo/file03.txt", "succ x 2";
81 is $numfile.pred, "foo/file00.txt", "pred basic";
f3b450b @labster io-path.t is platform aware now, path tests for .succ and .pred
labster authored
82 is IO::Path::Unix.new("foo/()").succ, "foo/()", "succ only effects basename";
83 is IO::Path::Unix.new("foo/()").succ, "foo/()", "pred only effects basename";
Something went wrong with that request. Please try again.