| 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 | sub start { | ||||||||||||||||||||||||
| 20 | 26 | ▶ | my $encoding = do { | ||||||||||||||||||||||
|
Subroutine
start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||
| 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 | sub colored { | ||||||||||||||||||||||||
| 32 | 0 | ▶ | my ($self, $color, $msg) = @_; | ||||||||||||||||||||||
|
Subroutine
colored: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||
| 33 | 0 | $msg; | |||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||
| 36 | sub suite { | ||||||||||||||||||||||||
| 37 | 58 | ▶ | my ($self, $title) = @_; | ||||||||||||||||||||||
|
Subroutine
suite: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||
| 38 | 58 | push @{$self->{suite}}, $title; | |||||||||||||||||||||||
| 39 | 58 | printf "# %s\n", join('/', @{$self->{suite}}); | |||||||||||||||||||||||
| 40 | return Scope::Guard->new( | ||||||||||||||||||||||||
| 41 | sub { | ||||||||||||||||||||||||
| 42 | 58 | ▶ | pop @{$self->{suite}}; | ||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||
| 44 | 58 | ); | |||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||
| 47 | sub fail { | ||||||||||||||||||||||||
| 48 | 14 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||
|
Subroutine
fail: called CC=5 SCAR=17.3
Pod
undocumented
| |||||||||||||||||||||||||
| 49 | 14 | ▶ | $args{caller} or Carp::confess; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||
| 51 | 14 | ▶ | my $title = $args{description} || $args{caller}->code || '-'; | ||||||||||||||||||||||
|
Condition60%3/5
$args{'description'} || $args{'caller'}->code || '-'
$args{"description"} or $args{"caller"}->code
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
| |||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||
| 56 | $self->diag(message => $args{diag}) | ||||||||||||||||||||||||
| 57 | 0 | } | |||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||
| 60 | sub pass { | ||||||||||||||||||||||||
| 61 | 26 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||
|
Subroutine
pass: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||
| 62 | 26 | ▶ | my $title = $args{description} || $args{caller}->code || '-'; | ||||||||||||||||||||||
|
Condition60%3/5
$args{'description'} || $args{'caller'}->code || '-'
$args{"description"} or $args{"caller"}->code
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
| |||||||||||||||||||||||||
| 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 | sub message { | ||||||||||||||||||||||||
| 69 | 0 | ▶ | my ($self, $message) = @_; | ||||||||||||||||||||||
|
Subroutine
message: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||
| 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 | sub render_message_power { | ||||||||||||||||||||||||
| 79 | 0 | ▶ | my ($self, $message) = @_; | ||||||||||||||||||||||
|
Subroutine
render_message_power: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||
| 80 | 0 | $message->caller->code; | |||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||
| 83 | sub step { | ||||||||||||||||||||||||
| 84 | 42 | ▶ | my ($self, $title) = @_; | ||||||||||||||||||||||
|
Subroutine
step: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||
| 85 | 42 | for my $line (split /\n/, $title) { | |||||||||||||||||||||||
| 86 | 42 | print "# $line\n"; | |||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||
| 90 | sub diag { | ||||||||||||||||||||||||
| 91 | 12 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||
|
Subroutine
diag: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||
| 92 | 12 | ▶ | my $message = $args{message} // die; | ||||||||||||||||||||||
|
Condition50%1/2
$args{"message"} // die()
MC/DC0%0/1
$args{"message"} // die()
$args{"message"}
Truth table50%1/2
A
A= $args{"message"}
| |||||||||||||||||||||||||
| 93 | 12 | ▶ | my $cutoff = $args{cutoff} // $self->cutoff; | ||||||||||||||||||||||
|
Condition33%1/3
$args{"cutoff"} // $self->cutoff
MC/DC0%0/2
$args{"cutoff"} // $self->cutoff
$args{"cutoff"}
$self->cutoff
Truth table33%1/3
A // B
A= $args{"cutoff"}B= $self->cutoff
| |||||||||||||||||||||||||
| 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 | sub exception { | ||||||||||||||||||||||||
| 102 | 2 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||
|
Subroutine
exception: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||
| 103 | 2 | print "Exception: $args{message}"; | |||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||
| 106 | sub finalize { | ||||||||||||||||||||||||
| 107 | 22 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||
|
Subroutine
finalize: called CC=3 SCAR=16.0
Pod
undocumented
| |||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||
| 109 | # If Test::Builder was loaded... | ||||||||||||||||||||||||
| 110 | 22 | ▶ | if (Test::Builder->can('new')) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 111 | 0 | ▶ | if (!Test::Builder->new->is_passing) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||