File: 01_base.t

package info (click to toggle)
libtest-time-perl 0.092-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 336 kB
  • sloc: perl: 4,540; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use strict;
use warnings;
use Test::More;
use Test::Time time => 1;

is time(), 1, 'initial time taken from use line';

CORE::sleep(1);
is time(), 1, 'apparent time unchanged after changes in real time';

sleep 1;
is time(), 2, 'apparent time updated after sleep';

is scalar( localtime() ), scalar(localtime(2)),
    "localtime() in scalar context correct";

my @localtime = localtime();
is_deeply \@localtime, [ CORE::localtime(2) ],
    "localtime() in list context correct";

is scalar( localtime(100) ), scalar(localtime(100)),
    "localtime() in scalar context with argument correct";

@localtime = localtime(100);
is_deeply \@localtime, [ CORE::localtime(100) ],
    "localtime() in list context with argument correct";

my $overriden = scalar( localtime() );
Test::Time->unimport();

isnt time(), 2, "removed overwritten time()";
isnt scalar( localtime() ), $overriden, "removed overwritten localtime()";

Test::Time->import();

is time(), 2, "re-enabled overwritten time()";
is scalar( localtime() ), $overriden, "re-enabled overwritten localtime()";

done_testing;