line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Time; |
2
|
2
|
|
|
2
|
|
97288
|
use strict; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
42
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
34
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
7
|
use Test::More; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
21
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.092'; |
8
|
|
|
|
|
|
|
our $time = CORE::time(); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $pkg = __PACKAGE__; |
11
|
|
|
|
|
|
|
my $in_effect = 1; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub in_effect { |
14
|
15
|
|
|
15
|
0
|
32
|
$in_effect; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub __time () { |
18
|
5
|
100
|
|
5
|
|
65
|
if (in_effect) { |
19
|
4
|
|
|
|
|
15
|
$time; |
20
|
|
|
|
|
|
|
} else { |
21
|
1
|
|
|
|
|
4
|
CORE::time(); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub __sleep (;$) { |
26
|
1
|
50
|
|
1
|
|
3
|
if (in_effect) { |
27
|
1
|
|
50
|
|
|
3
|
my $sleep = shift || 1; |
28
|
1
|
|
|
|
|
2
|
$time += $sleep; |
29
|
1
|
|
|
|
|
4
|
note "sleep $sleep"; |
30
|
|
|
|
|
|
|
} else { |
31
|
0
|
|
|
|
|
0
|
CORE::sleep(shift); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub __localtime (;$) { |
36
|
9
|
|
|
9
|
|
921
|
my $arg = shift; |
37
|
9
|
100
|
|
|
|
11
|
if (in_effect) { |
38
|
8
|
|
66
|
|
|
15
|
$arg ||= $time; |
39
|
|
|
|
|
|
|
} |
40
|
9
|
100
|
|
|
|
192
|
return defined $arg ? CORE::localtime($arg) : CORE::localtime(); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub import { |
44
|
3
|
|
|
3
|
|
17
|
my ($class, %opts) = @_; |
45
|
3
|
|
|
|
|
3
|
$in_effect = 1; |
46
|
3
|
100
|
|
|
|
9
|
$time = $opts{time} if defined $opts{time}; |
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
8
|
*CORE::GLOBAL::time = \&__time; |
49
|
3
|
|
|
|
|
4
|
*CORE::GLOBAL::sleep = \&__sleep; |
50
|
3
|
|
|
|
|
1013
|
*CORE::GLOBAL::localtime = \&__localtime; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub unimport { |
54
|
1
|
|
|
1
|
|
8
|
$in_effect = 0; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
__END__ |