| 1 | 25 | ▶ | use Test::Builder; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 25 | ▶ | use TestML1::Runtime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package TestML1::Runtime::TAP; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 25 | ▶ | use TestML1::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 25 | extends 'TestML1::Runtime'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 24 | ▶ | has tap_object => sub { Test::Builder->new }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 25 | has planned => 0; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 24 | ▶ | sub run { | ||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 24 | my ($self) = @_; | |||||||||||||||||||||||||||
| 14 | 24 | $self->SUPER::run; | |||||||||||||||||||||||||||
| 15 | 24 | $self->check_plan; | |||||||||||||||||||||||||||
| 16 | 24 | $self->plan_end; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 122 | ▶ | sub run_assertion { | ||||||||||||||||||||||||||
|
Subroutine
run_assertion: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 20 | 122 | my ($self, @args) = @_; | |||||||||||||||||||||||||||
| 21 | 122 | $self->check_plan; | |||||||||||||||||||||||||||
| 22 | 122 | $self->SUPER::run_assertion(@args); | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 146 | ▶ | sub check_plan { | ||||||||||||||||||||||||||
|
Subroutine
check_plan: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 146 | my ($self) = @_; | |||||||||||||||||||||||||||
| 27 | 146 | ▶ | if (! $self->planned) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 24 | $self->title; | |||||||||||||||||||||||||||
| 29 | 24 | $self->plan_begin; | |||||||||||||||||||||||||||
| 30 | 24 | $self->{planned} = 1; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 24 | ▶ | sub title { | ||||||||||||||||||||||||||
|
Subroutine
title: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 24 | my ($self) = @_; | |||||||||||||||||||||||||||
| 36 | 24 | ▶ | if (my $title = $self->function->getvar('Title')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 6 | $title = $title->value; | |||||||||||||||||||||||||||
| 38 | 6 | $title = "=== $title ===\n"; | |||||||||||||||||||||||||||
| 39 | 6 | $self->tap_object->note($title); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub skip_test { | ||||||||||||||||||||||||||
|
Subroutine
skip_test: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 0 | my ($self, $reason) = @_; | |||||||||||||||||||||||||||
| 45 | 0 | $self->tap_object->plan(skip_all => $reason); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 24 | ▶ | sub plan_begin { | ||||||||||||||||||||||||||
|
Subroutine
plan_begin: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 24 | my ($self) = @_; | |||||||||||||||||||||||||||
| 50 | 24 | ▶ | if (my $tests = $self->function->getvar('Plan')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 23 | $self->tap_object->plan(tests => $tests->value); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 24 | ▶ | sub plan_end { | ||||||||||||||||||||||||||
|
Subroutine
plan_end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 24 | my ($self) = @_; | |||||||||||||||||||||||||||
| 57 | 24 | $self->tap_object->done_testing(); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # TODO Use Test::Diff here. | ||||||||||||||||||||||||||||
| 61 | 96 | ▶ | sub assert_EQ { | ||||||||||||||||||||||||||
|
Subroutine
assert_EQ: called CC=5 SCAR=26.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 96 | my ($self, $got, $want) = @_; | |||||||||||||||||||||||||||
| 63 | 96 | $got = $got->str->value; | |||||||||||||||||||||||||||
| 64 | 96 | $want = $want->str->value; | |||||||||||||||||||||||||||
| 65 | 96 | ▶ | if ($got ne $want and $want =~ /\n/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$got ne $want and $want =~ /\n/
MC/DC0%0/2
$got ne $want and $want =~ /\n/
$got ne $want
$want =~ /\n/
Truth table33%1/3
A and B
A= $got ne $wantB= $want =~ /\n/
| |||||||||||||||||||||||||||||
| 66 | 0 | my $block = $self->function->getvar('Block'); | |||||||||||||||||||||||||||
| 67 | 0 | my $diff = $self->function->getvar('Diff'); | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ($diff or exists $block->points->{DIFF}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$diff or exists $block->points->{"DIFF"}
MC/DC0%0/2
$diff or exists $block->points->{"DIFF"}
$diff
exists $block->points->{"DIFF"}
Truth table0%0/3
A or B
A= $diffB= exists $block->points->{"DIFF"}
| |||||||||||||||||||||||||||||
| 69 | 0 | require Text::Diff; | |||||||||||||||||||||||||||
| 70 | 0 | $self->tap_object->ok(0, $self->get_label); | |||||||||||||||||||||||||||
| 71 | 0 | my $diff = Text::Diff::diff( | |||||||||||||||||||||||||||
| 72 | \$want, \$got, { | ||||||||||||||||||||||||||||
| 73 | FILENAME_A => "want", | ||||||||||||||||||||||||||||
| 74 | FILENAME_B => "got", | ||||||||||||||||||||||||||||
| 75 | }, | ||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||
| 77 | 0 | $self->tap_object->diag($diff); | |||||||||||||||||||||||||||
| 78 | 0 | return; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | $self->tap_object->is_eq( | ||||||||||||||||||||||||||||
| 82 | 96 | $got, | |||||||||||||||||||||||||||
| 83 | $want, | ||||||||||||||||||||||||||||
| 84 | $self->get_label, | ||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 7 | ▶ | sub assert_HAS { | ||||||||||||||||||||||||||
|
Subroutine
assert_HAS: called CC=2 SCAR=7.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 89 | 7 | my ($self, $got, $has) = @_; | |||||||||||||||||||||||||||
| 90 | 7 | $got = $got->str->value; | |||||||||||||||||||||||||||
| 91 | 7 | $has = $has->str->value; | |||||||||||||||||||||||||||
| 92 | 7 | my $assertion = (index($got, $has) >= 0); | |||||||||||||||||||||||||||
| 93 | 7 | ▶ | if (not $assertion) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 0 | my $msg = <<"..."; | |||||||||||||||||||||||||||
| 95 | Failed TestML1 HAS (~~) assertion. This text: | ||||||||||||||||||||||||||||
| 96 | '$got' | ||||||||||||||||||||||||||||
| 97 | does not contain this string: | ||||||||||||||||||||||||||||
| 98 | '$has' | ||||||||||||||||||||||||||||
| 99 | ... | ||||||||||||||||||||||||||||
| 100 | 0 | $self->tap_object->diag($msg); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | 7 | $self->tap_object->ok($assertion, $self->get_label); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 19 | ▶ | sub assert_OK { | ||||||||||||||||||||||||||
|
Subroutine
assert_OK: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 106 | 19 | my ($self, $got) = @_; | |||||||||||||||||||||||||||
| 107 | 19 | $self->tap_object->ok( | |||||||||||||||||||||||||||
| 108 | $got->bool->value, | ||||||||||||||||||||||||||||
| 109 | $self->get_label, | ||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 25 | 1; | |||||||||||||||||||||||||||