blib/lib/Test2/V0.pm

filter: Statementstmt 100% 96 / 96 Branchbran 66.6% 16 / 24 Conditioncond 45.0% 9 / 20 MC/DCmcdc 8.3% 1 / 12 Subroutinesub 100% 24 / 24 Podpod n/a totaltotal 82.9% 146 / 176 CC 19 SCAR 25.5
CC
19
Cov
86%
import
27.2
BEGIN
1.0
BEGIN
1.0
CRAP 12.9
« blib/lib/Test2/Hub.pm ↑ Summary blib/lib/Test2/Compare.pm »
1 package Test2::V0;
2 158 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 158 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 158 ▶use Test2::Util::Importer;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 158 our $VERSION = '1.302226';
8  
9 158 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 158 ▶use Test2::Plugin::SRand();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 158 ▶use Test2::Plugin::UTF8();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 158 ▶use Test2::Tools::Target();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 158 ▶use Test2::Plugin::ExitSummary;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 158 ▶use Test2::API qw/intercept context/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 158 ▶use Test2::Tools::Event qw/gen_event/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 158 ▶use Test2::Tools::Defer qw/def do_def/;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 158 ▶use Test2::Tools::Basic qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
24 ok pass fail diag note todo skip
25 plan skip_all done_testing bail_out
26 158 };
27  
28 158 ▶use Test2::Tools::Compare qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
29 is like isnt unlike
30 match mismatch validator
31 hash array bag object meta meta_check number float rounded within string subset bool check_isa
32 number_lt number_le number_ge number_gt
33 in_set not_in_set check_set
34 item field call call_list call_hash prop check all_items all_keys all_vals all_values
35 etc end filter_items
36 T F D DF E DNE FDNE U L
37 event fail_events
38 exact_ref
39 158 };
40  
41 158 ▶use Test2::Tools::Warnings qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
42 warns warning warnings no_warnings
43 158 };
44  
45 158 ▶use Test2::Tools::ClassicCompare qw/cmp_ok/;
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 158 ▶use Test2::Util::Importer 'Test2::Tools::Subtest' => (
Subroutine BEGIN: called CC=1 SCAR=0.0
48 subtest_buffered => { -as => 'subtest' },
49 158 );
50  
51 158 ▶use Test2::Tools::Class qw/can_ok isa_ok DOES_ok/;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 158 ▶use Test2::Tools::Encoding qw/set_encoding/;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 158 ▶use Test2::Tools::Exports qw/imported_ok not_imported_ok/;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 158 ▶use Test2::Tools::Ref qw/ref_ok ref_is ref_is_not/;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 158 ▶use Test2::Tools::Mock qw/mock mocked/;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 158 ▶use Test2::Tools::Exception qw/try_ok dies lives/;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 158 ▶use Test2::Tools::Refcount qw/is_refcount is_oneref refcount/;
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 158 our @EXPORT = qw{
60 ok pass fail diag note todo skip
61 plan skip_all done_testing bail_out
62  
63 intercept context
64  
65 gen_event
66  
67 def do_def
68  
69 cmp_ok
70  
71 warns warning warnings no_warnings
72  
73 subtest
74 can_ok isa_ok DOES_ok
75 set_encoding
76 imported_ok not_imported_ok
77 ref_ok ref_is ref_is_not
78 mock mocked
79 dies lives try_ok
80  
81 is like isnt unlike
82 match mismatch validator
83 hash array bag object meta meta_check number float rounded within string subset bool check_isa
84 number_lt number_le number_ge number_gt
85 in_set not_in_set check_set
86 item field call call_list call_hash prop check all_items all_keys all_vals all_values
87 etc end filter_items
88 T F D DF E DNE FDNE U L
89 event fail_events
90 exact_ref
91  
92 is_refcount is_oneref refcount
93 };
94  
95 158 my $SRAND;
96 311 ▶sub import {
Subroutine import: called CC=19 SCAR=33.0
97 311 my $class = shift;
98  
99 311 my $caller = caller;
100 311 my (@exports, %options);
101 311 ▶ while (my $arg = shift @_) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $arg = shift @_) 81 311 392
102 81 ▶ push @exports => $arg and next unless substr($arg, 0, 1) eq '-';
Branch: 1 branch
BranchTrueFalseTotal
unless substr($arg, 0, 1) eq "-" 10 71 81
Condition60%3/5
substr($arg, 0, 1) eq '-' || push(@exports, $arg) && (next)
l!l&&r!l&&!r
71100
push @exports, $arg and next
!ll
010
MC/DC0%0/2
substr($arg, 0, 1) eq '-' || push(@exports, $arg) && (next)
substr($arg, 0, 1) eq '-' push @exports, $arg
Truth table66%2/3
A || B
A= substr($arg, 0, 1) eq '-'B= push @exports, $arg
ABresult
1X1
011
000
103 71 $options{$arg} = shift @_;
104 }
105  
106 # SRand handling
107 311 my $srand = delete $options{'-srand'};
108  
109 311 my $no_srand = exists $options{'-no_srand'};
110 311 ▶ delete $options{'-no_srand'} if $no_srand;
Branch: 1 branch
BranchTrueFalseTotal
if $no_srand 0 311 311
111  
112 311 ▶ croak "Cannot combine '-srand' and '-no_srand' options"
Branch: 1 branch
BranchTrueFalseTotal
if $no_srand and defined $srand 0 311 311
Condition33%1/3
$no_srand and defined $srand
!ll&&!rl&&r
31100
MC/DC0%0/2
$no_srand and defined $srand
$no_srand defined $srand
Truth table33%1/3
A and B
A= $no_srandB= defined $srand
ABresult
0X0
100
111
113 if $no_srand && defined($srand);
114  
115 311 ▶ if ( !$no_srand ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($no_srand) 311 0 311
116 311 ▶ Test2::Plugin::SRand->import($srand ? $srand : ()) if defined($srand) || !$SRAND++;
Branch: 2 branches
BranchTrueFalseTotal
if defined $srand or not $SRAND++ 158 153 311
$srand ? : 0 158 158
Condition66%2/3
defined $srand or not $SRAND++
l!l&&r!l&&!r
0158153
MC/DC50%1/2
defined $srand or not $SRAND++
defined $srand not $SRAND++
Truth table66%2/3
A or not(B)
A= defined $srandB= not $SRAND++
ABresult
1X1
011
000
117 }
118  
119 # Pragmas
120 311 my $no_pragmas = delete $options{'-no_pragmas'};
121 311 ▶ my $no_strict = delete $options{'-no_strict'} || $no_pragmas;
Condition33%1/3
delete $options{'-no_strict'} || $no_pragmas
l!l&&r!l&&!r
00311
MC/DC0%0/2
delete $options{'-no_strict'} || $no_pragmas
delete $options{'-no_strict'} $no_pragmas
Truth table33%1/3
A || B
A= delete $options{'-no_strict'}B= $no_pragmas
ABresult
1X1
011
000
122 311 ▶ my $no_warnings = delete $options{'-no_warnings'} || $no_pragmas;
Condition33%1/3
delete $options{'-no_warnings'} || $no_pragmas
l!l&&r!l&&!r
00311
MC/DC0%0/2
delete $options{'-no_warnings'} || $no_pragmas
delete $options{'-no_warnings'} $no_pragmas
Truth table33%1/3
A || B
A= delete $options{'-no_warnings'}B= $no_pragmas
ABresult
1X1
011
000
123 311 ▶ my $no_utf8 = delete $options{'-no_utf8'} || $no_pragmas;
Condition33%1/3
delete $options{'-no_utf8'} || $no_pragmas
l!l&&r!l&&!r
00311
MC/DC0%0/2
delete $options{'-no_utf8'} || $no_pragmas
delete $options{'-no_utf8'} $no_pragmas
Truth table33%1/3
A || B
A= delete $options{'-no_utf8'}B= $no_pragmas
ABresult
1X1
011
000
124  
125 311 ▶ strict->import() unless $no_strict;
Branch: 1 branch
BranchTrueFalseTotal
unless $no_strict 311 0 311
126 311 ▶ 'warnings'->import() unless $no_warnings;
Branch: 1 branch
BranchTrueFalseTotal
unless $no_warnings 311 0 311
127 311 ▶ Test2::Plugin::UTF8->import() unless $no_utf8;
Branch: 1 branch
BranchTrueFalseTotal
unless $no_utf8 311 0 311
128  
129 311 my $target = delete $options{'-target'};
130 311 ▶ Test2::Tools::Target->import_into($caller, $target)
Branch: 1 branch
BranchTrueFalseTotal
if $target 71 240 311
131 if $target;
132  
133 311 ▶ croak "Unknown option(s): " . join(', ', sort keys %options) if keys %options;
Branch: 1 branch
BranchTrueFalseTotal
if keys %options 0 311 311
134  
135 311 Test2::Util::Importer->import_into($class, $caller, @exports);
136 }
137  
138 158 1;
139  
140 __END__
« blib/lib/Test2/Hub.pm ↑ Summary blib/lib/Test2/Compare.pm »