Kantan/Reporter/TAP.pm

filter: Statementstmt 84.0% 74 / 88 Branchbran 37.5% 3 / 8 Conditioncond 53.3% 8 / 15 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 86.9% 20 / 23 Podpod 0.0% 0 / 11 totaltotal 69.0% 105 / 152 CC 13 SCAR 9.9
CC
13
Cov
77%
fail
5.6
finalize
4.9
diag
4.2
CRAP 2.7
« Kantan/Caller.pm ↑ Summary Kantan/Builder.pm »
1 package Test::Kantan::Reporter::TAP;
2 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 26 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 26 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 26 ▶use 5.010_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 26 ▶use Term::ANSIColor ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 26 ▶use Test::Kantan::Util qw(dump_data truncstr);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 26 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 26 extends 'Test::Kantan::Reporter::Base';
12  
13 26 ▶has count => (is => 'ro', default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
14  
15 26 ▶no Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 26 ▶use Scope::Guard;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 26 ▶sub start {
Subroutine start: called CC=1 SCAR=0.0
Pod undocumented
20 26 my $encoding = do {
21 26 require Term::Encoding;
22 26 Term::Encoding::get_encoding();
23 };
24  
25 26 ▶ binmode *STDOUT, ":encoding(${encoding})";
Subroutine BEGIN: called CC=1 SCAR=0.0
26 26 STDOUT->autoflush(1);
27  
28 26 print "\n\n";
29 }
30  
31 0 ▶sub colored {
Subroutine colored: not called CC=1 SCAR=6.9
Pod undocumented
32 0 my ($self, $color, $msg) = @_;
33 0 $msg;
34 }
35  
36 58 ▶sub suite {
Subroutine suite: called CC=1 SCAR=0.0
Pod undocumented
37 58 my ($self, $title) = @_;
38 58 push @{$self->{suite}}, $title;
39 58 printf "# %s\n", join('/', @{$self->{suite}});
40 return Scope::Guard->new(
41 58 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
42 58 pop @{$self->{suite}};
43 }
44 58 );
45 }
46  
47 14 ▶sub fail {
Subroutine fail: called CC=5 SCAR=17.3
Pod undocumented
48 14 my ($self, %args) = @_;
49 14 ▶ $args{caller} or Carp::confess;
Branch: 1 branch
BranchTrueFalseTotal
$args{"caller"} or Carp::confess() 14 0 14
50  
51 14 ▶ my $title = $args{description} || $args{caller}->code || '-';
Condition60%3/5
$args{'description'} || $args{'caller'}->code || '-'
l!l
140
$args{"description"} or $args{"caller"}->code
l!l&&r!l&&!r
2120
MC/DC0%0/2
$args{'description'} || $args{'caller'}->code || '-'
$args{"description"} $args{"caller"}->code
Truth table66%2/3
A or B
A= $args{"description"}B= $args{"caller"}->code
ABresult
1X1
011
000
52 14 $title =~ s/\n/\\n/g;
53 14 $self->{count}++;
54 14 printf("not ok %d - %s\n", $self->count, $title);
55 14 ▶ if ($args{diag}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"diag"}) 0 14 14
56 $self->diag(message => $args{diag})
57 0 }
58 }
59  
60 26 ▶sub pass {
Subroutine pass: called CC=3 SCAR=11.2
Pod undocumented
61 26 my ($self, %args) = @_;
62 26 ▶ my $title = $args{description} || $args{caller}->code || '-';
Condition60%3/5
$args{'description'} || $args{'caller'}->code || '-'
l!l
260
$args{"description"} or $args{"caller"}->code
l!l&&r!l&&!r
12140
MC/DC0%0/2
$args{'description'} || $args{'caller'}->code || '-'
$args{"description"} $args{"caller"}->code
Truth table66%2/3
A or B
A= $args{"description"}B= $args{"caller"}->code
ABresult
1X1
011
000
63 26 $title =~ s/\n/\\n/g;
64 26 $self->{count}++; # TODO: use counter in the state object
65 26 printf("ok %d - %s\n", $self->count, $title);
66 }
67  
68 0 ▶sub message {
Subroutine message: not called CC=1 SCAR=6.9
Pod undocumented
69 0 my ($self, $message) = @_;
70  
71 0 (my $moniker = ref($message)) =~ s/.*:://;
72 0 my $method = "render_message_\L$moniker";
73 0 my $str = $self->$method($message);
74 0 $str =~ s/^/# /mg;
75 0 print "$str\n";
76 }
77  
78 0 ▶sub render_message_power {
Subroutine render_message_power: not called CC=1 SCAR=6.9
Pod undocumented
79 0 my ($self, $message) = @_;
80 0 $message->caller->code;
81 }
82  
83 42 ▶sub step {
Subroutine step: called CC=2 SCAR=6.9
Pod undocumented
84 42 my ($self, $title) = @_;
85 42 for my $line (split /\n/, $title) {
86 42 print "# $line\n";
87 }
88 }
89  
90 12 ▶sub diag {
Subroutine diag: called CC=4 SCAR=14.5
Pod undocumented
91 12 my ($self, %args) = @_;
92 12 ▶ my $message = $args{message} // die;
Condition50%1/2
$args{"message"} // die()
l!l
120
MC/DC0%0/1
$args{"message"} // die()
$args{"message"}
Truth table50%1/2
A
A= $args{"message"}
Aresult
11
00
93 12 ▶ my $cutoff = $args{cutoff} // $self->cutoff;
Condition33%1/3
$args{"cutoff"} // $self->cutoff
l!l&&r!l&&!r
0120
MC/DC0%0/2
$args{"cutoff"} // $self->cutoff
$args{"cutoff"} $self->cutoff
Truth table33%1/3
A // B
A= $args{"cutoff"}B= $self->cutoff
ABresult
1X1
011
000
94 12 $message = dump_data($message);
95 12 $message = truncstr($message, $cutoff);
96 12 for my $line (split /\n/, $message) {
97 12 print "# $line\n";
98 }
99 }
100  
101 2 ▶sub exception {
Subroutine exception: called CC=1 SCAR=0.0
Pod undocumented
102 2 my ($self, %args) = @_;
103 2 print "Exception: $args{message}";
104 }
105  
106 22 ▶sub finalize {
Subroutine finalize: called CC=3 SCAR=16.0
Pod undocumented
107 22 my ($self, %args) = @_;
108  
109 # If Test::Builder was loaded...
110 22 ▶ if (Test::Builder->can('new')) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Test::Builder"->can("new")) 0 22 22
111 0 ▶ if (!Test::Builder->new->is_passing) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("Test::Builder"->new->is_passing) 0 0 0
112 0 $self->state->failed;
113 0 printf "not ok - %s\n", 'Test::Builder was failed';
114 }
115 }
116  
117 22 printf "1..%d\n", $self->count;
118 }
119  
120 26 1;
121  
« Kantan/Caller.pm ↑ Summary Kantan/Builder.pm »