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
1 use strict;
2
3 BEGIN {
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
11 use Test::More tests => 6;
12 BEGIN { push @INC, '.' }
13 use t::Watchdog;
14
15 my @one = Time::HiRes::gettimeofday();
16 printf("# gettimeofday returned %d args\n", 0+@one);
17 ok @one == 2;
18 ok $one[0] > 850_000_000 or print("# @one too small\n");
19
20 sleep 1;
21
22 my @two = Time::HiRes::gettimeofday();
23 ok $two[0] > $one[0] || ($two[0] == $one[0] && $two[1] > $one[1])
24         or print("# @two is not greater than @one\n");
25
26 my $f = Time::HiRes::time();
27 ok $f > 850_000_000 or print("# $f too small\n");
28 ok $f - $two[0] < 2 or print("# $f - $two[0] >= 2\n");
29
30 my $r = [Time::HiRes::gettimeofday()];
31 my $g = Time::HiRes::tv_interval $r;
32 ok $g < 2 or print("# $g\n");
33
34 1;