| 1 | 49 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 49 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package YAML::PP::Representer; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 49 | our $VERSION = 'v0.43.0'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 49 | ▶ | use Scalar::Util qw/ reftype blessed refaddr /; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 49 | ▶ | use YAML::PP::Common qw/ | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | YAML_PLAIN_SCALAR_STYLE YAML_SINGLE_QUOTED_SCALAR_STYLE | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | YAML_DOUBLE_QUOTED_SCALAR_STYLE | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | YAML_ANY_SCALAR_STYLE | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | YAML_LITERAL_SCALAR_STYLE YAML_FOLDED_SCALAR_STYLE | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | YAML_FLOW_SEQUENCE_STYLE YAML_FLOW_MAPPING_STYLE | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | YAML_BLOCK_MAPPING_STYLE YAML_BLOCK_SEQUENCE_STYLE | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | PRESERVE_ORDER PRESERVE_SCALAR_STYLE PRESERVE_FLOW_STYLE PRESERVE_ALIAS | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 49 | /; | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | 49 | ▶ | use B; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 764 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 764 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | 764 | ▶ | my $preserve = delete $args{preserve} || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{'preserve'} || 0
MC/DC100%1/1
delete $args{'preserve'} || 0
delete $args{'preserve'}
Truth table100%2/2
A
A= delete $args{'preserve'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 764 | ▶ | if ($preserve == 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | $preserve = PRESERVE_ORDER | PRESERVE_SCALAR_STYLE | PRESERVE_FLOW_STYLE | PRESERVE_ALIAS; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | schema => delete $args{schema}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 764 | preserve => $preserve, | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 764 | ▶ | if (keys %args) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | die "Unexpected arguments: " . join ', ', sort keys %args; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 764 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 9 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | my $clone = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | schema => $self->schema, | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | preserve => $self->{preserve}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 9 | return bless $clone, ref $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3959 | ▶ | sub schema { return $_[0]->{schema} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
schema: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 458 | ▶ | sub preserve_order { return $_[0]->{preserve} & PRESERVE_ORDER } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preserve_order: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 3817 | ▶ | sub preserve_scalar_style { return $_[0]->{preserve} & PRESERVE_SCALAR_STYLE } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preserve_scalar_style: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 724 | ▶ | sub preserve_flow_style { return $_[0]->{preserve} & PRESERVE_FLOW_STYLE } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preserve_flow_style: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 3888 | ▶ | sub preserve_alias { return $_[0]->{preserve} & PRESERVE_ALIAS } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preserve_alias: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 3817 | ▶ | sub represent_node { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
represent_node: called CC=26 SCAR=32.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 3817 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 3817 | my $preserve_alias = $self->preserve_alias; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 3817 | my $preserve_style = $self->preserve_scalar_style; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 3817 | ▶ | if ($preserve_style or $preserve_alias) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$preserve_style or $preserve_alias
MC/DC100%2/2
$preserve_style or $preserve_alias
$preserve_style
$preserve_alias
Truth table100%3/3
A or B
A= $preserve_styleB= $preserve_alias
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 131 | ▶ | if (ref $node->{value} eq 'YAML::PP::Preserve::Scalar') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 87 | my $value = $node->{value}->value; | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | 87 | ▶ | if ($preserve_style) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 21 | $node->{style} = $node->{value}->style; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # $node->{tag} = $node->{value}->tag; | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 87 | $node->{value} = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 3817 | $node->{reftype} = reftype($node->{value}); | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3817 | ▶ | if (not $node->{reftype} and reftype(\$node->{value}) eq 'GLOB') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $node->{"reftype"} and builtin::reftype(\$node->{"value"}) eq "GLOB"
MC/DC100%2/2
not $node->{"reftype"} and builtin::reftype(\$node->{"value"}) eq "GLOB"
not $node->{"reftype"}
builtin::reftype(\$node->{"value"}) eq "GLOB"
Truth table100%3/3
not(A) and B
A= not $node->{"reftype"}B= builtin::reftype(\$node->{"value"}) eq "GLOB"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 6 | $node->{reftype} = 'GLOB'; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3817 | ▶ | if ($node->{reftype}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 807 | $self->_represent_noderef($node); | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 3010 | $self->_represent_node_nonref($node); | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 3817 | ▶ | $node->{reftype} = (reftype $node->{data}) || ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
builtin::reftype($node->{'data'}) || ''
MC/DC100%1/1
builtin::reftype($node->{'data'}) || ''
builtin::reftype($node->{'data'})
Truth table100%2/2
A
A= builtin::reftype($node->{'data'})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 3817 | ▶ | if ($node->{reftype} eq 'HASH' and my $tied = tied(%{ $node->{data} })) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$node->{"reftype"} eq "HASH" and my $tied = tied %{$$node{"data"};}
MC/DC100%2/2
$node->{"reftype"} eq "HASH" and my $tied = tied %{$$node{"data"};}
$node->{"reftype"} eq "HASH"
my $tied = tied %{$$node{"data"};}
Truth table100%3/3
A and B
A= $node->{"reftype"} eq "HASH"B= my $tied = tied %{$$node{"data"};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 34 | my $representers = $self->schema->representers; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 34 | $tied = ref $tied; | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | 34 | ▶ | if (my $def = $representers->{tied_equals}->{ $tied }) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $code = $def->{code}; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $done = $code->($self, $node); | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 3817 | ▶ | if ($node->{reftype} eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 458 | ▶ | unless (defined $node->{items}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # by default we sort hash keys | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 458 | my @keys; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 458 | ▶ | if ($self->preserve_order) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 24 | @keys = keys %{ $node->{data} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 434 | @keys = sort keys %{ $node->{data} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 458 | for my $key (@keys) { | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | 876 | push @{ $node->{items} }, $key, $node->{data}->{ $key }; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 458 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 458 | ▶ | if ($self->preserve_flow_style and reftype $node->{value} eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->preserve_flow_style and builtin::reftype($node->{"value"}) eq "HASH"
MC/DC50%1/2
$self->preserve_flow_style and builtin::reftype($node->{"value"}) eq "HASH"
$self->preserve_flow_style
builtin::reftype($node->{"value"}) eq "HASH"
Truth table66%2/3
A and B
A= $self->preserve_flow_styleB= builtin::reftype($node->{"value"}) eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 19 | ▶ | if (my $tied = tied %{ $node->{value} } ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 18 | $args{style} = $tied->{style}; | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 458 | return [ mapping => $node, %args ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | elsif ($node->{reftype} eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 266 | ▶ | unless (defined $node->{items}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 266 | @{ $node->{items} } = @{ $node->{data} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 266 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 266 | ▶ | if ($self->preserve_flow_style and reftype $node->{value} eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->preserve_flow_style and builtin::reftype($node->{"value"}) eq "ARRAY"
MC/DC50%1/2
$self->preserve_flow_style and builtin::reftype($node->{"value"}) eq "ARRAY"
$self->preserve_flow_style
builtin::reftype($node->{"value"}) eq "ARRAY"
Truth table66%2/3
A and B
A= $self->preserve_flow_styleB= builtin::reftype($node->{"value"}) eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 10 | ▶ | if (my $tied = tied @{ $node->{value} } ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 10 | $args{style} = $tied->{style}; | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 266 | return [ sequence => $node, %args ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | elsif ($node->{reftype}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | die "Cannot handle reftype '$node->{reftype}' (you might want to enable YAML::PP::Schema::Perl)"; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3092 | ▶ | unless (defined $node->{items}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 3026 | $node->{items} = [$node->{data}]; | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3092 | return [ scalar => $node ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 49 | my $bool_code = <<'EOM'; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | my ($x) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | use experimental qw/ builtin /; | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | builtin::is_bool($x); | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | EOM | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 49 | my $is_bool; | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3010 | ▶ | sub _represent_node_nonref { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_represent_node_nonref: called CC=18 SCAR=29.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 3010 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3010 | my $representers = $self->schema->representers; | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 3010 | ▶ | if (not defined $node->{value}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 110 | ▶ | if (my $undef = $representers->{undef}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 110 | ▶ | return 1 if $undef->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $node->{style} = YAML_SINGLE_QUOTED_SCALAR_STYLE; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $node->{data} = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2900 | ▶ | if ($] >= 5.036000 and my $rep = $representers->{bool}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$] >= "5.036" and my $rep = $representers->{"bool"}
MC/DC50%1/2
$] >= "5.036" and my $rep = $representers->{"bool"}
$] >= "5.036"
my $rep = $representers->{"bool"}
Truth table66%2/3
A and B
A= $] >= "5.036"B= my $rep = $representers->{"bool"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 748 | ▶ | $is_bool ||= eval $bool_code; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Condition66%2/3
$is_bool ||= eval $bool_code
MC/DC0%0/2
$is_bool ||= eval $bool_code
$is_bool
eval $bool_code
Truth table66%2/3
A ||= B
A= $is_boolB= eval $bool_code
| |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 748 | ▶ | if ($is_bool->($node->{value})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | return $rep->{code}->($self, $node); | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2898 | for my $rep (@{ $representers->{flags} }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | 4969 | my $check_flags = $rep->{flags}; | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | 4969 | my $flags = B::svref_2object(\$node->{value})->FLAGS; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | 4969 | ▶ | if ($flags & $check_flags) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 517 | ▶ | return 1 if $rep->{code}->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2392 | ▶ | if (my $rep = $representers->{equals}->{ $node->{value} }) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 138 | ▶ | return 1 if $rep->{code}->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2254 | for my $rep (@{ $representers->{regex} }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | 2050 | ▶ | if ($node->{value} =~ $rep->{regex}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 101 | ▶ | return 1 if $rep->{code}->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2159 | ▶ | unless (defined $node->{data}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2159 | $node->{data} = $node->{value}; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2159 | ▶ | unless (defined $node->{style}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2143 | $node->{style} = YAML_ANY_SCALAR_STYLE; | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2143 | $node->{style} = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 807 | ▶ | sub _represent_noderef { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_represent_noderef: called CC=24 SCAR=33.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 807 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | 807 | my $representers = $self->schema->representers; | |||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 807 | ▶ | if (my $classname = blessed($node->{value})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 112 | ▶ | if (my $def = $representers->{class_equals}->{ $classname }) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 66 | my $code = $def->{code}; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | 66 | ▶ | return 1 if $code->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 46 | for my $matches (@{ $representers->{class_matches} }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | 43 | my ($re, $code) = @$matches; | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 43 | ▶ | if (ref $re and $classname =~ $re or $re) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $re and $classname =~ /$re/ or $re
ref $re and $classname =~ /$re/
MC/DC0%0/3
ref $re and $classname =~ /$re/ or $re
ref $re
$classname =~ /$re/
$re
Truth table20%1/5
A and B or C
A= ref $reB= $classname =~ /$re/C= $re
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 43 | ▶ | return 1 if $code->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | for my $isa (@{ $representers->{class_isa} }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | 3 | my ($class_name, $code) = @$isa; | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | ▶ | if ($node->{ value }->isa($class_name)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | ▶ | return 1 if $code->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 697 | ▶ | if ($node->{reftype} eq 'SCALAR' and my $scalarref = $representers->{scalarref}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$node->{"reftype"} eq "SCALAR" and my $scalarref = $representers->{"scalarref"}
MC/DC100%2/2
$node->{"reftype"} eq "SCALAR" and my $scalarref = $representers->{"scalarref"}
$node->{"reftype"} eq "SCALAR"
my $scalarref = $representers->{"scalarref"}
Truth table100%3/3
A and B
A= $node->{"reftype"} eq "SCALAR"B= my $scalarref = $representers->{"scalarref"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 4 | my $code = $scalarref->{code}; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 4 | ▶ | return 1 if $code->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 693 | ▶ | if ($node->{reftype} eq 'REF' and my $refref = $representers->{refref}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$node->{"reftype"} eq "REF" and my $refref = $representers->{"refref"}
MC/DC50%1/2
$node->{"reftype"} eq "REF" and my $refref = $representers->{"refref"}
$node->{"reftype"} eq "REF"
my $refref = $representers->{"refref"}
Truth table66%2/3
A and B
A= $node->{"reftype"} eq "REF"B= my $refref = $representers->{"refref"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 4 | my $code = $refref->{code}; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | 4 | ▶ | return 1 if $code->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 689 | ▶ | if ($node->{reftype} eq 'CODE' and my $coderef = $representers->{coderef}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$node->{"reftype"} eq "CODE" and my $coderef = $representers->{"coderef"}
MC/DC50%1/2
$node->{"reftype"} eq "CODE" and my $coderef = $representers->{"coderef"}
$node->{"reftype"} eq "CODE"
my $coderef = $representers->{"coderef"}
Truth table66%2/3
A and B
A= $node->{"reftype"} eq "CODE"B= my $coderef = $representers->{"coderef"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | my $code = $coderef->{code}; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | ▶ | return 1 if $code->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 684 | ▶ | if ($node->{reftype} eq 'GLOB' and my $glob = $representers->{glob}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$node->{"reftype"} eq "GLOB" and my $glob = $representers->{"glob"}
MC/DC50%1/2
$node->{"reftype"} eq "GLOB" and my $glob = $representers->{"glob"}
$node->{"reftype"} eq "GLOB"
my $glob = $representers->{"glob"}
Truth table66%2/3
A and B
A= $node->{"reftype"} eq "GLOB"B= my $glob = $representers->{"glob"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 6 | my $code = $glob->{code}; | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 6 | ▶ | return 1 if $code->($self, $node); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 678 | $node->{data} = $node->{value}; | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 49 | 1; | |||||||||||||||||||||||||||||||||||||||||||||