| 1 | package Test::HexDifferences; ## no critic (TidyCode) | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Sub::Exporter -setup => { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | exports => [ | ||||||||||||||||||||||||||||||||||
| 8 | qw(eq_or_dump_diff dumped_eq_dump_or_diff), | ||||||||||||||||||||||||||||||||||
| 9 | ], | ||||||||||||||||||||||||||||||||||
| 10 | groups => { | ||||||||||||||||||||||||||||||||||
| 11 | default => [ qw(eq_or_dump_diff dumped_eq_dump_or_diff) ], | ||||||||||||||||||||||||||||||||||
| 12 | }, | ||||||||||||||||||||||||||||||||||
| 13 | 3 | }; | |||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use Test::Builder::Module; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use Test::HexDifferences::HexDump qw(hex_dump); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use Text::Diff qw(diff); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | 3 | our $VERSION = '1.001'; | |||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | 3 | my $builder = Test::Builder->new; | |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | 3 | my %diff_arg_of = ( | |||||||||||||||||||||||||||||||||
| 23 | STYLE => 'Table', | ||||||||||||||||||||||||||||||||||
| 24 | INDEX_LABEL => 'Ln', | ||||||||||||||||||||||||||||||||||
| 25 | FILENAME_A => 'Got', | ||||||||||||||||||||||||||||||||||
| 26 | FILENAME_B => 'Expected', | ||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | sub eq_or_dump_diff ($$;$$) { ## no critic (SubroutinePrototypes) | ||||||||||||||||||||||||||||||||
|
Subroutine
eq_or_dump_diff: called CC=13 SCAR=27.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 30 | 4 | my ($got, $expected, @more) = @_; | |||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 4 | ▶ | my $attr_ref | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@more and ref $more[0] eq "HASH"
MC/DC0%0/2
@more and ref $more[0] eq "HASH"
@more
ref $more[0] eq "HASH"
Truth table33%1/3
A and B
A= @moreB= ref $more[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||
| 33 | = ( @more && ref $more[0] eq 'HASH' ) | ||||||||||||||||||||||||||||||||||
| 34 | ? shift @more | ||||||||||||||||||||||||||||||||||
| 35 | : (); | ||||||||||||||||||||||||||||||||||
| 36 | 4 | ▶ | my $both_undefined | ||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $got || defined $expected
MC/DC0%0/2
defined $got || defined $expected
defined $got
defined $expected
Truth table66%2/3
A || B
A= defined $gotB= defined $expected
| |||||||||||||||||||||||||||||||||||
| 37 | = ! defined $got | ||||||||||||||||||||||||||||||||||
| 38 | && ! defined $expected; | ||||||||||||||||||||||||||||||||||
| 39 | 4 | ▶ | my $any_undefined | ||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $got && defined $expected
MC/DC100%2/2
defined $got && defined $expected
defined $got
defined $expected
Truth table100%3/3
A && B
A= defined $gotB= defined $expected
| |||||||||||||||||||||||||||||||||||
| 40 | = ! defined $got | ||||||||||||||||||||||||||||||||||
| 41 | || ! defined $expected; | ||||||||||||||||||||||||||||||||||
| 42 | 4 | ▶ | if ( $both_undefined || $any_undefined ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$both_undefined or $any_undefined
MC/DC50%1/2
$both_undefined or $any_undefined
$both_undefined
$any_undefined
Truth table66%2/3
A or B
A= $both_undefinedB= $any_undefined
| |||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | my $result | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
$both_undefined || !$any_undefined && $got eq $expected
not $any_undefined and $got eq $expected
MC/DC0%0/3
$both_undefined || !$any_undefined && $got eq $expected
$both_undefined
not $any_undefined
$got eq $expected
Truth table25%1/4
A || not(B) and C
A= $both_undefinedB= not $any_undefinedC= $got eq $expected
| |||||||||||||||||||||||||||||||||||
| 44 | = $both_undefined | ||||||||||||||||||||||||||||||||||
| 45 | || ! $any_undefined && $got eq $expected; | ||||||||||||||||||||||||||||||||||
| 46 | 2 | ▶ | $got = defined $got ? $got : 'undef'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | $expected = defined $expected ? $expected : 'undef'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | my $ok = $builder->ok($result, $more[0]) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 49 | or $builder->diag( | ||||||||||||||||||||||||||||||||||
| 50 | diff( | ||||||||||||||||||||||||||||||||||
| 51 | \$got, | ||||||||||||||||||||||||||||||||||
| 52 | \$expected, | ||||||||||||||||||||||||||||||||||
| 53 | \%diff_arg_of, | ||||||||||||||||||||||||||||||||||
| 54 | ), | ||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||
| 56 | 2 | return $ok; | |||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||
| 58 | 2 | ▶ | my $ok = $builder->ok($got eq $expected, $more[0]) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 59 | or $builder->diag( | ||||||||||||||||||||||||||||||||||
| 60 | diff( | ||||||||||||||||||||||||||||||||||
| 61 | \hex_dump($got, $attr_ref), | ||||||||||||||||||||||||||||||||||
| 62 | \hex_dump($expected, $attr_ref), | ||||||||||||||||||||||||||||||||||
| 63 | \%diff_arg_of, | ||||||||||||||||||||||||||||||||||
| 64 | ), | ||||||||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | 2 | return $ok; | |||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | 4 | ▶ | sub dumped_eq_dump_or_diff ($$;$$) { ## no critic (SubroutinePrototypes) | ||||||||||||||||||||||||||||||||
|
Subroutine
dumped_eq_dump_or_diff: called CC=7 SCAR=20.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 71 | 4 | my ($got, $expected_dump, @more) = @_; | |||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | 4 | ▶ | my $attr_ref | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@more and ref $more[0] eq "HASH"
MC/DC0%0/2
@more and ref $more[0] eq "HASH"
@more
ref $more[0] eq "HASH"
Truth table33%1/3
A and B
A= @moreB= ref $more[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||
| 74 | = ( @more && ref $more[0] eq 'HASH' ) | ||||||||||||||||||||||||||||||||||
| 75 | ? shift @more | ||||||||||||||||||||||||||||||||||
| 76 | : (); | ||||||||||||||||||||||||||||||||||
| 77 | 4 | ▶ | $got = defined $got | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 78 | ? hex_dump($got, $attr_ref) | ||||||||||||||||||||||||||||||||||
| 79 | : 'undef'; | ||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | $expected_dump = defined $expected_dump | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 81 | ? $expected_dump | ||||||||||||||||||||||||||||||||||
| 82 | : 'undef'; | ||||||||||||||||||||||||||||||||||
| 83 | 4 | ▶ | $expected_dump = defined $expected_dump ? $expected_dump : q{}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 84 | 4 | ▶ | my $ok = $builder->ok($got eq $expected_dump, $more[0]) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 85 | or $builder->diag( | ||||||||||||||||||||||||||||||||||
| 86 | diff( | ||||||||||||||||||||||||||||||||||
| 87 | \$got, | ||||||||||||||||||||||||||||||||||
| 88 | \$expected_dump, | ||||||||||||||||||||||||||||||||||
| 89 | \%diff_arg_of, | ||||||||||||||||||||||||||||||||||
| 90 | ), | ||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||
| 93 | 4 | return $ok; | |||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | # $Id$ | ||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | 3 | 1; | |||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||
| 100 | __END__ | ||||||||||||||||||||||||||||||||||