Scaffold/Log_TEST.pm

filter: Statementstmt 100% 15 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 21 / 21 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Scaffold/Exception/Container.pm ↑ Summary Scaffold/Storable_TEST.pm »
1 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Class::Scaffold::Log_TEST;
6 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 $Class::Scaffold::Log_TEST::VERSION = '1.102280';
8 }
9 # ABSTRACT: Companion test class for the log class
10 1 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use parent 'Class::Scaffold::Test';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 use constant PLAN => 2;
13  
14 sub run {
15 my $self = shift;
16 $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 my $log = $self->make_real_object->instance;
21 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 $log->delegate->test_mode(0);
26 $log->info('Hello');
27 Class::Scaffold::Log->debug('a debug message that should not appear');
28 $log->max_level(2);
29 Class::Scaffold::Log->debug('a debug message that should appear');
30 $log->set_pid;
31 Class::Scaffold::Log->info('a message with %s and %s', qw/pid timestamp/);
32 $log->clear_timestamp;
33 $log->info('a message with pid but without timestamp');
34 Class::Scaffold::Log->instance->clear_pid;
35 Class::Scaffold::Log->instance->info('a message without pid or timestamp');
36 (my $out = $log->output) =~ s/^\d{8}\.\d{6}\.\d\d/[timestamp]/mg;
37 my $pid = sprintf '%08d', $$;
38 is($out, <<EXPECT, 'log output');
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__
« Scaffold/Exception/Container.pm ↑ Summary Scaffold/Storable_TEST.pm »