blib/lib/Test2/Tools/Exports.pm

filter: Statementstmt 100% 49 / 49 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 67 / 67 CC 5 SCAR 6.9
CC
5
Cov
100%
imported_ok
3.0
not_imported_ok
3.0
BEGIN
1.0
CRAP 2.0
« blib/lib/Test2/Compare/Isa.pm ↑ Summary blib/lib/Test2/Tools/Event.pm »
1 package Test2::Tools::Exports;
2 164 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 164 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 164 our $VERSION = '1.302226';
6  
7 164 ▶use Carp qw/croak carp/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 164 ▶use Test2::API qw/context/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 164 ▶use Test2::Util::Stash qw/get_symbol/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 164 our @EXPORT = qw/imported_ok not_imported_ok/;
12 164 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 38 ▶sub imported_ok {
Subroutine imported_ok: called CC=3 SCAR=11.0
Pod documented
15 38 my $ctx = context();
16 38 my $caller = caller;
17 38 my @missing = grep { !get_symbol($_, $caller) } @_;
18  
19 38 my $name = "Imported symbol";
20 38 ▶ $name .= "s" if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 22 16 38
21 38 $name .= ": ";
22 38 my $list = join(", ", @_);
23 38 ▶ substr($list, 37, length($list) - 37, '...') if length($list) > 40;
Branch: 1 branch
BranchTrueFalseTotal
if length $list > 40 15 23 38
24 38 $name .= $list;
25  
26 38 $ctx->ok(!@missing, $name, [map { "'$_' was not imported." } @missing]);
27  
28 38 $ctx->release;
29  
30 38 return !@missing;
31 }
32  
33 10 ▶sub not_imported_ok {
Subroutine not_imported_ok: called CC=3 SCAR=11.0
Pod documented
34 10 my $ctx = context();
35 10 my $caller = caller;
36 10 my @found = grep { get_symbol($_, $caller) } @_;
37  
38 10 my $name = "Did not imported symbol";
39 10 ▶ $name .= "s" if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 2 8 10
40 10 $name .= ": ";
41 10 my $list = join(", ", @_);
42 10 ▶ substr($list, 37, length($list) - 37, '...') if length($list) > 40;
Branch: 1 branch
BranchTrueFalseTotal
if length $list > 40 1 9 10
43 10 $name .= $list;
44  
45 10 $ctx->ok(!@found, $name, [map { "'$_' was imported." } @found]);
46  
47 10 $ctx->release;
48  
49 10 return !@found;
50 }
51  
52 164 1;
53  
54 __END__
« blib/lib/Test2/Compare/Isa.pm ↑ Summary blib/lib/Test2/Tools/Event.pm »