t/dflt_stdout.pl

filter: Statementstmt 75.0% 6 / 8 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 76.9% 10 / 13 CC 2 SCAR 4.7
CC
2
Cov
70%
BEGIN
2.1
BEGIN
1.3
BEGIN
1.0
CRAP 1.6
« t/multi_pack.pl ↑ Summary t/W.pm »
1 # test the logger -*- perl -*-
2  
3 2 ▶use Getopt::Std;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 my $opt;
5 2 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.2
6 2 $opt={};
7 2 ▶ getopts('d:',$opt) or die<<EOPTS
Branch: 1 branch
BranchTrueFalseTotal
&getopts("d:", $opt) or die " Usage: $0 [-d<option letters from AutoCategorize>]\n\t -d <> : exposes AutoCategorize options for easy testing\n" 2 0 2
8 Usage: $0 [-d<option letters from AutoCategorize>]
9 -d <> : exposes AutoCategorize options for easy testing
10 EOPTS
11 }
12  
13 2 ▶use Log::Log4perl::AutoCategorize (alias => 'Logger',
Subroutine BEGIN: called CC=1 SCAR=2.6
14 debug => $opt->{d}, #'mrijDs',
15 0 );
16  
17 package Foo;
18 use Log::Log4perl::AutoCategorize (alias => 'Logger');
19 sub bar { my $pkg = shift; print "in $pkg->bar(@_)\n" }
20  
21 sub uselogger {
22 Logger->debug("logging from Foo", @_);
23 Logger->debug("logging from Foo", @_, 'extra');
24 Logger->debug("logging from Foo", \@_);
25 }
26  
27 package main;
28  
29 # DONT ADD ANY LINES - ABOVE OR BELOW - EVEN COMMENTS
30 # THE TESTS RELY ON LINE NUMBERS - THATS A FEATURE
31  
32 # blank lines to allow subsequent insert of fixes
33  
34 for (1..2) {
35
36 Logger->debug($_);
37 Logger->info("one arg");
38 Logger->warn("2", "args");
39 Logger->debug(["arrayref"]);
40 Logger->info({hash=>'ref'});
41 Logger->info([[qw/nested arrayref and/], {hash=>'also'}]);
42
43 # 2 of same call on same line !
44 Logger->info( Logger->info({inner=>'call to same fn'}) );
45  
46 # nested call, but different method
47 Logger->info ( Logger->debug({inner=>'call to diff fn'}),
48 'nested', {hash=>'ref'} );
49 usersub($_);
50 Foo->uselogger($_);
51 }
52  
53 sub usersub {
54 Logger->info ( "logging from main function", \@_);
55 Logger->info ( "logging from main function", @_);
56 Logger->info ( "logging from main function", 'arg1', @_);
57 }
58  
59 Logger->bar(); # should evoke warning
60  
61 if ($false) {
62 Logger->info("2", "args");
63 Logger->debug("suppressed", "dueto level");
64 }
65  
66 # these should not be munged
67 Foo->bar();
68 Foo->bar(1);
69  
70  
71 # OK MY TESTS ARE DONE. YOU CAN ADD NOW.
72  
73 # exit 1; # would fail basic test 3
74  
75 __END__
« t/multi_pack.pl ↑ Summary t/W.pm »