| 1 | package YATT::Lite::LRXML::FormatEntpath; | ||||||||||||||||||||||||||||
| 2 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use Exporter qw/import/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 9 | our @EXPORT_OK = qw/format_entpath/; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use YATT::Lite::Constants; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use YATT::Lite::LRXML::ParseEntpath; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 9 | *close_ch = *YATT::Lite::LRXML::ParseEntpath::close_ch; | |||||||||||||||||||||||||||
| 12 | 9 | *close_ch = *YATT::Lite::LRXML::ParseEntpath::close_ch; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 18 | ▶ | sub inverse_hash { | ||||||||||||||||||||||||||
|
Subroutine
inverse_hash: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 18 | my ($fromHash, $toHash) = @_; | |||||||||||||||||||||||||||
| 16 | 18 | ▶ | $toHash //= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$toHash //= {}
MC/DC0%0/1
$toHash //= {}
$toHash
Truth table50%1/2
A
A= $toHash
| |||||||||||||||||||||||||||||
| 17 | 18 | $toHash->{$fromHash->{$_}} = $_ for keys %$fromHash; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 9 | our (%name2sym); | |||||||||||||||||||||||||||
| 21 | 9 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 9 | inverse_hash(\%name2sym, \%YATT::Lite::LRXML::ParseEntpath::open_head); | |||||||||||||||||||||||||||
| 23 | 9 | inverse_hash(\%name2sym, \%YATT::Lite::LRXML::ParseEntpath::open_rest); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub ME () {__PACKAGE__} | ||||||||||||||||||||||||||||
| 27 | 368 | ▶ | sub format_entpath { | ||||||||||||||||||||||||||
|
Subroutine
format_entpath: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | join("", map { | ||||||||||||||||||||||||||||
| 29 | 368 | my ($type, @rest) = @{lxnest($_)}; | |||||||||||||||||||||||||||
| 30 | 409 | ▶ | my $sub = ME->can("format__$type") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | or Carp::croak "Unknown entpath type: ".YATT::Lite::Util::terse_dump($type); | ||||||||||||||||||||||||||||
| 32 | 409 | $sub->(@rest); | |||||||||||||||||||||||||||
| 33 | } @_); | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 83 | ▶ | sub format__call { | ||||||||||||||||||||||||||
|
Subroutine
format__call: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 83 | my ($name, @args) = @_; | |||||||||||||||||||||||||||
| 38 | 83 | my @items = map {format_entpath(lxnest($_))} @args; | |||||||||||||||||||||||||||
| 39 | 83 | ▶ | $items[-1] .= "," if @items and $items[-1] eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@items and $items[-1] eq ""
MC/DC100%2/2
@items and $items[-1] eq ""
@items
$items[-1] eq ""
Truth table100%3/3
A and B
A= @itemsB= $items[-1] eq ""
| |||||||||||||||||||||||||||||
| 40 | 83 | sprintf(":%s(%s)", $name, join(",", @items)); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 9 | *format__invoke = *format__call; *format__invoke = *format__call; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 107 | ▶ | sub format__var { | ||||||||||||||||||||||||||
|
Subroutine
format__var: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | 107 | my ($name) = @_; | |||||||||||||||||||||||||||
| 47 | 107 | ":$name"; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 9 | *format__prop = *format__var; *format__prop = *format__var; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 25 | ▶ | sub format__href { | ||||||||||||||||||||||||||
|
Subroutine
format__href: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 25 | my (@args) = @_; | |||||||||||||||||||||||||||
| 54 | 25 | "{".join(",", map {format_entpath(lxnest($_))} @args)."}" | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 9 | *format__hash = *format__href; *format__hash = *format__href; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 29 | ▶ | sub format__aref { | ||||||||||||||||||||||||||
|
Subroutine
format__aref: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | 29 | my (@args) = @_; | |||||||||||||||||||||||||||
| 61 | 29 | "[".join(",", map {format_entpath(lxnest($_))} @args)."]" | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 9 | *format__array = *format__aref; *format__array = *format__aref; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 121 | ▶ | sub format__text { | ||||||||||||||||||||||||||
|
Subroutine
format__text: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | 121 | my ($name) = @_; | |||||||||||||||||||||||||||
| 68 | 121 | ▶ | if ($name eq '') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 69 | 10 | ""; | |||||||||||||||||||||||||||
| 70 | } elsif ($name =~ m{^[-\+\*/<>!\w\|\@\$%][-\+\*/<>!\w\|\@\$%=]*\z}) { | ||||||||||||||||||||||||||||
| 71 | # XXX: matching paren {..} | ||||||||||||||||||||||||||||
| 72 | 106 | $name | |||||||||||||||||||||||||||
| 73 | } else { | ||||||||||||||||||||||||||||
| 74 | 5 | "($name)" | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 44 | ▶ | sub format__expr { | ||||||||||||||||||||||||||
|
Subroutine
format__expr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | 44 | my ($name) = @_; | |||||||||||||||||||||||||||
| 80 | 44 | "=$name" | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 9 | 1; | |||||||||||||||||||||||||||