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