| 1 | package Treex::PML::Schema::Derive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | $VERSION='2.29'; # version template | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 9 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use Treex::PML::Schema::Constants; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 9 | ▶ | use base qw(Treex::PML::Schema::XMLNode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub get_decl_type { return(PML_DERIVE_DECL); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_decl_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub get_decl_type_str { return('derive'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_decl_type_str: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 18 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 18 | my ($derive,$opts)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 18 | ▶ | if (!exists($derive->{type})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | die "<derive> must have a type attribute\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 18 | ▶ | if (!exists($derive->{name})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 16 | $derive->{name}=$derive->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 18 | ▶ | sub simplify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
simplify: called CC=51 SCAR=47.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 18 | my ($derive,$opts)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 18 | ▶ | $derive->{name} ||= $derive->{-name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$derive->{"name"} ||= $derive->{"-name"}
MC/DC0%0/2
$derive->{"name"} ||= $derive->{"-name"}
$derive->{"name"}
$derive->{"-name"}
Truth table33%1/3
A ||= B
A= $derive->{"name"}B= $derive->{"-name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 18 | my $schema = $derive->{-parent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | return if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | (($schema->get_decl_type == PML_TEMPLATE_DECL and $opts->{no_template_derive}) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 18 | ▶ | ($schema->get_decl_type == PML_SCHEMA_DECL and $opts->{no_derive})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$schema->get_decl_type == 22 and $opts->{"no_template_derive"} or $schema->get_decl_type == 14 and $opts->{"no_derive"}
$schema->get_decl_type == 22 and $opts->{"no_template_derive"}
$schema->get_decl_type == 14 and $opts->{"no_derive"}
MC/DC0%0/4
$schema->get_decl_type == 22 and $opts->{"no_template_derive"} or $schema->get_decl_type == 14 and $opts->{"no_derive"}
$schema->get_decl_type == 22
$opts->{"no_template_derive"}
$schema->get_decl_type == 14
$opts->{"no_derive"}
Truth table28%2/7
A and B or C and D
A= $schema->get_decl_type == 22B= $opts->{"no_template_derive"}C= $schema->get_decl_type == 14D= $opts->{"no_derive"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 18 | my $name = $derive->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 18 | my $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 18 | my $source = $derive->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 18 | ▶ | unless (defined($source) and length($source)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $source and length $source
MC/DC0%0/2
defined $source and length $source
defined $source
length $source
Truth table33%1/3
A and B
A= defined $sourceB= length $source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | croak "Derive must specify source type in the attribute 'type' in $schema->{URL}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 18 | ▶ | if (defined($name) and length($name)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and length $name
MC/DC0%0/2
defined $name and length $name
defined $name
length $name
Truth table33%1/3
A and B
A= defined $nameB= length $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 18 | ▶ | if (exists ($schema->{type}{$name}) and $source ne $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $schema->{"type"}{$name} and $source ne $name
MC/DC0%0/2
exists $schema->{"type"}{$name} and $source ne $name
exists $schema->{"type"}{$name}
$source ne $name
Truth table66%2/3
A and B
A= exists $schema->{"type"}{$name}B= $source ne $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | croak "Refusing to derive already existing type '$name' from '$source' in $schema->{URL}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 18 | $type = $schema->{type}{$name} = $schema->copy_decl($schema->{type}{$source}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 18 | $type->{-name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $name = $source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $type = $schema->{type}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # deriving possible for structures, sequences and choices | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 18 | ▶ | if ($derive->{structure}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 7 | ▶ | if ($type->{structure}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 7 | my $derive_structure = $derive->{structure}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 7 | my $target_structure = $type->{structure}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 7 | foreach my $attr (qw(role name)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 14 | ▶ | if (exists $derive_structure->{$attr}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | $target_structure->{$attr} = $derive_structure->{$attr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | push @{$target_structure->{-attributes}},$attr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 3 | ▶ | unless grep { $_ eq $attr } @{$target_structure->{-attributes}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 7 | ▶ | $target_structure->{member} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$target_structure->{"member"} ||= {}
MC/DC0%0/1
$target_structure->{"member"} ||= {}
$target_structure->{"member"}
Truth table50%1/2
A
A= $target_structure->{"member"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 7 | my $members = $target_structure->{member}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 7 | ▶ | while (my ($member,$value) = each %{$derive_structure->{member}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 9 | $members->{$member} = $target_structure->copy_decl($value); # FIXME: no need if we remove derives in the end | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 7 | ▶ | if (ref $derive_structure->{delete}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | for my $member (@{$derive_structure->{delete}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | delete $members->{$member}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | croak "Cannot derive structure type '$name' from a non-structure '$source'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } elsif ($derive->{sequence}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | if ($type->{sequence}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | my $derive_sequence = $derive->{sequence}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | my $target_sequence = $type->{sequence}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | if (exists $derive_sequence->{role}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $target_sequence->{role} = $derive_sequence->{role}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | push @{$target_sequence->{-attributes}},'role' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | unless grep { $_ eq 'role' } @{$target_sequence->{-attributes}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | ▶ | if (exists $derive_sequence->{content_pattern}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | $target_sequence->{content_pattern} = $derive_sequence->{content_pattern}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | push @{$target_sequence->{-attributes}},'content_pattern' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | ▶ | unless grep { $_ eq 'content_pattern' } @{$target_sequence->{-attributes}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | $target_sequence->{element} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$target_sequence->{"element"} ||= {}
MC/DC0%0/1
$target_sequence->{"element"} ||= {}
$target_sequence->{"element"}
Truth table50%1/2
A
A= $target_sequence->{"element"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | my $elements = $target_sequence->{element}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | while (my ($element,$value) = each %{$derive_sequence->{element}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | $elements->{$element} = $target_sequence->copy_decl($value); # FIXME: no need if we remove derives in the end | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | if (ref $derive_sequence->{delete}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | for my $element (@{$derive_sequence->{delete}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | delete $elements->{$element}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # print STDERR Data::Dumper::Dumper([$type]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | croak "Cannot derive sequence type '$name' from a non-sequence '$source'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } elsif ($derive->{container}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 7 | ▶ | if ($type->{container}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 7 | my $derive_container = $derive->{container}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 7 | my $target_container = $type->{container}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 7 | for my $attr (qw(type role)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 14 | ▶ | next unless exists $derive_container->{$attr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | if ($attr eq 'type' and !exists($target_container->{type})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$attr eq "type" and not exists $target_container->{"type"}
MC/DC50%1/2
$attr eq "type" and not exists $target_container->{"type"}
$attr eq "type"
not exists $target_container->{"type"}
Truth table66%2/3
A and not(B)
A= $attr eq "type"B= not exists $target_container->{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | foreach my $d (qw(list alt structure container sequence cdata)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 6 | ▶ | if (exists $target_container->{$d}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | delete $target_container->{$d}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | delete $target_container->{-decl}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | delete $target_container->{-resolved}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | $target_container->{$attr} = $derive_container->{$attr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | push @{$target_container->{-attributes}},$attr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | ▶ | unless grep { $_ eq $attr } @{$target_container->{-attributes}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 7 | ▶ | $target_container->{attribute} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$target_container->{"attribute"} ||= {}
MC/DC100%1/1
$target_container->{"attribute"} ||= {}
$target_container->{"attribute"}
Truth table100%2/2
A
A= $target_container->{"attribute"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 7 | my $attributes = $target_container->{attribute}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 7 | ▶ | while (my ($attribute,$value) = each %{$derive_container->{attribute}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 7 | $attributes->{$attribute} = $target_container->copy_decl($value); # FIXME: no need if we remove derives in the end | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 7 | ▶ | if (ref $derive_container->{delete}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | for my $attribute (@{$derive_container->{delete}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | delete $attributes->{$attribute}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | croak "Cannot derive a container '$name' from a different type '$source'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } elsif ($derive->{choice}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | my $choice = $derive->{choice}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | ▶ | if ($type->{choice}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | my (@add,%delete); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | ▶ | if (UNIVERSAL::isa($choice,'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | ▶ | @add = @{$choice->{values}} if ref $choice->{values}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | ▶ | @delete{ @{$choice->{delete}} }=() if ref $choice->{delete}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | @add = @$choice; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | @{$type->{choice}{values}} = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | ▶ | grep { !($seen{$_}++) and ! exists $delete{$_} } (@{$type->{choice}{values}},@add); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$seen{$_}++ || exists $delete{$_}
MC/DC50%1/2
$seen{$_}++ || exists $delete{$_}
$seen{$_}++
exists $delete{$_}
Truth table66%2/3
A || B
A= $seen{$_}++B= exists $delete{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | croak "Cannot derive a choice type '$name' from a non-choice type '$source'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | unless ($name ne $source) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | croak "<derive type='$source'> has no effect in $schema->{URL}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||