This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix dist/Time-HiRes/t/*.t that assumed '.' in @INC
[perl5.git] / dist / Time-HiRes / t / gettimeofday.t
CommitLineData
90e44bf6
Z
1use strict;
2
3BEGIN {
4 require Time::HiRes;
5 unless(&Time::HiRes::d_gettimeofday) {
6 require Test::More;
7 Test::More::plan(skip_all => "no gettimeofday()");
8 }
9}
10
c4a535af 11use Test::More tests => 6;
465db51d 12BEGIN { push @INC, '.' }
90e44bf6
Z
13use t::Watchdog;
14
15my @one = Time::HiRes::gettimeofday();
c4a535af 16printf("# gettimeofday returned %d args\n", 0+@one);
90e44bf6 17ok @one == 2;
c4a535af 18ok $one[0] > 850_000_000 or print("# @one too small\n");
90e44bf6
Z
19
20sleep 1;
21
22my @two = Time::HiRes::gettimeofday();
23ok $two[0] > $one[0] || ($two[0] == $one[0] && $two[1] > $one[1])
c4a535af 24 or print("# @two is not greater than @one\n");
90e44bf6
Z
25
26my $f = Time::HiRes::time();
c4a535af
SH
27ok $f > 850_000_000 or print("# $f too small\n");
28ok $f - $two[0] < 2 or print("# $f - $two[0] >= 2\n");
90e44bf6
Z
29
30my $r = [Time::HiRes::gettimeofday()];
31my $g = Time::HiRes::tv_interval $r;
c4a535af 32ok $g < 2 or print("# $g\n");
90e44bf6
Z
33
341;