From: Jarkko Hietaniemi Date: Tue, 29 May 2001 15:15:44 +0000 (+0000) Subject: Add test for File::stat. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f7a45afb043dafc521db9513c0ecf764944fe22a;p=p5sagit%2Fp5-mst-13.2.git Add test for File::stat. p4raw-id: //depot/perl@10290 --- diff --git a/MANIFEST b/MANIFEST index e21e2d3..c2c6970 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1523,6 +1523,7 @@ t/lib/filefunc.t See if File::Spec::Functions works t/lib/filehand.t See if FileHandle works t/lib/filepath.t See if File::Path works t/lib/filespec.t See if File::Spec works +t/lib/filestat.t See if File::stat works t/lib/filter-simple.t See if Filter::Simple works t/lib/filter-util.pl See if Filter::Util::Call works t/lib/filter-util.t See if Filter::Util::Call works diff --git a/t/lib/1_compile.t b/t/lib/1_compile.t index d99641d..2670e7a 100644 --- a/t/lib/1_compile.t +++ b/t/lib/1_compile.t @@ -155,6 +155,7 @@ File::Path File::Spec File::Spec::Functions File::Temp +File::stat FileCache FileHandle Filter::Simple diff --git a/t/lib/filestat.t b/t/lib/filestat.t new file mode 100644 index 0000000..ac6d95f --- /dev/null +++ b/t/lib/filestat.t @@ -0,0 +1,70 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +BEGIN { + our $hasst; + eval { my @n = stat "TEST" }; + $hasst = 1 unless $@ && $@ =~ /unimplemented/; + unless ($hasst) { print "1..0 # Skip: no stat\n"; exit 0 } + use Config; + $hasst = 0 unless $Config{'i_sysstat'} eq 'define'; + unless ($hasst) { print "1..0 # Skip: no sys/stat.h\n"; exit 0 } +} + +BEGIN { + our @stat = stat "TEST"; # This is the function stat. + unless (@stat) { print "1..0 # Skip: no file TEST\n"; exit 0 } +} + +print "1..14\n"; + +use File::stat; + +print "ok 1\n"; + +my $stat = stat "TEST"; # This is the OO stat. + +print "not " unless $stat->dev == $stat[ 0]; +print "ok 2\n"; + +print "not " unless $stat->ino == $stat[ 1]; +print "ok 3\n"; + +print "not " unless $stat->mode == $stat[ 2]; +print "ok 4\n"; + +print "not " unless $stat->nlink == $stat[ 3]; +print "ok 5\n"; + +print "not " unless $stat->uid == $stat[ 4]; +print "ok 6\n"; + +print "not " unless $stat->gid == $stat[ 5]; +print "ok 7\n"; + +print "not " unless $stat->rdev == $stat[ 6]; +print "ok 8\n"; + +print "not " unless $stat->size == $stat[ 7]; +print "ok 9\n"; + +print "not " unless $stat->atime == $stat[ 8]; +print "ok 10\n"; + +print "not " unless $stat->mtime == $stat[ 9]; +print "ok 11\n"; + +print "not " unless $stat->ctime == $stat[10]; +print "ok 12\n"; + +print "not " unless $stat->blksize == $stat[11]; +print "ok 13\n"; + +print "not " unless $stat->blocks == $stat[12]; +print "ok 14\n"; + +# Testing pretty much anything else is unportable.