| 1 | package Test2::Tools::ClassicCompare; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 167 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 167 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 167 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 167 | our @EXPORT = qw/is is_deeply isnt like unlike cmp_ok/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 167 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 167 | ▶ | use Carp qw/carp/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 167 | ▶ | use Scalar::Util qw/reftype/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 167 | ▶ | use Test2::API qw/context/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 167 | ▶ | use Test2::Compare qw/compare strict_convert/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 167 | ▶ | use Test2::Util::Ref qw/rtype render_ref/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 167 | ▶ | use Test2::Util::Table qw/table/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 167 | ▶ | use Test2::Compare::Array(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 167 | ▶ | use Test2::Compare::Bag(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 167 | ▶ | use Test2::Compare::Custom(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 167 | ▶ | use Test2::Compare::Event(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 167 | ▶ | use Test2::Compare::Hash(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 167 | ▶ | use Test2::Compare::Meta(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 167 | ▶ | use Test2::Compare::Number(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 167 | ▶ | use Test2::Compare::Object(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 167 | ▶ | use Test2::Compare::OrderedSubset(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 167 | ▶ | use Test2::Compare::Pattern(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 167 | ▶ | use Test2::Compare::Ref(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 167 | ▶ | use Test2::Compare::Regex(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 167 | ▶ | use Test2::Compare::Scalar(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 167 | ▶ | use Test2::Compare::Set(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 167 | ▶ | use Test2::Compare::String(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 167 | ▶ | use Test2::Compare::Undef(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 167 | ▶ | use Test2::Compare::Wildcard(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 7 | ▶ | sub is($$;$@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 7 | my ($got, $exp, $name, @diag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 7 | my $ctx = context(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 7 | my @caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 7 | my $delta = compare($got, $exp, \&is_convert); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 7 | ▶ | if ($delta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | $ctx->fail($name, $delta->diag, @diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | $ctx->ok(1, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 7 | $ctx->release; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 7 | return !$delta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | ▶ | sub isnt($$;$@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isnt: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | my ($got, $exp, $name, @diag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | my $ctx = context(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | my @caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | my $delta = compare($got, $exp, \&isnt_convert); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | ▶ | if ($delta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | $ctx->fail($name, $delta->diag, @diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | $ctx->ok(1, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 4 | $ctx->release; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 4 | return !$delta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 7 | ▶ | sub is_convert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_convert: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 7 | my ($thing) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 7 | ▶ | return Test2::Compare::Undef->new() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | unless defined $thing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 5 | return Test2::Compare::String->new(input => $thing); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | ▶ | sub isnt_convert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isnt_convert: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | my ($thing) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | ▶ | return Test2::Compare::Undef->new() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | unless defined $thing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 4 | my $str = Test2::Compare::String->new(input => $thing, negate => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | sub like($$;$@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
like: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | my ($got, $exp, $name, @diag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | my $ctx = context(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | my $delta = compare($got, $exp, \&like_convert); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 4 | ▶ | if ($delta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | $ctx->fail($name, $delta->diag, @diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | $ctx->ok(1, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 4 | $ctx->release; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 4 | return !$delta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 3 | ▶ | sub unlike($$;$@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unlike: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | my ($got, $exp, $name, @diag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 3 | my $ctx = context(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 3 | my $delta = compare($got, $exp, \&unlike_convert); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | if ($delta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | $ctx->fail($name, $delta->diag, @diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | $ctx->ok(1, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | $ctx->release; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | return !$delta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | ▶ | sub like_convert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
like_convert: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | my ($thing) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | return Test2::Compare::Pattern->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | pattern => $thing, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | stringify_got => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 3 | ▶ | sub unlike_convert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unlike_convert: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | my ($thing) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 3 | return Test2::Compare::Pattern->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | negate => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | stringify_got => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | pattern => $thing, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 5 | ▶ | sub is_deeply($$;$@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_deeply: called CC=10 SCAR=40.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 5 | my ($got, $exp, $name, @diag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 5 | my $ctx = context(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | my @caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 5 | my $delta = compare($got, $exp, \&strict_convert); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | ▶ | if ($delta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # Temporary thing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $implicit = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my @deltas = ($delta); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | while (my $d = shift @deltas) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $add = $d->children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | push @deltas => @$add if $add && @$add; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$add and @$add
MC/DC0%0/2
$add and @$add
$add
@$add
Truth table0%0/3
A and B
A= $addB= @$add
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | next if $d->verified; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $count++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $implicit++ if $d->note && $d->note eq 'implicit end'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$d->note and $d->note eq "implicit end"
MC/DC0%0/2
$d->note and $d->note eq "implicit end"
$d->note
$d->note eq "implicit end"
Truth table0%0/3
A and B
A= $d->noteB= $d->note eq "implicit end"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if ($implicit == $count) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $ctx->ok(1, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | my $meth = $ENV{AUTHOR_TESTING} ? 'throw' : 'alert'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $type = $delta->render_check; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $ctx->$meth( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | join "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | "!!! NOTICE OF BEHAVIOR CHANGE !!!", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | "This test uses at least 1 $type check without using end() or etc().", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | "The existing behavior is to default to etc() when inside is_deeply().", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | "The new behavior is to default to end().", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | "This test will soon start to fail with the following diagnostics:", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | $delta->diag->as_string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $ctx->fail($name, $delta->diag, @diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 5 | $ctx->ok(1, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | $ctx->release; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 5 | return !$delta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 167 | our %OPS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | '==' => 'num', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | '!=' => 'num', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | '>=' => 'num', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | '<=' => 'num', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | '>' => 'num', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | '<' => 'num', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | '<=>' => 'num', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 'eq' => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 'ne' => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 'gt' => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 'lt' => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 'ge' => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 'le' => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 'cmp' => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | '!~' => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | '=~' => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | '&&' => 'logic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | '||' => 'logic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 'xor' => 'logic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 'or' => 'logic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 'and' => 'logic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | '//' => 'logic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | '&' => 'bitwise', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | '|' => 'bitwise', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | '~~' => 'match', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 15 | ▶ | sub cmp_ok($$$;$@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmp_ok: called CC=19 SCAR=29.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 15 | my ($got, $op, $exp, $name, @diag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 15 | my $ctx = context(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # Warnings and syntax errors should report to the cmp_ok call, not the test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # context. They may not be the same. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 15 | my ($pkg, $file, $line) = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 15 | my $type = $OPS{$op}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 15 | ▶ | if (!$type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | carp "operator '$op' is not supported (you can add it to %Test2::Tools::ClassicCompare::OPS)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | $type = 'unsupported'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 15 | local ($@, $!, $SIG{__DIE__}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 15 | my $test; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 15 | my $lived = eval <<" EOT"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | #line $line "(eval in cmp_ok) $file" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | \$test = (\$got $op \$exp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | EOT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 15 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 15 | ▶ | $ctx->send_event('Exception', error => $error) unless $lived; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 15 | ▶ | if ($test && $lived) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$test and $lived
MC/DC50%1/2
$test and $lived
$test
$lived
Truth table66%2/3
A and B
A= $testB= $lived
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 7 | $ctx->ok(1, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 7 | $ctx->release; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 7 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # Ugh, it failed. Do roughly the same thing Test::More did to try and show | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # diagnostics, but make it better by showing both the overloaded and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # unoverloaded form if overloading is in play. Also unoverload numbers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # Test::More only unoverloaded strings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 8 | my ($display_got, $display_exp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 8 | ▶ | if($type eq 'str') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | ▶ | $display_got = defined($got) ? "$got" : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | ▶ | $display_exp = defined($exp) ? "$exp" : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | elsif($type eq 'num') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 4 | ▶ | $display_got = defined($got) ? $got + 0 : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 4 | ▶ | $display_exp = defined($exp) ? $exp + 0 : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | else { # Well, we did what we could. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | $display_got = $got; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | $display_exp = $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 8 | ▶ | my $got_ref = ref($got) ? render_ref($got) : $got; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 8 | ▶ | my $exp_ref = ref($exp) ? render_ref($exp) : $exp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 8 | my @table; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 8 | ▶ | my $show_both = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition55%5/9
defined $got && $got_ref ne "$display_got" || defined $exp && $exp_ref ne "$display_exp"
defined $got and $got_ref ne "$display_got"
defined $exp and $exp_ref ne "$display_exp"
MC/DC25%1/4
defined $got && $got_ref ne "$display_got" || defined $exp && $exp_ref ne "$display_exp"
defined $got
$got_ref ne "$display_got"
defined $exp
$exp_ref ne "$display_exp"
Truth table28%2/7
A and B || C and D
A= defined $gotB= $got_ref ne "$display_got"C= defined $expD= $exp_ref ne "$display_exp"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | (defined($got) && $got_ref ne "$display_got") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | (defined($exp) && $exp_ref ne "$display_exp") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 8 | ▶ | if ($show_both) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 4 | ▶ | @table = table( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | header => ['TYPE', 'GOT', 'OP', 'CHECK'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | rows => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | [$type, $display_got, $op, $lived ? $display_exp : '<EXCEPTION>'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | ['orig', $got_ref, '', $exp_ref], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | ▶ | @table = table( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | header => ['GOT', 'OP', 'CHECK'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | rows => [[$display_got, $op, $lived ? $display_exp : '<EXCEPTION>']], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 8 | $ctx->ok(0, $name, [join("\n", @table), @diag]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 8 | $ctx->release; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 8 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 167 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||