Phonology/Segment/Tier.pm

filter: Statementstmt 75.4% 40 / 53 Branchbran 46.6% 14 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 3 totaltotal 63.5% 61 / 96 CC 19 SCAR 27.8
CC
19
Cov
65%
AUTOLOAD
28.8
err
6.0
new
5.4
CRAP 16.1
« Phonology/RuleParser.pm ↑ Summary Phonology/Symbols.pm »
1 #!/usr/bin/perl -w
2  
3 package Lingua::Phonology::Segment::Tier;
4  
5 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use Lingua::Phonology::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 our $VERSION = 0.11;
11  
12 0 ▶sub err ($) { _err($_[0]) if warnings::enabled() };
Subroutine err: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if warnings::enabled() 0 0 0
13  
14 135 ▶sub new {
Subroutine new: called CC=5 SCAR=16.8
Pod undocumented
15 135 my $proto = shift;
16  
17 # When called as an object method, return a regular segment
18 135 ▶ return $proto->[0]->new(@_) if ref $proto;
Branch: 1 branch
BranchTrueFalseTotal
if ref $proto 0 135 135
19  
20 135 ▶ return err "No segments given for pseudo-segment" if not @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 135 135
21 135 for (@_) {
22 141 ▶ _is_seg $_ or return;
Branch: 1 branch
BranchTrueFalseTotal
&_is_seg($_) or return 141 0 141
23 }
24 135 bless \@_, $proto;
25 }
26  
27  
28 # all_values() always returns the value C<< ( PSEUDO => 1 ) >>. This is mostly
29 # just useful to help Lingua::Phonology::Rules, so that it doesn't think that
30 # pseudo-segments are blank.
31  
32 0 ▶sub all_values {
Subroutine all_values: not called CC=1 SCAR=6.9
Pod undocumented
33 0 return ( PSEUDO => 1 );
34 }
35  
36 # This method ensures that we pass method calls to all encapsulated segs, but
37 # only return if all segs returned the same thing
38 8 our $AUTOLOAD;
39 282 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=14 SCAR=33.6
40 282 my $self = shift;
41 282 my $method = $AUTOLOAD;
42 282 $method =~ s/.*:://;
43  
44 # Pass everything through to the segments
45 282 my ($return, $disagree);
46 282 for (@$self) {
47 8 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 # Return value from current member of $self
50 294 my $this;
51  
52 # The following blocks ensure that we provide the proper context to the
53 # method calls
54  
55 # Array context
56 294 ▶ if (wantarray) {
Branch: 2 branches
BranchTrueFalseTotal
if (wantarray) { } 0 294 294
elsif (defined wantarray) { } 270 24 294
57 0 $this = [ $_->$method(@_) ];
58 0 ▶ next if $disagree;
Branch: 1 branch
BranchTrueFalseTotal
if $disagree 0 0 0
59  
60 0 ▶ if (not $return) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $return) { } 0 0 0
61 0 $return = $this;
62 }
63 # Check that we're the same for every element of the returned list
64 else {
65 0 ▶ if (@$this != @$return) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$this != @$return) { } 0 0 0
66 0 $disagree = 1;
67 }
68  
69 else {
70 0 for (0 .. $#{$this}) {
71 0 ▶ if ($this->[$_] ne $return->[$_]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->[$_] ne $return->[$_]) 0 0 0
72 0 $disagree = 1;
73 0 last;
74 }
75 }
76 }
77 }
78 }
79  
80 # Scalar context
81 elsif (defined wantarray) {
82 270 $this = $_->$method(@_);
83 270 ▶ next if $disagree;
Branch: 1 branch
BranchTrueFalseTotal
if $disagree 0 270 270
84  
85 270 ▶ if (not defined $return) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $return) { } 262 8 270
86 262 $return = $this;
87 }
88 else {
89 8 ▶ $disagree = 1 if $return ne $this;
Branch: 1 branch
BranchTrueFalseTotal
if $return ne $this 1 7 8
90 }
91 }
92  
93 # Void context
94 else {
95 24 $_->$method(@_);
96 }
97  
98 }
99  
100 282 ▶ return if $disagree;
Branch: 1 branch
BranchTrueFalseTotal
if $disagree 1 281 282
101 281 ▶ return @$return if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 281 281
102 281 return $return;
103 }
104  
105 # Don't pass on DESTROY
106 0 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
107  
108 8 1;
« Phonology/RuleParser.pm ↑ Summary Phonology/Symbols.pm »