Fetching contributors…
Cannot retrieve contributors at this time
79 lines (63 sloc) 2.36 KB
use v6;
use Test;
plan 22;
# L<S32::IO/IO::Path>
my $path = '/foo/bar.txt'.IO;
isa-ok $path, IO::Path, "Str.IO returns an IO::Path";
is'/foo/bar.txt'), $path,
"Constructor works without named arguments";
"Can use either :basename or positional argument";
is</foo>, :basename<bar.txt>).cleanup, $path.cleanup,
"Can construct path from :dirname and :basename";
# This assumes slash-separated paths, so it will break on, say, VMS
is $path.volume, '', 'volume';
is $path.dirname, '/foo', 'dirname';
is $path.basename, 'bar.txt', 'basename';
is $path.parent, '/foo', 'parent';
is $path.parent.parent, '/', 'parent of parent';
is $, True, 'is-absolute';
is $, False, 'is-relative';
isa-ok $path.path, Str, 'IO::Path.path returns Str';
isa-ok $path.IO, IO::Path, 'IO::Path.IO returns IO::Path';
# Try to guess from context that the correct backend is loaded:
#?DOES 2
if $* eq any <win32 mswin32 os2 dos symbian netware> {
ok "c:\\", "Win32ish OS loaded (volume)";
is "/".IO.cleanup, "\\", "Win32ish OS loaded (back slash)"
elsif $* eq 'cygwin' {
ok "c:\\", "Cygwin OS loaded (volume)";
is "/".IO.cleanup, "/", "Cygwin OS loaded (forward slash)"
else { # assume POSIX
nok "c:\\", "POSIX OS loaded (no volume)";
is "/".IO.cleanup, "/", "POSIX OS loaded (forward slash)"
# RT #126935
my $perl = "/foo|\\bar".IO.perl;
is $perl.EVAL.perl, $perl, "does $perl roundtrip?";
my $nul = "/foo\0bar".IO.perl;
is $nul.EVAL.perl, $nul, "does $nul roundtrip?";
# RT #127989
throws-like { 'foo', 'bar' }, X::Multi::NoMatch,
' with wrong args must not claim it only takes named ones';
# RT #128097
is'-')).path.gist, '"-".IO', '"-" as the path of an IO::Handle gists correctly';
is '-'.IO.gist, '"-".IO', '"-".IO gists correctly';
# RT #130889
my $file = ("S32-io-path-RT-130889-test" ~ rand);
LEAVE $file.IO.unlink;
my $p1 = $file.IO;
is-deeply $p1.e, False, 'temporary test file does not exist';
my $p2 = $file.IO.spurt: "test";
is-deeply $p1.e, True,
'.e detects change on filesystem and returns True now';