Skip to content

Commit

Permalink
Merge pull request #801 from patrickbkr/more-io-path-parent-tests
Browse files Browse the repository at this point in the history
Add more IO::Path::parent tests
  • Loading branch information
patrickbkr committed Feb 19, 2022
2 parents d98a00b + 384129f commit da4705a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
21 changes: 14 additions & 7 deletions S32-io/io-path-cygwin.t
Expand Up @@ -65,13 +65,20 @@ is $relpath.absolute("/foo").IO.relative("\\foo"), "foo/bar", "absolute inverts
#?rakudo 1 todo 'resolve NYI, needs nqp::readlink'
is $abspath.relative.IO.absolute.IO.resolve, "\\foo\\bar", "absolute inverts relative with resolve";

is IO::Path::Cygwin.new("foo/bar").parent, "foo", "parent of 'foo/bar' is 'foo'";
is IO::Path::Cygwin.new("foo").parent, ".", "parent of 'foo' is '.'";
is IO::Path::Cygwin.new(".").parent, "..", "parent of '.' is '..'";
is IO::Path::Cygwin.new("..").parent, "../..", "parent of '..' is '../..'";
is IO::Path::Cygwin.new("/foo").parent, "/", "parent at top level is '/'";
is IO::Path::Cygwin.new("/").parent, "/", "parent of root is '/'";
is IO::Path::Cygwin.new("\\").parent, "/", "parent of root ('\\') is '/'";
is IO::Path::Cygwin.new("foo/bar").parent, "foo", "parent of 'foo/bar' is 'foo'";
is IO::Path::Cygwin.new("foo").parent, ".", "parent of 'foo' is '.'";
is IO::Path::Cygwin.new(".").parent, "..", "parent of '.' is '..'";
is IO::Path::Cygwin.new("..").parent, "../..", "parent of '..' is '../..'";
is IO::Path::Cygwin.new("/foo").parent, "/", "parent at top level is '/'";
is IO::Path::Cygwin.new("/").parent, "/", "parent of root is '/'";
is IO::Path::Cygwin.new("\\").parent, "/", "parent of root ('\\') is '/'";
is IO::Path::Cygwin.new("../foo").parent, "..", "parent of '../foo' is '..'";
is IO::Path::Cygwin.new("foo/..").parent, "foo/../..", "parent of 'foo/..' is 'foo/../..'";

is IO::Path::Cygwin.new("/foo/bar").parent, "/foo", "parent of '/foo/bar' is '/foo'";
is IO::Path::Cygwin.new("/foo").parent, "/", "parent of '/foo' is '/'";
is IO::Path::Cygwin.new("/foo/..").parent, "/foo/../..", "parent of '/foo/..' is '/foo/../..'";
is IO::Path::Cygwin.new("/foo/../bar").parent, "/foo/..", "parent of '/foo/../bar' is '/foo/..'";

is IO::Path::Cygwin.new("/").child('foo'), "/foo", "append to root";
is IO::Path::Cygwin.new(".").child('foo'), "foo", "append to cwd";
Expand Down
19 changes: 13 additions & 6 deletions S32-io/io-path-unix.t
Expand Up @@ -50,12 +50,19 @@ is $relpath.absolute("/foo").IO.relative("/foo"),
#?rakudo 1 todo 'resolve NYI, needs nqp::readlink'
is $abspath.relative.IO.absolute.IO.resolve, "/foo/bar", "absolute inverts relative with resolve";

is IO::Path::Unix.new("foo/bar").parent, "foo", "parent of 'foo/bar' is 'foo'";
is IO::Path::Unix.new("foo").parent, ".", "parent of 'foo' is '.'";
is IO::Path::Unix.new(".").parent, "..", "parent of '.' is '..'";
is IO::Path::Unix.new("..").parent, "../..", "parent of '..' is '../..'";
is IO::Path::Unix.new("/foo").parent, "/", "parent at top level is '/'";
is IO::Path::Unix.new("/").parent, "/", "parent of root is '/'";
is IO::Path::Unix.new("foo/bar").parent, "foo", "parent of 'foo/bar' is 'foo'";
is IO::Path::Unix.new("foo").parent, ".", "parent of 'foo' is '.'";
is IO::Path::Unix.new(".").parent, "..", "parent of '.' is '..'";
is IO::Path::Unix.new("..").parent, "../..", "parent of '..' is '../..'";
is IO::Path::Unix.new("/foo").parent, "/", "parent at top level is '/'";
is IO::Path::Unix.new("/").parent, "/", "parent of root is '/'";
is IO::Path::Unix.new("../foo").parent, "..", "parent of '../foo' is '..'";
is IO::Path::Unix.new("foo/..").parent, "foo/../..", "parent of 'foo/..' is 'foo/../..'";

is IO::Path::Unix.new("/foo/bar").parent, "/foo", "parent of '/foo/bar' is '/foo'";
is IO::Path::Unix.new("/foo").parent, "/", "parent of '/foo' is '/'";
is IO::Path::Unix.new("/foo/..").parent, "/foo/../..", "parent of '/foo/..' is '/foo/../..'";
is IO::Path::Unix.new("/foo/../bar").parent, "/foo/..", "parent of '/foo/../bar' is '/foo/..'";

is IO::Path::Unix.new("/").child('foo'), "/foo", "append to root";
is IO::Path::Unix.new(".").child('foo'), "foo", "append to cwd";
Expand Down
19 changes: 13 additions & 6 deletions S32-io/io-path-win.t
Expand Up @@ -65,12 +65,19 @@ is $relpath.absolute("/foo").IO.relative("\\foo"), "foo\\bar","absolute inverts
#?rakudo 1 todo 'resolve NYI, needs nqp::readlink'
is $abspath.relative.IO.absolute.IO.resolve, "\\foo\\bar", "absolute inverts relative with resolve";

is IO::Path::Win32.new("foo/bar").parent, "foo", "parent of 'foo/bar' is 'foo'";
is IO::Path::Win32.new("foo").parent, ".", "parent of 'foo' is '.'";
is IO::Path::Win32.new(".").parent, "..", "parent of '.' is '..'";
is IO::Path::Win32.new("..").parent, "..\\..", "parent of '..' is '../..'";
is IO::Path::Win32.new("\\foo").parent, "\\", "parent at top level is '/'";
is IO::Path::Win32.new("\\").parent, "\\", "parent of root is '/'";
is IO::Path::Win32.new("foo/bar").parent, "foo", "parent of 'foo/bar' is 'foo'";
is IO::Path::Win32.new("foo").parent, ".", "parent of 'foo' is '.'";
is IO::Path::Win32.new(".").parent, "..", "parent of '.' is '..'";
is IO::Path::Win32.new("..").parent, "..\\..", "parent of '..' is '../..'";
is IO::Path::Win32.new("\\foo").parent, "\\", "parent at top level is '/'";
is IO::Path::Win32.new("\\").parent, "\\", "parent of root is '/'";
is IO::Path::Win32.new("..\\foo").parent, "..", "parent of '../foo' is '..'";
is IO::Path::Win32.new("foo\\..").parent, "foo\\..\\..", "parent of 'foo/..' is 'foo/../..'";

is IO::Path::Win32.new("A:\\foo\\bar").parent, "A:\\foo", "parent of '/foo/bar' is '/foo'";
is IO::Path::Win32.new("A:\\foo").parent, "A:\\", "parent of '/foo' is '/'";
is IO::Path::Win32.new("A:\\foo\\..").parent, "A:\\foo\\..\\..", "parent of '/foo/..' is '/foo/../..'";
is IO::Path::Win32.new("A:\\foo\\..\\bar").parent, "A:\\foo\\..", "parent of '/foo/../bar' is '/foo/..'";

is IO::Path::Win32.new("\\").child('foo'), "\\foo", "append to root";
is IO::Path::Win32.new(".").child('foo'), "foo", "append to cwd";
Expand Down

0 comments on commit da4705a

Please sign in to comment.