This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] resurrect t/op/magic.t on VMS
[perl5.git] / lib / File / stat.t
CommitLineData
f7a45afb
JH
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
4f0c37ba
IZ
34# On OS/2 (fake) ino is not constant, it is incremented each time
35print "# ino=>@{[$stat->ino]}, 1=>$stat[ 1]\nnot "
36 unless $stat->ino == $stat[ 1] or $^O eq 'os2';
f7a45afb
JH
37print "ok 3\n";
38
39print "not " unless $stat->mode == $stat[ 2];
40print "ok 4\n";
41
42print "not " unless $stat->nlink == $stat[ 3];
43print "ok 5\n";
44
45print "not " unless $stat->uid == $stat[ 4];
46print "ok 6\n";
47
48print "not " unless $stat->gid == $stat[ 5];
49print "ok 7\n";
50
51print "not " unless $stat->rdev == $stat[ 6];
52print "ok 8\n";
53
54print "not " unless $stat->size == $stat[ 7];
55print "ok 9\n";
56
57print "not " unless $stat->atime == $stat[ 8];
58print "ok 10\n";
59
60print "not " unless $stat->mtime == $stat[ 9];
61print "ok 11\n";
62
63print "not " unless $stat->ctime == $stat[10];
64print "ok 12\n";
65
66print "not " unless $stat->blksize == $stat[11];
67print "ok 13\n";
68
69print "not " unless $stat->blocks == $stat[12];
70print "ok 14\n";
71
72# Testing pretty much anything else is unportable.