line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Time; |
2
|
2
|
|
|
2
|
|
121181
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
64
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use Test::More; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
8
|
|
|
|
|
|
|
our $time = CORE::time(); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $pkg = __PACKAGE__; |
11
|
|
|
|
|
|
|
my $in_effect = 1; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub in_effect { |
14
|
4
|
|
|
4
|
0
|
22
|
$in_effect; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import { |
18
|
2
|
|
|
2
|
|
21
|
my ($class, %opts) = @_; |
19
|
2
|
100
|
|
|
|
11
|
$time = $opts{time} if defined $opts{time}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
*CORE::GLOBAL::time = sub() { |
22
|
3
|
50
|
|
3
|
|
75
|
if (in_effect) { |
23
|
3
|
|
|
|
|
24
|
$time; |
24
|
|
|
|
|
|
|
} else { |
25
|
0
|
|
|
|
|
0
|
CORE::time(); |
26
|
|
|
|
|
|
|
} |
27
|
2
|
|
|
|
|
12
|
}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
*CORE::GLOBAL::sleep = sub(;$) { |
30
|
1
|
50
|
|
1
|
|
6
|
if (in_effect) { |
31
|
1
|
|
50
|
|
|
8
|
my $sleep = shift || 1; |
32
|
1
|
|
|
|
|
5
|
$time += $sleep; |
33
|
1
|
|
|
|
|
8
|
note "sleep $sleep"; |
34
|
|
|
|
|
|
|
} else { |
35
|
0
|
|
|
|
|
|
CORE::sleep(shift); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
2
|
|
|
|
|
1115
|
}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub unimport { |
41
|
0
|
|
|
0
|
|
|
$in_effect = 0; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |