| 1 | # ABSTRACT: What the POD of a module says about each of its subs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # PODNAME: Pod::Coverage::More::Documentation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package Pod::Coverage::More::Documentation 0.005; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use 5.036; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 15 | ▶ | use warnings FATAL => q{all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 15 | ▶ | use re q{/xsaa}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use List::Util qw{any}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use Pod::Simple::SimpleTree; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 15 | ▶ | use Types::Standard qw{Bool InstanceOf Int Str Undef}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 15 | ▶ | use Pod::Coverage::More::Types qw{type_named}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # A reader of POD. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # @param subs ArrayRef[Str] optional: the names of the subs of the package, which tell the headings that document subs from the others | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # @returns Pod::Coverage::More::Documentation the reader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # @example my $doc = Pod::Coverage::More::Documentation->new( subs => [ 'resize', 'crop' ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 56 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 56 | my ( $class, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 56 | ▶ | return bless( { subs => $args{subs} ? { map { $_ => 1 } @{ $args{subs} } } : undef, sections => [] }, $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # Reads the POD of C<file>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # @param file Str the path of the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # @returns Pod::Coverage::More::Documentation the reader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # @example my $doc = Pod::Coverage::More::Documentation->new->parse_file('lib/Some/Module.pm'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 33 | ▶ | sub parse_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 33 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 33 | return $self->_read( _parser()->parse_file($file)->root ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # Reads the POD in the string C<pod>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # @param pod Str the POD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # @returns Pod::Coverage::More::Documentation the reader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # @example my $doc = Pod::Coverage::More::Documentation->new->parse_string($pod); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 23 | ▶ | sub parse_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 23 | my ( $self, $pod ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 23 | return $self->_read( _parser()->parse_string_document($pod)->root ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # The sections, in the order of the POD, as SECTIONS describes them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # @returns the sections, as a list of HASHREFs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # @example my @headings = map { $_->{heading} } $doc->sections; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | sub sections { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sections: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 6 | return @{ $self->{sections} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # The section whose heading names the sub C<name>, or nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # A heading that writes it as a call, as C<name(...)>, C<< $obj->name >> or C<Pkg::name>, comes before one that writes only its bare name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # then a shallower heading before a deeper one, then the first in the POD. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # @param name Str the name of the sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # @returns HashRef the section | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # @example my $section = $doc->section_for('resize'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 598 | ▶ | sub section_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
section_for: called CC=8 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 598 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 598 | my $best; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 598 | foreach my $section ( @{ $self->{sections} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 16974 | ▶ | my $strength = $section->{strength}{$name} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 537 | ▶ | $best = $section if !$best || $strength > $best->{strength}{$name} || ( $strength == $best->{strength}{$name} && $section->{level} < $best->{level} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
not $best or $strength > $best->{"strength"}{$name} or $strength == $best->{"strength"}{$name} and $section->{"level"} < $best->{"level"}
not $best or $strength > $best->{"strength"}{$name}
$strength == $best->{"strength"}{$name} and $section->{"level"} < $best->{"level"}
MC/DC0%0/4
not $best or $strength > $best->{"strength"}{$name} or $strength == $best->{"strength"}{$name} and $section->{"level"} < $best->{"level"}
not $best
$strength > $best->{"strength"}{$name}
$strength == $best->{"strength"}{$name}
$section->{"level"} < $best->{"level"}
Truth table60%3/5
not(A) or B or C and D
A= not $bestB= $strength > $best->{"strength"}{$name}C= $strength == $best->{"strength"}{$name}D= $section->{"level"} < $best->{"level"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 598 | ▶ | return $best if $best; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 63 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # The names of all the subs that the headings name, which L<Pod::Coverage> counts as documented. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # @returns the names, as a list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # @example my @documented = $doc->identifiers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 16 | ▶ | sub identifiers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
identifiers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 16 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 16 | return map { @{ $_->{functions} } } @{ $self->{sections} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 56 | ▶ | sub _parser { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parser: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 56 | my $parser = Pod::Simple::SimpleTree->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 56 | $parser->accept_directive_as_processed(qw{method func attr}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 56 | return $parser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # A type word or a parameterized type expression, such as Str, Types::Standard::Int or ArrayRef[HashRef[Str]]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 15 | our $TYPE_NAME = qr/[[:alpha:]_]\w*(?:::\w+)*/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 15 | our $TYPE_PARAMS = qr/(?<params>\[(?:[^\[\]]++|(?¶ms))*\])/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # The words of a paragraph that says how a sub terminates. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 15 | our @TERMINATION_WORDS = qw{die dies died croak croaks croaked confess confesses confessed throw throws exception exceptions exit exits exited}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 15 | our $TERMINATION = do { my $words = join q{|}, @TERMINATION_WORDS; qr/\b(?:$words|terminat\w*)\b/i }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # A class name, maybe quoted, as prose names the class of a returned object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 15 | our $CLASS_NAME = qr/['"]?([\w:]+)['"]?/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # A class name that starts with a capital, followed by "object" or "instance", as in "a new Foo object". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 15 | our $CLASS_OBJECT = qr/(?-i:(?=['"]?[[:upper:]]))$CLASS_NAME\s+(?:object|instance)\b/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 15 | our %LEVEL = ( head1 => 1, head2 => 2, head3 => 3, head4 => 4, method => 2, func => 2, attr => 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 56 | ▶ | sub _read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 56 | my ( $self, $root ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 56 | my ( undef, undef, @nodes ) = @$root; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 56 | my $current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 56 | foreach my $node (@nodes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 897 | ▶ | next if !ref $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 897 | my $type = $node->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 897 | my $level = $LEVEL{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 897 | ▶ | if ($level) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 352 | my $text = _flatten($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 352 | ▶ | my $section = $level > 1 ? $self->_heading( $text, $node->[1]{start_line} ) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 352 | ▶ | if ( $section && ( !$self->{subs} || any { $self->{subs}{$_} } @{ $section->{functions} } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition100%6/6
$section and !$self->{"subs"} || &any(sub {
$self->{"subs"}{$_};
}
, @{$$section{"functions"};})
not $self->{"subs"} or &any(sub {
$self->{"subs"}{$_};
}
, @{$$section{"functions"};})
MC/DC100%3/3
$section and !$self->{"subs"} || &any(sub {
$self->{"subs"}{$_};
}
, @{$$section{"functions"};})
$section
not $self->{"subs"}
&any(sub {
$self->{"subs"}{$_};
}
, @{$$section{"functions"};})
Truth table100%4/4
A and not(B) or C
A= $sectionB= not $self->{"subs"}C= &any(sub {
$self->{"subs"}{$_};
}
, @{$$section{"functions"};})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 308 | $section->{level} = $level; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 308 | push @{ $self->{sections} }, $section; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 308 | $current = $section; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 308 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 44 | ▶ | undef $current if !$current || $level <= $current->{level}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $current or $level <= $current->{"level"}
MC/DC100%2/2
not $current or $level <= $current->{"level"}
not $current
$level <= $current->{"level"}
Truth table100%3/3
not(A) or B
A= not $currentB= $level <= $current->{"level"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 44 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 545 | ▶ | $self->_content( $current, $node ) if $current; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 56 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # _flatten and _content walk the tree of the POD, which is as deep as its nesting, and so recursion is their natural form. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ## no critic (Subroutines::ProhibitTailRecursion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # The text of a node, with its formatting codes and their markup left out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2066 | ▶ | sub _flatten { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_flatten: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2066 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2066 | ▶ | return $node if !ref $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 973 | my ( undef, undef, @kids ) = @$node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 973 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 973 | foreach my $kid (@kids) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 1101 | $text .= _flatten($kid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 973 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # What a heading assigns its call to: a variable, a reference to one, or a list of them in parentheses. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 15 | our $ASSIGNEE = qr/(?:(?:my|our)\s+)? (?:\\?[\$@%]\w+ | \([^()]*\))/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 15 | our $ASSIGNED = qr/\A $ASSIGNEE \s* =(?![=>~]) \s*/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 318 | ▶ | sub _heading { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_heading: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 318 | my ( $self, $text, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 318 | $text =~ s/[;#]//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 318 | $text =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 318 | my ( %args, %strength, @functions ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 318 | foreach my $named ( $self->_named_by($text) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 346 | my $function = $named->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 346 | ▶ | push @functions, $function if !$strength{$function}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 346 | ▶ | $args{$function} = [ grep { $_ ne q{} } map { s/\A\s+|\s+\z//gr =~ s/\A(\w+)\s*=>.*\z/$1/r } split m/,/, $named->{args} ] if defined $named->{args}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 346 | ▶ | my $strength = $named->{call} ? 2 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 346 | ▶ | $strength{$function} = $strength if ( $strength{$function} // 0 ) < $strength; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$strength{$function} // 0
MC/DC0%0/1
$strength{$function} // 0
$strength{$function}
Truth table50%1/2
A
A= $strength{$function}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 318 | ▶ | return if !@functions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 315 | ▶ | heading => $text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | line => $line, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | assigns => $text =~ $ASSIGNED ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | functions => \@functions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | args => \%args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | strength => \%strength, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | types => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | returns => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | terminations => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | verbatim => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # What may follow the last call or name of a heading: what it returns, after an =, or a description after a dash. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 15 | ▶ | our $DASH = qr/[-\N{EM DASH}]-?/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 15 | our $HEADING_TAIL = qr/\s*=(?![=>~]).*\z | \s+$DASH\s.*\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # One call or name in a heading: an optional invocant, an object or a class, or package, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # then the name of the sub, then an optional argument list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 15 | our $INVOCANT = qr/(?:\$\w+ | \w+(?:::\w+)*) \s*->\s*/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 15 | our $CALL_ARGS = qr/\s*\((?<args>[^()]*)\)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 15 | our $HEADING_ITEM = qr/(?<invocant>$INVOCANT)? (?<package>(?:\w+::)+)? (?<name>\w+) $CALL_ARGS?/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # The subs that the heading TEXT names, each a HASHREF with C<name>, C<args>, the text of its argument list or undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # and C<call>, true when the heading writes it as a call rather than as a bare name, in the forms that DESCRIPTION lists. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 318 | ▶ | sub _named_by { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_named_by: called CC=14 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 318 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 318 | $text =~ s/$ASSIGNED//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 318 | my ( @items, $spaced ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 318 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 359 | ▶ | $text =~ m/\G$HEADING_ITEM/gc or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 359 | ▶ | push @items, { name => $+{name}, args => $+{args}, call => ( defined $+{invocant} || defined $+{package} || defined $+{args} ) ? 1 : 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $+{"invocant"} or defined $+{"package"} or defined $+{"args"}
defined $+{"invocant"} or defined $+{"package"}
MC/DC100%3/3
defined $+{"invocant"} or defined $+{"package"} or defined $+{"args"}
defined $+{"invocant"}
defined $+{"package"}
defined $+{"args"}
Truth table100%4/4
A or B or C
A= defined $+{"invocant"}B= defined $+{"package"}C= defined $+{"args"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 359 | ▶ | last if pos($text) == length $text || $text =~ m/\G$HEADING_TAIL/gc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
pos $text == length $text or $text =~ /\G$Pod::Coverage::More::Documentation::HEADING_TAIL/aacgsx
MC/DC100%2/2
pos $text == length $text or $text =~ /\G$Pod::Coverage::More::Documentation::HEADING_TAIL/aacgsx
pos $text == length $text
$text =~ /\G$Pod::Coverage::More::Documentation::HEADING_TAIL/aacgsx
Truth table100%3/3
A or B
A= pos $text == length $textB= $text =~ /\G$Pod::Coverage::More::Documentation::HEADING_TAIL/aacgsx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 41 | ▶ | next if $text =~ m/\G\s*,\s*/gc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 21 | ▶ | $text =~ m/\G\s+/gc or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 21 | $spaced = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 318 | my $subs = $self->{subs}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 318 | ▶ | return @items if !$spaced || !$subs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$spaced and $subs
MC/DC100%2/2
$spaced and $subs
$spaced
$subs
Truth table100%3/3
A and B
A= $spacedB= $subs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | ▶ | my $has_call = any { $_->{call} } @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 5 | ▶ | my $all_known = !any { !$subs->{ $_->{name} } } @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 5 | ▶ | return if !$has_call && !$all_known; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$has_call or $all_known
MC/DC50%1/2
$has_call or $all_known
$has_call
$all_known
Truth table66%2/3
A or B
A= $has_callB= $all_known
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | return grep { $_->{call} || $subs->{ $_->{name} } } @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_->{'call'} || $$subs{$_->{'name'}}
MC/DC0%0/2
$_->{'call'} || $$subs{$_->{'name'}}
$_->{'call'}
$$subs{$_->{'name'}}
Truth table66%2/3
A || B
A= $_->{'call'}B= $$subs{$_->{'name'}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 764 | ▶ | sub _content { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_content: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 764 | my ( $self, $section, $node ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 764 | my $type = $node->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 764 | my $line = $node->[1]{start_line}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 764 | ▶ | if ( $type =~ m/\Aover-/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 151 | my ( undef, undef, @kids ) = @$node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 151 | foreach my $kid ( grep { ref } @kids ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 234 | $self->_content( $section, $kid ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 151 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 613 | my $text = _flatten($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 613 | ▶ | if ( $type eq 'Verbatim' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 123 | push @{ $section->{verbatim} }, $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 123 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 490 | ▶ | if ( $type =~ m/\Aitem-/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 234 | $self->_item( $section, $text, $line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | elsif ( $text =~ m/\A\s*returns?\b\s*(.*)/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 165 | push @{ $section->{returns} }, { %{ _returned($1) }, text => $text, line => $line }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 490 | ▶ | push @{ $section->{terminations} }, $text if $text =~ $TERMINATION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 490 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | ## use critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 234 | ▶ | sub _item { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_item: called CC=12 SCAR=25.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 234 | my ( $self, $section, $text, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 234 | my ( $name, $rest ) = $text =~ m/\A\s*(\S+?)[:,]?(?:\s+(.*))?\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 234 | ▶ | return if !defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 234 | ▶ | $rest //= q{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$rest //= ""
MC/DC0%0/1
$rest //= ""
$rest
Truth table50%1/2
A
A= $rest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 234 | ▶ | if ( lc $name eq 'returns' || lc $name eq 'return' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
lc $name eq "returns" or lc $name eq "return"
MC/DC50%1/2
lc $name eq "returns" or lc $name eq "return"
lc $name eq "returns"
lc $name eq "return"
Truth table66%2/3
A or B
A= lc $name eq "returns"B= lc $name eq "return"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | $rest =~ s/\A[-:\s]+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | push @{ $section->{returns} }, { %{ _returned($rest) }, text => $text, line => $line }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 233 | my $word = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 233 | ▶ | if ( $rest =~ m/\A\((.*?)\)/ ) { $word = $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 228 | elsif ( $rest =~ m/\A[-:\s]*(.*?)\s*(?:\s-\s|:\s|\z)/ ) { $word = $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 233 | $word =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 233 | my $type = type_named($word); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 233 | ▶ | my $documented = { word => $type ? lc $word : q{}, type => $type, sigil => $name =~ m/\A([@%])/ ? $1 : undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 233 | my $bare = _bare($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 233 | foreach my $function ( @{ $section->{functions} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 245 | ▶ | my @args = map { _bare($_) } @{ $section->{args}{$function} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$section->{'args'}{$function} || []
MC/DC0%0/1
$section->{'args'}{$function} || []
$section->{'args'}{$function}
Truth table50%1/2
A
A= $section->{'args'}{$function}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 245 | ▶ | next if !any { $_ eq $bare } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 233 | $section->{types}{$function}{$bare} = $documented; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 233 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # C<name> without its sigils and backslashes, in lower case, as arguments in the POD and parameters in the code are compared. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # @param name Str an argument or a parameter, such as C<\%Options> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # @returns Str the bare name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # @example my $bare = Pod::Coverage::More::Documentation->bare_name('\%Options'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1258 | ▶ | sub bare_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bare_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1258 | my ( $class, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1258 | return _bare($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2136 | ▶ | sub _bare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bare: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 2136 | my ($name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2136 | $name =~ tr/$*\\@%&|//d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2136 | return lc $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 15 | our %LITERAL_TYPES = ( undef => Undef, true => Bool, false => Bool, boolean => Bool, 'a boolean' => Bool ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # The types that the words after "Returns" name, and whether they say that it returns nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 166 | ▶ | sub _returned { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_returned: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 166 | my ($rest) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 166 | my @types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 166 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 173 | $rest =~ s/\A\s*(?:an?|the)\s+(?=\S)//i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 173 | ▶ | return { types => [], nothing => 1 } if !@types && $rest =~ m/\A\s*(?:nothing|no\s+value|an?\s+empty\s+list)\b/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not @types and $rest =~ /\A\s*(?:nothing|no\s+value|an?\s+empty\s+list)\b/aaisx
MC/DC100%2/2
not @types and $rest =~ /\A\s*(?:nothing|no\s+value|an?\s+empty\s+list)\b/aaisx
not @types
$rest =~ /\A\s*(?:nothing|no\s+value|an?\s+empty\s+list)\b/aaisx
Truth table100%3/3
not(A) and B
A= not @typesB= $rest =~ /\A\s*(?:nothing|no\s+value|an?\s+empty\s+list)\b/aaisx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 150 | ▶ | my $type = _type_at_start( \$rest ) or last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 120 | push @types, $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 120 | ▶ | last if $rest !~ s/\A\s*(?:,\s*)?(?:or\b|\|)\s*//i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 143 | return { types => \@types, nothing => 0 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 150 | ▶ | sub _type_at_start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_type_at_start: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 150 | my ($rest) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 150 | ▶ | if ( $$rest =~ s/\A\s*(?:an?\s+)?instance\s+of\s+(?:class\s+)?$CLASS_NAME//i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 3 | return InstanceOf [$1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 147 | ▶ | if ( $$rest =~ s/\A\s*(?:new\s+)?$CLASS_OBJECT//i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 8 | return InstanceOf [$1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 139 | my $literals = join q{|}, map { s/[ ]/\\s+/gr } sort keys %LITERAL_TYPES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 139 | ▶ | if ( $$rest =~ s/\A\s*($literals)\b//i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 11 | return $LITERAL_TYPES{ lc( $1 =~ s/\s+/ /gr ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 128 | ▶ | return Int if $$rest =~ s/\A\s*-?\d+(?!\.\d)\b//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 126 | ▶ | return Str if $$rest =~ s/\A\s*(?:'[^']*'|"[^"]*")//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 126 | my ($word) = $$rest =~ m/\A\s*($TYPE_NAME $TYPE_PARAMS?)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 126 | ▶ | return if !defined $word; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 126 | ▶ | my $type = type_named($word) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 96 | $$rest =~ s/\A\s*\Q$word\E//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 96 | return $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||