"Fossies" - the Fresh Open Source Software Archive

Member "Time-HiRes-1.9764/t/gettimeofday.t" (10 Aug 2020, 835 Bytes) of package /linux/privat/Time-HiRes-1.9764.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    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;