| 1 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Test::Tester; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | if (*Test::Builder::new{CODE}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | warn "You should load Test::Tester before Test::Builder (or anything that loads Test::Builder)" | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Test::Builder; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use Test::Tester::CaptureRunner; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use Test::Tester::Delegate; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | our @EXPORT = qw( run_tests check_tests check_test cmp_results show_space ); | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | our @ISA = qw( Exporter ); | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | my $Test = Test::Builder->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 6 | my $Capture = Test::Tester::Capture->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | 6 | my $Delegator = Test::Tester::Delegate->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | 6 | $Delegator->{Object} = $Test; | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | my $runner = Test::Tester::CaptureRunner->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 6 | my $want_space = $ENV{TESTTESTERSPACE}; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | sub show_space | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_space: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $want_space = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | my $colour = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | 6 | my $reset = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | ▶ | if (my $want_colour = $ENV{TESTTESTERCOLOUR} || $ENV{TESTTESTERCOLOR}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{'TESTTESTERCOLOUR'} || $ENV{'TESTTESTERCOLOR'}
MC/DC0%0/2
$ENV{'TESTTESTERCOLOUR'} || $ENV{'TESTTESTERCOLOR'}
$ENV{'TESTTESTERCOLOUR'}
$ENV{'TESTTESTERCOLOR'}
Truth table33%1/3
A || B
A= $ENV{'TESTTESTERCOLOUR'}B= $ENV{'TESTTESTERCOLOR'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if (eval { require Term::ANSIColor; 1 }) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | eval { require Win32::Console::ANSI } if 'MSWin32' eq $^O; # support color on windows platforms | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my ($f, $b) = split(",", $want_colour); | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $colour = Term::ANSIColor::color($f).Term::ANSIColor::color("on_$b"); | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $reset = Term::ANSIColor::color("reset"); | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | sub new_new | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 7 | return $Delegator; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | sub capture | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
capture: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | return Test::Tester::Capture->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | sub fh | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fh: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # experiment with capturing output, I don't like it | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $runner = Test::Tester::FHRunner->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return $Test; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | sub find_run_tests | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 26 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_run_tests: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 26 | my $d = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 26 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 26 | ▶ | while ((not $found) and (my ($sub) = (caller($d))[3]) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $found and my($sub) = (caller $d)[3]
MC/DC50%1/2
not $found and my($sub) = (caller $d)[3]
not $found
my($sub) = (caller $d)[3]
Truth table66%2/3
not(A) and B
A= not $foundB= my($sub) = (caller $d)[3]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # print "$d: $sub\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 109 | $found = ($sub eq "Test::Tester::run_tests"); | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 109 | $d++; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # die "Didn't find 'run_tests' in caller stack" unless $found; | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 26 | return $d; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | sub run_tests | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_tests: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 18 | local($Delegator->{Object}) = $Capture; | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 18 | $runner->run_tests(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 18 | return ($runner->get_premature, $runner->get_results); | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | sub check_test | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_test: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 8 | my $test = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | 8 | my $expect = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | 8 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | 8 | ▶ | $name = "" unless defined($name); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 8 | @_ = ($test, [$expect], $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 8 | goto &check_tests; | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | sub check_tests | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_tests: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 9 | my $test = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 9 | my $expects = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | 9 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | 9 | ▶ | $name = "" unless defined($name); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 9 | my ($prem, @results) = eval { run_tests($test, $name) }; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 9 | ▶ | $Test->ok(! $@, "Test '$name' completed") || $Test->diag($@); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 9 | ▶ | $Test->ok(! length($prem), "Test '$name' no premature diagnostication") || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | $Test->diag("Before any testing anything, your tests said\n$prem"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 9 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | 9 | cmp_results(\@results, $expects, $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | 9 | return ($prem, @results); | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | sub cmp_field | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 80 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmp_field: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 80 | my ($result, $expect, $field, $desc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 80 | ▶ | if (defined $expect->{$field}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 80 | $Test->is_eq($result->{$field}, $expect->{$field}, | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | "$desc compare $field"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | sub cmp_result | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmp_result: called CC=15 SCAR=32.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 16 | my ($result, $expect, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 16 | my $sub_name = $result->{name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | 16 | ▶ | $name = "" unless defined($name); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 16 | ▶ | $sub_name = "" unless defined $sub_name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 16 | my $desc = "subtest '$sub_name' of '$name'"; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 16 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 16 | cmp_field($result, $expect, "ok", $desc); | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 16 | cmp_field($result, $expect, "actual_ok", $desc); | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 16 | cmp_field($result, $expect, "type", $desc); | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 16 | cmp_field($result, $expect, "reason", $desc); | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 16 | cmp_field($result, $expect, "name", $desc); | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # if we got no depth then default to 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 16 | my $depth = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | 16 | ▶ | if (exists $expect->{depth}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 16 | $depth = $expect->{depth}; | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # if depth was explicitly undef then don't test it | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 16 | ▶ | if (defined $depth) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 16 | ▶ | $Test->is_eq($result->{depth}, $depth, "checking depth") || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | $Test->diag('You need to change $Test::Builder::Level'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 16 | ▶ | if (defined(my $exp = $expect->{diag})) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 16 | my $got = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 16 | ▶ | if (ref $exp eq 'Regexp') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 4 | ▶ | if (not $Test->like($result->{diag}, $exp, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | "subtest '$sub_name' of '$name' compare diag")) | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $got = $result->{diag}; | |||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # if there actually is some diag then put a \n on the end if it's not | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # there already | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 12 | ▶ | $exp .= "\n" if (length($exp) and $exp !~ /\n$/); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $exp and not $exp =~ /\n$/
MC/DC100%2/2
length $exp and not $exp =~ /\n$/
length $exp
not $exp =~ /\n$/
Truth table100%3/3
A and not(B)
A= length $expB= not $exp =~ /\n$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 12 | ▶ | if (not $Test->ok($result->{diag} eq $exp, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | "subtest '$sub_name' of '$name' compare diag")) | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $got = $result->{diag}; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 16 | ▶ | if ($got) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $glen = length($got); | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $elen = length($exp); | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | for ($got, $exp) | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my @lines = split("\n", $_); | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | $_ = join("\n", map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ($want_space) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $_ = $colour.escape($_).$reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | "'$colour$_$reset'" | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } @lines); | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $Test->diag(<<EOM); | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | Got diag ($glen bytes): | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | $got | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | Expected diag ($elen bytes): | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | $exp | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | EOM | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | sub escape | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escape: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $res = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | for my $char (split("", $str)) | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $c = ord($char); | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if(($c>32 and $c<125) or $c == 10) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$c > 32 and $c < 125 or $c == 10
$c > 32 and $c < 125
MC/DC0%0/3
$c > 32 and $c < 125 or $c == 10
$c > 32
$c < 125
$c == 10
Truth table0%0/5
A and B or C
A= $c > 32B= $c < 125C= $c == 10
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $res .= $char; | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $res .= sprintf('\x{%x}', $c) | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | sub cmp_results | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmp_results: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 9 | my ($results, $expects, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 9 | $Test->is_num(scalar @$results, scalar @$expects, "Test '$name' result count"); | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 9 | ▶ | for (my $i = 0; $i < @$expects; $i++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 16 | my $expect = $expects->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | 16 | my $result = $results->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 16 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 16 | cmp_result($result, $expect, $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | ######## nicked from Test::More | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 5 | ▶ | sub plan { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plan: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 5 | my(@plan) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 5 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 5 | $Test->exported_to($caller); | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 5 | my @imports = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | foreach my $idx (0..$#plan) { | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | ▶ | if( $plan[$idx] eq 'import' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my($tag, $imports) = splice @plan, $idx, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | @imports = @$imports; | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 5 | $Test->plan(@plan); | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 5 | __PACKAGE__->_export_to_level(1, __PACKAGE__, @imports); | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 5 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 5 | my($class) = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 6 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 5 | *Test::Builder::new = \&new_new; | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 5 | goto &plan; | |||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | sub _export_to_level | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_export_to_level: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 5 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 295 | 5 | my $level = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | 5 | (undef) = shift; # redundant arg | |||||||||||||||||||||||||||||||||||||||||||||
| 297 | 5 | my $callpkg = caller($level); | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | 5 | $pkg->export($callpkg, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | ############ | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||