| 1 | package Test2::Tools::Tester; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Test2::Util::Ref qw/rtype/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | if (eval { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | no warnings 'deprecated'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | require Module::Pluggable; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 15 | }) { | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | Module::Pluggable->import(search_path => ['Test2::EventFacet'], require => 1); | |||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | require Test2::EventFacet::About; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | require Test2::EventFacet::Amnesty; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | require Test2::EventFacet::Assert; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | require Test2::EventFacet::Control; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | require Test2::EventFacet::Error; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | require Test2::EventFacet::Hub; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | require Test2::EventFacet::Info; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | require Test2::EventFacet::Info::Table; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | require Test2::EventFacet::Meta; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | require Test2::EventFacet::Parent; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | require Test2::EventFacet::Plan; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | require Test2::EventFacet::Render; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | require Test2::EventFacet::Trace; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | *plugins = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | 'Test2::EventFacet::About', | |||||||||||||||||||||||||||||||||||||||||
| 36 | 'Test2::EventFacet::Amnesty', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 'Test2::EventFacet::Assert', | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 'Test2::EventFacet::Control', | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 'Test2::EventFacet::Error', | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 'Test2::EventFacet::Hub', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 'Test2::EventFacet::Info', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 'Test2::EventFacet::Info::Table', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 'Test2::EventFacet::Meta', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 'Test2::EventFacet::Parent', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 'Test2::EventFacet::Plan', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 'Test2::EventFacet::Render', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 'Test2::EventFacet::Trace', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | use Test2::Util::Importer 'Test2::Util::Importer' => 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | our @EXPORT_OK = qw{ | |||||||||||||||||||||||||||||||||||||||||
| 56 | facets | ||||||||||||||||||||||||||||||||||||||||||
| 57 | filter_events | ||||||||||||||||||||||||||||||||||||||||||
| 58 | event_groups | ||||||||||||||||||||||||||||||||||||||||||
| 59 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | my %TYPES; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | for my $class (__PACKAGE__->plugins) { | |||||||||||||||||||||||||||||||||||||||||
| 63 | 13 | my $type = $class; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 13 | $type =~ s/^Test2::EventFacet:://g; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 13 | ▶ | next unless $class->isa('Test2::EventFacet'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 12 | my $key; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 12 | ▶ | $key = $class->facet_key if $class->can('facet_key'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 12 | ▶ | $key = lc($type) unless defined $key; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 12 | $TYPES{$type} = $class; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 12 | $TYPES{lc($type)} = $class; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 12 | $TYPES{$key} = $class; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | ▶ | sub filter_events { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_events: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | my $events = shift; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | ▶ | my @match = map { rtype($_) eq 'REGEXP' ? $_ : qr/^\Q$_\E::/} @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | my @out; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | for my $e (@$events) { | |||||||||||||||||||||||||||||||||||||||||
| 83 | 15 | ▶ | my $trace = $e->facet_data->{trace} or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 15 | ▶ | next unless grep { $trace->{frame}->[3] =~ $_ } @match; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 8 | push @out => $e; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | return \@out; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | sub event_groups { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
event_groups: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | my $events = shift; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | my $out = {}; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | for my $e (@$events) { | |||||||||||||||||||||||||||||||||||||||||
| 96 | 8 | my $trace = $e->facet_data->{trace}; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 8 | ▶ | my $tool = ($trace && $trace->{frame} && $trace->{frame}->[3]) ? $trace->{frame}->[3] : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$trace and $trace->{"frame"} and $trace->{"frame"}[3]
$trace and $trace->{"frame"}
MC/DC33%1/3
$trace and $trace->{"frame"} and $trace->{"frame"}[3]
$trace
$trace->{"frame"}
$trace->{"frame"}[3]
Truth table50%2/4
A and B and C
A= $traceB= $trace->{"frame"}C= $trace->{"frame"}[3]
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 8 | ▶ | unless ($tool) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | push @{$out->{__NA__}} => $e; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 7 | my ($pkg, $sub) = ($tool =~ m/^(.*)(?:::|')([^:']+)$/); | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | push @{$out->{$pkg}->{$sub}} => $e; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 7 | push @{$out->{$pkg}->{__ALL__}} => $e; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 6 | ▶ | sub facets { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
facets: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | my ($type, $events) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 6 | my ($key, $is_list); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 6 | my $class = $TYPES{$type}; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 6 | ▶ | if ($class) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 4 | ▶ | $key = $class->facet_key || lc($type); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$class->facet_key || lc $type
MC/DC0%0/2
$class->facet_key || lc $type
$class->facet_key
lc $type
Truth table33%1/3
A || B
A= $class->facet_keyB= lc $type
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 4 | $is_list = $class->is_list; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | $key = lc($type); | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 6 | my @out; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 6 | for my $e (@$events) { | |||||||||||||||||||||||||||||||||||||||||
| 128 | 42 | my $fd = $e->facet_data; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 42 | ▶ | my $f = $fd->{$key} or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 9 | ▶ | my $list = defined($is_list) ? $is_list : rtype($f) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 9 | ▶ | if ($list) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 6 | ▶ | push @out => map { $class ? $class->new($_) : $_ } @$f; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | ▶ | push @out => $class ? $class->new($f) : $f; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 6 | return \@out; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | __END__ | ||||||||||||||||||||||||||||||||||||||||||