Re: [ID 20010529.003] find2perl and File::Find doesn't emulate find when path is...
[p5sagit/p5-mst-13.2.git] / t / lib / filestat.t
CommitLineData
f7a45afb 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
8BEGIN {
9 our $hasst;
10 eval { my @n = stat "TEST" };
11 $hasst = 1 unless $@ && $@ =~ /unimplemented/;
12 unless ($hasst) { print "1..0 # Skip: no stat\n"; exit 0 }
13 use Config;
14 $hasst = 0 unless $Config{'i_sysstat'} eq 'define';
15 unless ($hasst) { print "1..0 # Skip: no sys/stat.h\n"; exit 0 }
16}
17
18BEGIN {
19 our @stat = stat "TEST"; # This is the function stat.
20 unless (@stat) { print "1..0 # Skip: no file TEST\n"; exit 0 }
21}
22
23print "1..14\n";
24
25use File::stat;
26
27print "ok 1\n";
28
29my $stat = stat "TEST"; # This is the OO stat.
30
31print "not " unless $stat->dev == $stat[ 0];
32print "ok 2\n";
33
34print "not " unless $stat->ino == $stat[ 1];
35print "ok 3\n";
36
37print "not " unless $stat->mode == $stat[ 2];
38print "ok 4\n";
39
40print "not " unless $stat->nlink == $stat[ 3];
41print "ok 5\n";
42
43print "not " unless $stat->uid == $stat[ 4];
44print "ok 6\n";
45
46print "not " unless $stat->gid == $stat[ 5];
47print "ok 7\n";
48
49print "not " unless $stat->rdev == $stat[ 6];
50print "ok 8\n";
51
52print "not " unless $stat->size == $stat[ 7];
53print "ok 9\n";
54
55print "not " unless $stat->atime == $stat[ 8];
56print "ok 10\n";
57
58print "not " unless $stat->mtime == $stat[ 9];
59print "ok 11\n";
60
61print "not " unless $stat->ctime == $stat[10];
62print "ok 12\n";
63
64print "not " unless $stat->blksize == $stat[11];
65print "ok 13\n";
66
67print "not " unless $stat->blocks == $stat[12];
68print "ok 14\n";
69
70# Testing pretty much anything else is unportable.