### ----------------------------------------------------
### -- path-utils
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: t/01-basic.rakutest
### ----------------------------------------------------
use Test;
use path-utils;

plan 56;

my str $file = $?FILE;
my str $dir  = $file.IO.parent.absolute;

is-deeply path-exists($file), 1, "does $file exist";
is-deeply path-exists($dir),  1, "does $dir exist";
is-deeply path-exists("foo"), 0, "does foo NOT exist";

is-deeply path-is-regular-file($file),  1, "is $file a regular file";
is-deeply path-is-regular-file($dir),   0, "is $dir NOT a regular file";
is-deeply path-is-directory($dir),      1, "is $dir a directory";
is-deeply path-is-directory($file),     0, "is $file NOT a directory";
is-deeply path-is-device($file),        0, "is $file NOT a device";
is-deeply path-is-device($dir),         0, "is $dir NOT a device";
is-deeply path-is-symbolic-link($file), 0, "is $file NOT a symlink";
is-deeply path-is-symbolic-link($dir),  0, "is $dir NOT a symlink";

is-deeply path-is-text(  $file), 1, "does $file contain text";
is-deeply path-is-moarvm($file), 0, "is $file NOT a MoarVM file";
is-deeply path-is-pdf($file),    0, "is $file NOT a PDF file";

isa-ok path-created($file),       Num, "is $file created a Num";
isa-ok path-accessed($file),      Num, "is $file accessed a Num";
isa-ok path-modified($file),      Num, "is $file accessed a Num";
isa-ok path-meta-modified($file), Num, "is $file accessed a Num";

isa-ok path-uid($file), Int, "is $file uid an Int";
isa-ok path-gid($file), Int, "is $file gid an Int";

isa-ok path-inode($file), Int, "is $file inode an Int";
isa-ok path-inode($dir),  Int, "is $dir inode an Int";
isa-ok path-device-number($file), Int, "is $file device-number an Int";
isa-ok path-device-number($dir),  Int, "is $dir device-number an Int";

isa-ok path-hard-links($file), Int, "is $file hard-links an Int";
isa-ok path-hard-links($dir),  Int, "is $dir hard-links an Int";

isa-ok path-inode($file),     Int, "is $file inode an Int";
isa-ok path-inode($dir),      Int, "is $dir inode an Int";
isa-ok path-block-size($file), Int, "is $file block-size an Int";
isa-ok path-block-size($dir),  Int, "is $dir block-size an Int";
isa-ok path-blocks($file),    Int, "is $file blocks an Int";
isa-ok path-blocks($dir),     Int, "is $dir blocks an Int";

isa-ok path-filesize($file), Int, "is $file filesize an Int";
isa-ok path-filesize($dir),  Int, "is $dir filesize an Int";
nok path-is-empty($file), "is $file not empty";

if Rakudo::Internals.IS-WIN {
    isa-ok path-mode($file),     Int , "is $file mode an Int";
    isa-ok path-mode($dir),      Int , "is $dir mode an Int";
    isa-ok path-filesize($file), Int, "is $file filesize ok";

    pass "Windows mode checks unreliable" for ^18;
}
else {
    is-deeply path-mode($file),    33188, "is $file mode ok";
    is-deeply path-mode($dir),     16877, "is $dir mode ok";
    is-deeply path-filesize($file), 4009, "is $file filesize ok";

     ok path-is-readable($file),   "is $file readable by user";
     ok path-is-writable($file),   "is $file writable by user";
    nok path-is-executable($file), "is $file executable by user";

     ok path-is-group-readable($file),   "is $file group readable";
    nok path-is-group-writable($file),   "is $file group writable";
    nok path-is-group-executable($file), "is $file group executable";

     ok path-is-world-readable($file),   "is $file world readable";
    nok path-is-world-writable($file),   "is $file world writable";
    nok path-is-world-executable($file), "is $file world executable";

     ok path-is-readable($dir),   "is $dir readable by user";
     ok path-is-writable($dir),   "is $dir writable by user";
     ok path-is-executable($dir), "is $dir executable by user";

     ok path-is-group-readable($dir),   "is $dir group readable";
    nok path-is-group-writable($dir),   "is $dir group writable";
     ok path-is-group-executable($dir), "is $dir group executable";

     ok path-is-world-readable($dir),   "is $dir world readable";
    nok path-is-world-writable($dir),   "is $dir world writable";
     ok path-is-world-executable($dir), "is $dir world executable";
}

# vim: expandtab shiftwidth=4


