This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade Parse::CPAN::Meta from version 1.4417 to 1.4421
[perl5.git] / dist / Time-HiRes / t / sleep.t
CommitLineData
90e44bf6
Z
1use strict;
2
3use Test::More 0.82 tests => 4;
4use t::Watchdog;
5
6BEGIN { require_ok "Time::HiRes"; }
7
8use Config;
9
10my $xdefine = '';
11if (open(XDEFINE, "xdefine")) {
12 chomp($xdefine = <XDEFINE> || "");
13 close(XDEFINE);
14}
15
16my $can_subsecond_alarm =
17 defined &Time::HiRes::gettimeofday &&
18 defined &Time::HiRes::ualarm &&
19 defined &Time::HiRes::usleep &&
20 ($Config{d_ualarm} || $xdefine =~ /-DHAS_UALARM/);
21
22eval { Time::HiRes::sleep(-1) };
23like $@, qr/::sleep\(-1\): negative time not invented yet/,
24 "negative time error";
25
26SKIP: {
27 skip "no subsecond alarm", 2 unless $can_subsecond_alarm;
28 my $f = Time::HiRes::time;
29 note "time...$f";
30 ok 1;
31
32 my $r = [Time::HiRes::gettimeofday()];
33 Time::HiRes::sleep (0.5);
34 note "sleep...", Time::HiRes::tv_interval($r);
35 ok 1;
36}
37
381;