| 1 | package Data::Printer::Filter::GenericClass; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 35 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 35 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 35 | ▶ | use Data::Printer::Filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 35 | ▶ | use Data::Printer::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 35 | ▶ | use Scalar::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 52 | ▶ | filter '-class' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=47 SCAR=48.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 52 | my ($object, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # if the class implements its own Data::Printer method, we use it! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 52 | ▶ | if ($ddp->class_method and my $method = $object->can( $ddp->class_method )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ddp->class_method and my $method = $object->can($ddp->class_method)
MC/DC0%0/2
$ddp->class_method and my $method = $object->can($ddp->class_method)
$ddp->class_method
my $method = $object->can($ddp->class_method)
Truth table33%1/3
A and B
A= $ddp->class_methodB= my $method = $object->can($ddp->class_method)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | return $method->($object, $ddp) if ref $method eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 52 | my $class_name = ref $object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # there are many parts of the class filter that require the object's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # linear ISA, so we declare it earlier and load it only once: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 52 | my $linear_ISA = Data::Printer::Common::_linear_ISA_for($class_name, $ddp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # if the object overloads stringification, use it! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # except for PDF::API2 which has a destructive stringify() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 52 | ▶ | if ($ddp->class->stringify && $class_name ne 'PDF::API2') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ddp->class->stringify and $class_name ne "PDF::API2"
MC/DC50%1/2
$ddp->class->stringify and $class_name ne "PDF::API2"
$ddp->class->stringify
$class_name ne "PDF::API2"
Truth table66%2/3
A and B
A= $ddp->class->stringifyB= $class_name ne "PDF::API2"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 51 | my $str = _get_stringification($ddp, $object, $class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 51 | ▶ | return $ddp->maybe_colorize("$str ($class_name)", 'class') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | if defined $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # otherwise, do our generic object representation: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 47 | my $show_reftype = $ddp->class->show_reftype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 47 | my $show_internals = $ddp->class->internals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 47 | my $reftype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 47 | ▶ | if ($show_reftype || $show_internals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$show_reftype or $show_internals
MC/DC100%2/2
$show_reftype or $show_internals
$show_reftype
$show_internals
Truth table100%3/3
A or B
A= $show_reftypeB= $show_internals
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 46 | $reftype = Scalar::Util::reftype($object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 46 | ▶ | $reftype = 'Regexp' if $reftype eq 'REGEXP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 47 | $ddp->{_class_depth}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 47 | my $string = $ddp->maybe_colorize( $class_name, 'class' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 47 | ▶ | if ($show_reftype) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | $string .= ' ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | . $ddp->maybe_colorize('(', 'brackets') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | . $ddp->maybe_colorize( $reftype, 'class' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | . $ddp->maybe_colorize(')', 'brackets'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 47 | ▶ | if ($ddp->class->expand eq 'all' || $ddp->class->expand >= $ddp->{_class_depth}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ddp->class->expand eq "all" or $ddp->class->expand >= $ddp->{"_class_depth"}
MC/DC100%2/2
$ddp->class->expand eq "all" or $ddp->class->expand >= $ddp->{"_class_depth"}
$ddp->class->expand eq "all"
$ddp->class->expand >= $ddp->{"_class_depth"}
Truth table100%3/3
A or B
A= $ddp->class->expand eq "all"B= $ddp->class->expand >= $ddp->{"_class_depth"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 39 | $ddp->indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 39 | $string .= ' ' . $ddp->maybe_colorize('{', 'brackets'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 39 | my @superclasses = Data::Printer::Common::_get_superclasses_for($class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 39 | ▶ | if (@superclasses && $ddp->class->parents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@superclasses and $ddp->class->parents
MC/DC100%2/2
@superclasses and $ddp->class->parents
@superclasses
$ddp->class->parents
Truth table100%3/3
A and B
A= @superclassesB= $ddp->class->parents
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 23 | $string .= $ddp->newline . 'parents: ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | . join(', ', map $ddp->maybe_colorize($_, 'class'), @superclasses) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 39 | my (%roles, %attributes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 39 | ▶ | if ($INC{'Role/Tiny.pm'} && exists $Role::Tiny::APPLIED_TO{$class_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$INC{"Role/Tiny.pm"} and exists $Role::Tiny::APPLIED_TO{$class_name}
MC/DC50%1/2
$INC{"Role/Tiny.pm"} and exists $Role::Tiny::APPLIED_TO{$class_name}
$INC{"Role/Tiny.pm"}
exists $Role::Tiny::APPLIED_TO{$class_name}
Truth table66%2/3
A and B
A= $INC{"Role/Tiny.pm"}B= exists $Role::Tiny::APPLIED_TO{$class_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | %roles = %{ $Role::Tiny::APPLIED_TO{$class_name} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 39 | my $is_moose = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 39 | foreach my $parent (@$linear_ISA) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 74 | ▶ | if ($parent eq 'Moo::Object') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | ▶ | Data::Printer::Common::_tryme(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | my $moo_maker = 'Moo'->_constructor_maker_for($class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | ▶ | if (defined $moo_maker) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | %attributes = %{ $moo_maker->all_attribute_specs }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | elsif ($parent eq 'Moose::Object') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | Data::Printer::Common::_tryme(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $class_meta = $class_name->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $is_moose = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | %attributes = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | $_->name => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | index => $_->insertion_order, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | init_arg => $_->init_arg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | is => (defined $_->writer ? 'rw' : 'ro'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | reader => $_->reader, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | required => $_->is_required, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } $class_meta->get_all_attributes(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | foreach my $role ($class_meta->calculate_all_roles()) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $roles{ $role->name } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | elsif ($parent eq 'Object::Pad::UNIVERSAL') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | Data::Printer::Common::_tryme(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $meta = Object::Pad::MOP::Class->for_class( $class_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | %attributes = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $_->name . $_->value($class_name) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } $meta->fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | %roles = map { $_->name => 1 } $meta->direct_roles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 39 | ▶ | if ($ddp->class->show_methods ne 'none') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 38 | ▶ | if (my @role_list = keys %roles) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | ▶ | @role_list = Data::Printer::Common::_nsort(@role_list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@role_list and $ddp->class->sort_methods
MC/DC0%0/2
@role_list and $ddp->class->sort_methods
@role_list
$ddp->class->sort_methods
Truth table33%1/3
A and B
A= @role_listB= $ddp->class->sort_methods
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | if @role_list && $ddp->class->sort_methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | $string .= $ddp->newline . 'roles (' . scalar(@role_list) . '): ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | . join(', ' => map $ddp->maybe_colorize($_, 'class'), @role_list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 38 | ▶ | if (my @attr_list = keys %attributes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | ▶ | @attr_list = Data::Printer::Common::_nsort(@attr_list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@attr_list and $ddp->class->sort_methods
MC/DC0%0/2
@attr_list and $ddp->class->sort_methods
@attr_list
$ddp->class->sort_methods
Truth table33%1/3
A and B
A= @attr_listB= $ddp->class->sort_methods
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | if @attr_list && $ddp->class->sort_methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | $string .= $ddp->newline . 'attributes (' . scalar(@attr_list) . '): ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | . join(', ' => map $ddp->maybe_colorize($_, 'method'), @attr_list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 39 | ▶ | my $show_linear_isa = $ddp->class->linear_isa && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%9/9
$ddp->class->linear_isa && ($ddp->class->linear_isa eq 'auto' && @superclasses > 1 || $ddp->class->linear_isa ne 'auto')
$ddp->class->linear_isa eq "auto" and @superclasses > 1 or $ddp->class->linear_isa ne "auto"
$ddp->class->linear_isa eq "auto" and @superclasses > 1
MC/DC50%2/4
$ddp->class->linear_isa && ($ddp->class->linear_isa eq 'auto' && @superclasses > 1 || $ddp->class->linear_isa ne 'auto')
$ddp->class->linear_isa
$ddp->class->linear_isa eq "auto"
@superclasses > 1
$ddp->class->linear_isa ne "auto"
Truth table66%4/6
A && B and C or D
A= $ddp->class->linear_isaB= $ddp->class->linear_isa eq "auto"C= @superclasses > 1D= $ddp->class->linear_isa ne "auto"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | ($ddp->class->linear_isa eq 'auto' and @superclasses > 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | or ($ddp->class->linear_isa ne 'auto') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 39 | ▶ | if ($show_linear_isa && @$linear_ISA) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$show_linear_isa and @$linear_ISA
MC/DC50%1/2
$show_linear_isa and @$linear_ISA
$show_linear_isa
@$linear_ISA
Truth table66%2/3
A and B
A= $show_linear_isaB= @$linear_ISA
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | $string .= $ddp->newline . 'linear @ISA: ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | . join(', ' => map $ddp->maybe_colorize($_, 'class'), @$linear_ISA) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 39 | ▶ | if ($ddp->class->show_methods ne 'none') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 38 | $string .= _show_methods($class_name, $linear_ISA, \%attributes, $ddp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 38 | ▶ | if ($is_moose && $ddp->class->show_wrapped) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$is_moose and $ddp->class->show_wrapped
MC/DC0%0/2
$is_moose and $ddp->class->show_wrapped
$is_moose
$ddp->class->show_wrapped
Truth table33%1/3
A and B
A= $is_mooseB= $ddp->class->show_wrapped
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $modified = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $modified_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $ddp->indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | for my $method ($class_name->meta->get_all_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if (ref $method eq 'Class::MOP::Method::Wrapped') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | foreach my $kind (qw(before around after)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $getter_method = $kind . '_modifiers'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if (my @modlist = $method->$getter_method) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $modified .= $ddp->newline . $kind . ' ' . $method->name . ': ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | . (@modlist > 1 ? $ddp->parse(\@modlist) : $ddp->parse($modlist[0])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $modified_count++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $ddp->outdent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ($modified_count) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $string .= $ddp->newline . 'method modifiers (' . $modified_count . '):' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | . $modified; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 39 | ▶ | if ($ddp->class->show_overloads) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 38 | my @overloads = _get_overloads($object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 38 | ▶ | if (@overloads) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | $string .= $ddp->newline . 'overloads: ' . join(', ' => @overloads); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 39 | ▶ | if ($show_internals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 38 | $string .= $ddp->newline | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | . 'internals: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | . $ddp->parse_as($reftype, $object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 39 | $ddp->outdent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 39 | $string .= $ddp->newline . $ddp->maybe_colorize('}', 'brackets'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 47 | $ddp->{_class_depth}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 47 | ▶ | if ($ddp->show_tied and my $tie = ref tied $object) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ddp->show_tied and my $tie = ref tied $object
MC/DC0%0/2
$ddp->show_tied and my $tie = ref tied $object
$ddp->show_tied
my $tie = ref tied $object
Truth table33%1/3
A and B
A= $ddp->show_tiedB= my $tie = ref tied $object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $string .= " (tied to $tie)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 47 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 35 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ### Private auxiliary helpers below ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 51 | ▶ | sub _get_stringification { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_stringification: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 51 | my ($ddp, $object, $class_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 51 | require overload; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 51 | ▶ | if (overload::Overloaded($object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
overload::Overloaded($object) and overload::Method($object, "\"\"") || overload::Method($object, "0+")
overload::Method($object, "\"\"") or overload::Method($object, "0+")
MC/DC100%3/3
overload::Overloaded($object) and overload::Method($object, "\"\"") || overload::Method($object, "0+")
overload::Overloaded($object)
overload::Method($object, "\"\"")
overload::Method($object, "0+")
Truth table100%4/4
A and B or C
A= overload::Overloaded($object)B= overload::Method($object, "\"\"")C= overload::Method($object, "0+")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | && (overload::Method($object, q("")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | || overload::Method($object, q(0+)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 3 | my $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 3 | ▶ | my $error = Data::Printer::Common::_tryme(sub { $string = '' . $object }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 3 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | Data::Printer::Common::_warn( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | $ddp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | "string/number overload error for object $class_name: $error" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 48 | foreach my $method (qw(as_string stringify to_string)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 141 | ▶ | if ($object->can($method)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | my $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | ▶ | my $error = Data::Printer::Common::_tryme(sub { $string = $object->$method }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | Data::Printer::Common::_warn( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | $ddp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | "error stringifying object $class_name with $method\(\): $error" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 46 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # returns array of all overloads in class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 38 | ▶ | sub _get_overloads { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_overloads: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 38 | my ($object) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 38 | require overload; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 38 | ▶ | return () unless overload::Overloaded($object); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | return sort grep overload::Method($object, $_), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | map split(/\s+/), values %overload::ops; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 38 | ▶ | sub _show_methods { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_show_methods: called CC=30 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 38 | my ($class_name, $linear_ISA, $attributes, $ddp) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 38 | my %methods = ( public => {}, private => {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 38 | my @all_methods = map _methods_of( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | $_, Data::Printer::Common::_get_namespace($_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ), @$linear_ISA; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 38 | my $show_methods = $ddp->class->show_methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 38 | my $show_inherited = $ddp->class->inherited; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 38 | my %seen_method_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 38 | foreach my $method (@all_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 235 | my ($package_string, $method_string) = @$method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 235 | ▶ | next if exists $attributes->{$method_string}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 233 | ▶ | next if $seen_method_name{$method_string}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 206 | ▶ | next if $method_string eq '__ANON__'; # anonymous subs don't matter here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 205 | ▶ | my $type = substr($method_string, 0, 1) eq '_' ? 'private' : 'public'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 205 | ▶ | if ($package_string eq $class_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 107 | ▶ | next unless $show_methods eq 'all' || $show_methods eq $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$show_methods eq "all" or $show_methods eq $type
MC/DC100%2/2
$show_methods eq "all" or $show_methods eq $type
$show_methods eq "all"
$show_methods eq $type
Truth table100%3/3
A or B
A= $show_methods eq "all"B= $show_methods eq $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 94 | $methods{$type}{$method_string} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 98 | ▶ | next unless $show_inherited eq 'all' || $show_inherited eq $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$show_inherited eq "all" or $show_inherited eq $type
MC/DC100%2/2
$show_inherited eq "all" or $show_inherited eq $type
$show_inherited eq "all"
$show_inherited eq $type
Truth table100%3/3
A or B
A= $show_inherited eq "all"B= $show_inherited eq $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 52 | $methods{$type}{$method_string} = $package_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 38 | my $string = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 38 | foreach my $type (qw(public private)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 76 | ▶ | next unless $show_methods eq 'all' or $show_methods eq $type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$show_methods eq "all" or $show_methods eq $type or $show_inherited eq "all" or $show_inherited eq $type
$show_methods eq "all" or $show_methods eq $type or $show_inherited eq "all"
$show_methods eq "all" or $show_methods eq $type
MC/DC75%3/4
$show_methods eq "all" or $show_methods eq $type or $show_inherited eq "all" or $show_inherited eq $type
$show_methods eq "all"
$show_methods eq $type
$show_inherited eq "all"
$show_inherited eq $type
Truth table80%4/5
A or B or C or D
A= $show_methods eq "all"B= $show_methods eq $typeC= $show_inherited eq "all"D= $show_inherited eq $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | or $show_inherited eq 'all' or $show_inherited eq $type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 73 | ▶ | if ($ddp->class->format_inheritance eq 'string') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 4 | my @method_list = keys %{$methods{$type}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 4 | ▶ | @method_list = Data::Printer::Common::_nsort(@method_list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@method_list and $ddp->class->sort_methods
MC/DC50%1/2
@method_list and $ddp->class->sort_methods
@method_list
$ddp->class->sort_methods
Truth table66%2/3
A and B
A= @method_listB= $ddp->class->sort_methods
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | if @method_list && $ddp->class->sort_methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 4 | $string .= $ddp->newline . "$type methods (" . scalar(@method_list) . ')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 4 | ▶ | if (@method_list) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | $string .= ': ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | . join(', ' => map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 3 | $ddp->maybe_colorize( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 14 | ▶ | $_ . (defined $methods{$type}{$_} ? " ($methods{$type}{$_})" : ''), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 'method' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } @method_list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | else { # 'lines' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # first we convert our hash to { pkg => [ @methods ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 69 | my %lined_methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | my @base_methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 69 | my $total_methods = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 69 | foreach my $method (keys %{$methods{$type}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 132 | my $pkg_name = $methods{$type}{$method}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 132 | ▶ | if (defined $pkg_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 44 | push @{ $lined_methods{$pkg_name} }, $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 88 | push @base_methods, $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 132 | $total_methods++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # then we print them, starting with our own methods: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 69 | ▶ | @base_methods = Data::Printer::Common::_nsort(@base_methods) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@base_methods and $ddp->class->sort_methods
MC/DC50%1/2
@base_methods and $ddp->class->sort_methods
@base_methods
$ddp->class->sort_methods
Truth table66%2/3
A and B
A= @base_methodsB= $ddp->class->sort_methods
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | if @base_methods && $ddp->class->sort_methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 69 | ▶ | $string .= $ddp->newline . "$type methods ($total_methods)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | . ($total_methods ? ':' : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 69 | ▶ | if (@base_methods) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | my $base_string = join(', ' => map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 40 | $ddp->maybe_colorize($_, 'method') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } @base_methods); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 40 | $ddp->indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | # newline only if we have parent methods to show: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 40 | ▶ | $string .= (keys %lined_methods ? $ddp->newline : ' ') . $base_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 40 | $ddp->outdent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 69 | foreach my $pkg (sort keys %lined_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 23 | $ddp->indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 23 | $string .= $ddp->newline . "$pkg:"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 23 | ▶ | @{$lined_methods{$pkg}} = Data::Printer::Common::_nsort(@{$lined_methods{$pkg}}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | if $ddp->class->sort_methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 23 | $ddp->indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | $string .= $ddp->newline . join(', ' => map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 44 | $ddp->maybe_colorize($_, 'method') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 23 | } @{$lined_methods{$pkg}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 23 | $ddp->outdent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 23 | $ddp->outdent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 38 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 72 | ▶ | sub _methods_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_methods_of: called CC=8 SCAR=23.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 72 | require B; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 72 | my ($class_name, $namespace) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 72 | my @methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 72 | foreach my $subref (_get_all_subs_from($class_name, $namespace)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 235 | ▶ | next unless $subref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 235 | my $m = B::svref_2object($subref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 235 | ▶ | next unless $m && $m->isa('B::CV'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$m and $m->isa("B::CV")
MC/DC0%0/2
$m and $m->isa("B::CV")
$m
$m->isa("B::CV")
Truth table33%1/3
A and B
A= $mB= $m->isa("B::CV")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 235 | my $gv = $m->GV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 235 | ▶ | next unless $gv && !$gv->isa('B::Special') && $gv->NAME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$gv and not $gv->isa("B::Special") and $gv->NAME
$gv and not $gv->isa("B::Special")
MC/DC0%0/3
$gv and not $gv->isa("B::Special") and $gv->NAME
$gv
not $gv->isa("B::Special")
$gv->NAME
Truth table25%1/4
A and not(B) and C
A= $gvB= not $gv->isa("B::Special")C= $gv->NAME
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 235 | push @methods, [ $gv->STASH->NAME, $gv->NAME ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 72 | return @methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 72 | ▶ | sub _get_all_subs_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_all_subs_from: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 72 | my ($class_name, $namespace) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 72 | my @subs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 72 | foreach my $key (keys %$namespace) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # perlsub says any sub starting with '(' is reserved for overload, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # so we skip those: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 530 | ▶ | next if substr($key, 0, 1) eq '('; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 521 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref \$namespace->{$key} ne "GLOB" or defined *{$namespace->{$key};}{"CODE"}
MC/DC50%1/2
ref \$namespace->{$key} ne "GLOB" or defined *{$namespace->{$key};}{"CODE"}
ref \$namespace->{$key} ne "GLOB"
defined *{$namespace->{$key};}{"CODE"}
Truth table66%2/3
A or B
A= ref \$namespace->{$key} ne "GLOB"B= defined *{$namespace->{$key};}{"CODE"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # any non-typeglob in the symbol table is a constant or stub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ref(\$namespace->{$key}) ne 'GLOB' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | # regular subs are stored in the CODE slot of the typeglob | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 521 | || defined(*{$namespace->{$key}}{CODE}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 235 | push @subs, $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 72 | my @symbols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 72 | foreach my $sub (@subs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 235 | push @symbols, Data::Printer::Common::_get_symbol($class_name, $namespace, $sub, 'CODE'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 72 | return @symbols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 35 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||