Plugin/NoWarnings.pm

filter: Statementstmt 94.5% 35 / 37 Branchbran 58.3% 7 / 12 Conditioncond 13.3% 2 / 15 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 65.8% 52 / 79 CC 12 SCAR 27.5
CC
12
Cov
69%
__ANON__
26.1
import
2.0
BEGIN
1.0
CRAP 15.7
↑ Summary Event/Warning.pm »
1 package Test2::Plugin::NoWarnings;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 our $VERSION = '0.10';
7  
8 # This is the version that added test2_is_testing_done.
9 6 ▶use Test2 1.302167;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Test2::API qw( context_do test2_is_testing_done );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Test2::Event::Warning;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 6 my $echo = 0;
14  
15 6 ▶sub import {
Subroutine import: called CC=2 SCAR=7.0
16 6 shift;
17 6 my %args = @_;
18 6 ▶ $echo = $args{echo} if exists $args{echo};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"echo"} 0 6 6
19 6 return;
20 }
21  
22 6 my $_orig_warn_handler = $SIG{__WARN__};
23 ## no critic (Variables::RequireLocalizedPunctuationVars)
24 5 ▶$SIG{__WARN__} = sub {
Subroutine __ANON__: called CC=11 SCAR=32.6
25 5 ▶ unless ( test2_is_testing_done() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (test2_is_testing_done()) 4 1 5
26 4 my $w = $_[0];
27 4 $w =~ s/\n+$//g;
28  
29 3 ▶ context_do {
Subroutine __ANON__: called CC=1 SCAR=0.0
30 3 my $ctx = shift;
31 3 $ctx->send_event(
32 'Warning',
33 warning => "Unexpected warning: $w",
34 );
35 }
36 4 $_[0];
37  
38 3 ▶ return unless $echo;
Branch: 1 branch
BranchTrueFalseTotal
unless $echo 3 0 3
39 }
40  
41 1 ▶ return if $_orig_warn_handler && $_orig_warn_handler eq 'IGNORE';
Branch: 1 branch
BranchTrueFalseTotal
if $_orig_warn_handler and $_orig_warn_handler eq "IGNORE" 0 1 1
Condition33%1/3
$_orig_warn_handler and $_orig_warn_handler eq "IGNORE"
!ll&&!rl&&r
100
MC/DC0%0/2
$_orig_warn_handler and $_orig_warn_handler eq "IGNORE"
$_orig_warn_handler $_orig_warn_handler eq "IGNORE"
Truth table33%1/3
A and B
A= $_orig_warn_handlerB= $_orig_warn_handler eq "IGNORE"
ABresult
0X0
100
111
42  
43 # The rest was copied from Test::Warnings
44  
45 # TODO: this doesn't handle blessed coderefs... does anyone care?
46 1 ▶ goto &$_orig_warn_handler
Branch: 1 branch
BranchTrueFalseTotal
if $_orig_warn_handler and ref $_orig_warn_handler eq "CODE" || $_orig_warn_handler ne "DEFAULT" && $_orig_warn_handler ne "IGNORE" && defined &$_orig_warn_handler 0 1 1
Condition8%1/12
$_orig_warn_handler and ref $_orig_warn_handler eq "CODE" || $_orig_warn_handler ne "DEFAULT" && $_orig_warn_handler ne "IGNORE" && defined &$_orig_warn_handler
!ll&&!rl&&r
100
ref $_orig_warn_handler eq "CODE" or $_orig_warn_handler ne "DEFAULT" and $_orig_warn_handler ne "IGNORE" and defined &$_orig_warn_handler
l!l&&r!l&&!r
000
$_orig_warn_handler ne "DEFAULT" and $_orig_warn_handler ne "IGNORE" and defined &$_orig_warn_handler
!ll&&!rl&&r
000
$_orig_warn_handler ne "DEFAULT" and $_orig_warn_handler ne "IGNORE"
!ll&&!rl&&r
000
MC/DC0%0/5
$_orig_warn_handler and ref $_orig_warn_handler eq "CODE" || $_orig_warn_handler ne "DEFAULT" && $_orig_warn_handler ne "IGNORE" && defined &$_orig_warn_handler
$_orig_warn_handler ref $_orig_warn_handler eq "CODE" $_orig_warn_handler ne "DEFAULT" $_orig_warn_handler ne "IGNORE" defined &$_orig_warn_handler
Truth table16%1/6
A and B or C and D and E
A= $_orig_warn_handlerB= ref $_orig_warn_handler eq "CODE"C= $_orig_warn_handler ne "DEFAULT"D= $_orig_warn_handler ne "IGNORE"E= defined &$_orig_warn_handler
ABCDEresult
0XXXX0
100XX0
1010X0
101100
11XXX1
101111
47 if $_orig_warn_handler
48 and (
49 ( ref $_orig_warn_handler eq 'CODE' )
50 or ( $_orig_warn_handler ne 'DEFAULT'
51 and $_orig_warn_handler ne 'IGNORE'
52 and defined &$_orig_warn_handler )
53 );
54  
55 1 ▶ if ( $_[0] =~ /\n$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /\n$/) { } 1 0 1
56 1 warn $_[0];
57 }
58 else {
59 0 require Carp;
60 0 Carp::carp( $_[0] );
61 }
62 6 };
63  
64 6 1;
65  
66 # ABSTRACT: Fail if tests warn
67  
68 __END__
↑ Summary Event/Warning.pm »