This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
update Time-HiRes to CPAN version 1.9724
[perl5.git] / cpan / 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
11use Test::More 0.82 tests => 6;
12use t::Watchdog;
13
14my @one = Time::HiRes::gettimeofday();
15note 'gettimeofday returned ', 0+@one, ' args';
16ok @one == 2;
17ok $one[0] > 850_000_000 or note "@one too small";
18
19sleep 1;
20
21my @two = Time::HiRes::gettimeofday();
22ok $two[0] > $one[0] || ($two[0] == $one[0] && $two[1] > $one[1])
23 or note "@two is not greater than @one";
24
25my $f = Time::HiRes::time();
26ok $f > 850_000_000 or note "$f too small";
27ok $f - $two[0] < 2 or note "$f - $two[0] >= 2";
28
29my $r = [Time::HiRes::gettimeofday()];
30my $g = Time::HiRes::tv_interval $r;
31ok $g < 2 or note $g;
32
331;