line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
4102
|
use 5.008; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
62
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
73
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Class::Scaffold::Log_TEST; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
16
|
$Class::Scaffold::Log_TEST::VERSION = '1.102280'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Companion test class for the log class |
10
|
1
|
|
|
1
|
|
7
|
use Test::More; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
11
|
1
|
|
|
1
|
|
345
|
use parent 'Class::Scaffold::Test'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
9
|
|
12
|
1
|
|
|
1
|
|
45
|
use constant PLAN => 2; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
262
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub run { |
15
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
16
|
1
|
|
|
|
|
7
|
$self->SUPER::run(@_); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Use different ways of accessing the log: via the singleton object, or by |
19
|
|
|
|
|
|
|
# using the feature of turning a class method call into an instance call. |
20
|
1
|
|
|
|
|
298
|
my $log = $self->make_real_object->instance; |
21
|
1
|
|
|
|
|
33
|
isa_ok($log, $self->package); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# manually turn off test mode so that the log won't output to STDERR; after |
24
|
|
|
|
|
|
|
# all, that's exactly what we want to test. |
25
|
1
|
|
|
|
|
297
|
$log->delegate->test_mode(0); |
26
|
1
|
|
|
|
|
9
|
$log->info('Hello'); |
27
|
1
|
|
|
|
|
14
|
Class::Scaffold::Log->debug('a debug message that should not appear'); |
28
|
1
|
|
|
|
|
14
|
$log->max_level(2); |
29
|
1
|
|
|
|
|
13
|
Class::Scaffold::Log->debug('a debug message that should appear'); |
30
|
1
|
|
|
|
|
13
|
$log->set_pid; |
31
|
1
|
|
|
|
|
7
|
Class::Scaffold::Log->info('a message with %s and %s', qw/pid timestamp/); |
32
|
1
|
|
|
|
|
12
|
$log->clear_timestamp; |
33
|
1
|
|
|
|
|
6
|
$log->info('a message with pid but without timestamp'); |
34
|
1
|
|
|
|
|
12
|
Class::Scaffold::Log->instance->clear_pid; |
35
|
1
|
|
|
|
|
8
|
Class::Scaffold::Log->instance->info('a message without pid or timestamp'); |
36
|
1
|
|
|
|
|
13
|
(my $out = $log->output) =~ s/^\d{8}\.\d{6}\.\d\d/[timestamp]/mg; |
37
|
1
|
|
|
|
|
16
|
my $pid = sprintf '%08d', $$; |
38
|
1
|
|
|
|
|
6
|
is($out, <
|
39
|
|
|
|
|
|
|
[timestamp] Hello |
40
|
|
|
|
|
|
|
[timestamp] a debug message that should appear |
41
|
|
|
|
|
|
|
[timestamp] ($pid) a message with pid and timestamp |
42
|
|
|
|
|
|
|
($pid) a message with pid but without timestamp |
43
|
|
|
|
|
|
|
a message without pid or timestamp |
44
|
|
|
|
|
|
|
EXPECT |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |