| 1 | # You may distribute under the terms of either the GNU General Public License | ||||||||||||||||||||||||||||||||||||
| 2 | # or the Artistic License (the same terms as Perl itself) | ||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||
| 4 | # (C) Paul Evans, 2014-2022 -- leonerd@leonerd.org.uk | ||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||
| 6 | package Devel::MAT::Tool::Future 0.03; | ||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use v5.14; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use base qw( Devel::MAT::Tool ); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 11 | 3 | Devel::MAT::Tool->VERSION( '0.49' ); | |||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use Syntax::Keyword::Match; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use String::Tagged; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use constant FOR_UI => 1; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use File::ShareDir qw( module_file ); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||
| 22 | =head1 NAME | ||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||
| 24 | C<Devel::MAT::Tool::Future> - analyse C<Future> logic | ||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||
| 26 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||
| 28 | This C<Devel::MAT> tool performs analysis of objects and code logic built | ||||||||||||||||||||||||||||||||||||
| 29 | using the L<Future> module. | ||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||
| 31 | This version supports analysing code based on C<Future> version 0.24. | ||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||
| 33 | =cut | ||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||
| 35 | sub AUTOLOAD_TOOL | ||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD_TOOL: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 37 | 2 | shift; | |||||||||||||||||||||||||||||||||||
| 38 | 2 | my ( $pmat ) = @_; | |||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | return 1 if eval { $pmat->find_symbol( '%Future::' ) }; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||
| 42 | sub init_tool | ||||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
init_tool: called CC=13 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 44 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||
| 46 | 2 | my $df = $self->df; | |||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||
| 48 | 2 | my $heap_total = scalar $df->heap; | |||||||||||||||||||||||||||||||||||
| 49 | 2 | my $count; | |||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||
| 51 | # Are Futures XS or PP-based? | ||||||||||||||||||||||||||||||||||||
| 52 | my $future_is_xs; | ||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | if( my $isaav = $self->pmat->find_symbol( '@Future::ISA' ) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 54 | 2 | foreach my $isaelem ( $isaav->elems ) { | |||||||||||||||||||||||||||||||||||
| 55 | 2 | my $superclass = $isaelem->pv; | |||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | if( $superclass eq "Future::XS" ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 57 | 0 | $future_is_xs = 1; | |||||||||||||||||||||||||||||||||||
| 58 | 0 | last; | |||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||
| 60 | elsif( $superclass eq "Future::PP" ) { | ||||||||||||||||||||||||||||||||||||
| 61 | 2 | $future_is_xs = 0; | |||||||||||||||||||||||||||||||||||
| 62 | 2 | last; | |||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||
| 66 | 2 | ▶ | unless( defined $future_is_xs ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 67 | # TODO: Suppress this mesasge if $Future::VERSION is less than whatever it would need to be | ||||||||||||||||||||||||||||||||||||
| 68 | 0 | warn "Unable to determine if Future is based on Future::XS or Future::PP; presuming older version on PP"; | |||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||
| 71 | # Find all the classes that derive from Future | ||||||||||||||||||||||||||||||||||||
| 72 | 2 | $self->{classes} = \my %classes; | |||||||||||||||||||||||||||||||||||
| 73 | 2 | $classes{Future}++; | |||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||
| 75 | 2 | $count = 0; | |||||||||||||||||||||||||||||||||||
| 76 | 2 | foreach my $sv ( $df->heap ) { | |||||||||||||||||||||||||||||||||||
| 77 | 244661 | $count++; | |||||||||||||||||||||||||||||||||||
| 78 | 244661 | ▶ | $self->report_progress( sprintf "Finding Future subclasses in %d of %d (%.2f%%)", | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 79 | $count, $heap_total, 100*$count / $heap_total ) if ($count % 1000) == 0; | ||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||
| 81 | 244661 | ▶ | next unless $sv->type eq "STASH"; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||
| 83 | # populate the %classes hash | ||||||||||||||||||||||||||||||||||||
| 84 | 849 | $self->class_is_future( $sv ); | |||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||
| 87 | 2 | my $persv_data = [ $future_is_xs ]; | |||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||
| 89 | 2 | $count = 0; | |||||||||||||||||||||||||||||||||||
| 90 | 2 | foreach my $sv ( $df->heap ) { | |||||||||||||||||||||||||||||||||||
| 91 | 244661 | $count++; | |||||||||||||||||||||||||||||||||||
| 92 | 244661 | ▶ | $self->report_progress( sprintf "Finding Future instances in %d of %d (%.2f%%)", | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 93 | $count, $heap_total, 100*$count / $heap_total ) if ($count % 1000) == 0; | ||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||
| 95 | 244661 | ▶ | next unless my $pkg = $sv->blessed; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||
| 97 | 437 | ▶ | $classes{ $pkg->stashname } and $sv->{tool_future} = $persv_data; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||
| 100 | 2 | $self->init_cmd; | |||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||
| 103 | sub init_cmd | ||||||||||||||||||||||||||||||||||||
| 104 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
init_cmd: called CC=1 SCAR=4.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 105 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||
| 107 | Devel::MAT::Tool::Show->register_extra( | ||||||||||||||||||||||||||||||||||||
| 108 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=45.1
| |||||||||||||||||||||||||||||||||||||
| 109 | 1 | my ( $sv ) = @_; | |||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||
| 111 | 1 | ▶ | $sv->is_future or return undef; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||
| 113 | 1 | my $state = $sv->future_state; | |||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||
| 115 | 1 | Devel::MAT::Cmd->printf( " %s state %s\n", | |||||||||||||||||||||||||||||||||||
| 116 | Devel::MAT::Cmd->format_symbol( "Future" ), | ||||||||||||||||||||||||||||||||||||
| 117 | $state, | ||||||||||||||||||||||||||||||||||||
| 118 | ); | ||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||
| 120 | match( $state : eq ) { | ||||||||||||||||||||||||||||||||||||
| 121 | case( "done" ) { | ||||||||||||||||||||||||||||||||||||
| 122 | 0 | my @result = $sv->future_result; | |||||||||||||||||||||||||||||||||||
| 123 | 0 | my @str; | |||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | push @str, "(empty)" if !@result; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | push @str, Devel::MAT::Cmd->format_sv_with_value( $result[0] ) if @result; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | push @str, "..." if @result > 1; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | Devel::MAT::Cmd->printf( " %s result: %s\n", | ||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$(Syntax::Keyword::Match/topic) eq "failed" and do {
my(@failure) = $sv->future_failure;
my @str;
push @str, "(empty)" unless @failure;
if (@failure) {
push @str, defined $failure[0]->pv ? "Devel::MAT::Cmd"->format_value($failure[0]->pv, "pv", 1) : "Devel::MAT::Cmd"->format_sv($failure[0]);
push @str, "..." if @failure > 1;
};
"Devel::MAT::Cmd"->printf(" %s failure: %s\n", "Devel::MAT::Cmd"->format_symbol("Future"), "String::Tagged"->join(", ", @str))
}
MC/DC0%0/2
$(Syntax::Keyword::Match/topic) eq "failed" and do {
my(@failure) = $sv->future_failure;
my @str;
push @str, "(empty)" unless @failure;
if (@failure) {
push @str, defined $failure[0]->pv ? "Devel::MAT::Cmd"->format_value($failure[0]->pv, "pv", 1) : "Devel::MAT::Cmd"->format_sv($failure[0]);
push @str, "..." if @failure > 1;
};
"Devel::MAT::Cmd"->printf(" %s failure: %s\n", "Devel::MAT::Cmd"->format_symbol("Future"), "String::Tagged"->join(", ", @str))
}
$(Syntax::Keyword::Match/topic) eq "failed"
do {
my(@failure) = $sv->future_failure;
my @str;
push @str, "(empty)" unless @failure;
if (@failure) {
push @str, defined $failure[0]->pv ? "Devel::MAT::Cmd"->format_value($failure[0]->pv, "pv", 1) : "Devel::MAT::Cmd"->format_sv($failure[0]);
push @str, "..." if @failure > 1;
};
"Devel::MAT::Cmd"->printf(" %s failure: %s\n", "Devel::MAT::Cmd"->format_symbol("Future"), "String::Tagged"->join(", ", @str))
}
Truth table0%0/3
A and B
A= $(Syntax::Keyword::Match/topic) eq "failed"B= do {
my(@failure) = $sv->future_failure;
my @str;
push @str, "(empty)" unless @failure;
if (@failure) {
push @str, defined $failure[0]->pv ? "Devel::MAT::Cmd"->format_value($failure[0]->pv, "pv", 1) : "Devel::MAT::Cmd"->format_sv($failure[0]);
push @str, "..." if @failure > 1;
};
"Devel::MAT::Cmd"->printf(" %s failure: %s\n", "Devel::MAT::Cmd"->format_symbol("Future"), "String::Tagged"->join(", ", @str))
}
| |||||||||||||||||||||||||||||||||||||
| 129 | Devel::MAT::Cmd->format_symbol( "Future" ), | ||||||||||||||||||||||||||||||||||||
| 130 | String::Tagged->join( ", ", @str ), | ||||||||||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | case( "failed" ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 134 | 0 | my @failure = $sv->future_failure; | |||||||||||||||||||||||||||||||||||
| 135 | 0 | my @str; | |||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | push @str, "(empty)" if !@failure; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if( @failure ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | push @str, defined $failure[0]->pv | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 139 | ? Devel::MAT::Cmd->format_value( $failure[0]->pv, pv => 1 ) | ||||||||||||||||||||||||||||||||||||
| 140 | : Devel::MAT::Cmd->format_sv( $failure[0] ); | ||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | push @str, "..." if @failure > 1; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||
| 144 | 0 | Devel::MAT::Cmd->printf( " %s failure: %s\n", | |||||||||||||||||||||||||||||||||||
| 145 | Devel::MAT::Cmd->format_symbol( "Future" ), | ||||||||||||||||||||||||||||||||||||
| 146 | String::Tagged->join( ", ", @str ), | ||||||||||||||||||||||||||||||||||||
| 147 | ); | ||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||
| 151 | 2 | ); | |||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||
| 154 | sub init_ui | ||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
init_ui: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 156 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 157 | 0 | my ( $ui ) = @_; | |||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||
| 159 | 0 | foreach (qw( pending done failed cancelled )) { | |||||||||||||||||||||||||||||||||||
| 160 | 0 | $ui->register_icon( name => "future-$_", svg => module_file( __PACKAGE__, "icons/future-$_.svg" ) ); | |||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||
| 163 | $ui->provides_sv_detail( | ||||||||||||||||||||||||||||||||||||
| 164 | type => "widget", | ||||||||||||||||||||||||||||||||||||
| 165 | title => "Future", | ||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | render => sub { $self->render_sv_detail( @_ ) }, | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||
| 167 | 0 | ); | |||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||
| 170 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||
| 172 | =cut | ||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||
| 174 | =head2 class_is_future | ||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||
| 176 | $ok = $tool->class_is_future( $pkg ); | ||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||
| 178 | Returns true if the given package is a C<Future> class. C<$pkg> may be either | ||||||||||||||||||||||||||||||||||||
| 179 | a C<Devel::MAT::SV> instance referring to a stash, or a plain string. | ||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||
| 181 | =cut | ||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||
| 183 | # TODO: This kind of logic might belong in Devel::MAT::SV itself | ||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||
| 185 | sub class_is_future | ||||||||||||||||||||||||||||||||||||
| 186 | 1236 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
class_is_future: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 187 | 1236 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 188 | 1236 | my ( $pkg ) = @_; | |||||||||||||||||||||||||||||||||||
| 189 | 1236 | ▶ | ref $pkg or $pkg = $self->{pmat}->find_symbol( "%${pkg}::" ); # stash | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||
| 191 | 1236 | ▶ | return $self->{classes}{$pkg->stashname} //= $self->_class_is_future( $pkg ); | ||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"classes"}{$pkg->stashname} //= $self->_class_is_future($pkg)
MC/DC0%0/2
$self->{"classes"}{$pkg->stashname} //= $self->_class_is_future($pkg)
$self->{"classes"}{$pkg->stashname}
$self->_class_is_future($pkg)
Truth table66%2/3
A //= B
A= $self->{"classes"}{$pkg->stashname}B= $self->_class_is_future($pkg)
| |||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||
| 194 | sub _class_is_future | ||||||||||||||||||||||||||||||||||||
| 195 | 847 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
_class_is_future: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||
| 196 | 847 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 197 | 847 | my ( $pkg ) = @_; | |||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||
| 199 | 847 | ▶ | return 1 if $pkg->stashname eq "Future"; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||
| 201 | 847 | ▶ | my $isagv = $pkg->value( "ISA" ) or return 0; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 202 | 377 | ▶ | my $isaav = $isagv->array or return 0; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||
| 204 | 377 | foreach my $superclass ( $isaav->elems ) { | |||||||||||||||||||||||||||||||||||
| 205 | 383 | ▶ | return 1 if $self->class_is_future( $superclass->pv ); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||
| 208 | 376 | return 0; | |||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||
| 211 | =head1 SV METHODS | ||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||
| 213 | This tool adds the following SV methods. | ||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||
| 215 | =cut | ||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||
| 217 | =head2 is_future (SV) | ||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||
| 219 | $ok = $sv->is_future; | ||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||
| 221 | Returns true if the C<Devel::MAT::SV> instance represents a C<Future> | ||||||||||||||||||||||||||||||||||||
| 222 | instance. | ||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||
| 224 | =cut | ||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||
| 226 | sub Devel::MAT::SV::is_future | ||||||||||||||||||||||||||||||||||||
| 227 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
is_future: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 228 | 8 | my $sv = shift; | |||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||
| 230 | 8 | return defined $sv->{tool_future}; | |||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||
| 233 | sub Devel::MAT::SV::_future_is_xs | ||||||||||||||||||||||||||||||||||||
| 234 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
_future_is_xs: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||
| 235 | 5 | my $sv = shift; | |||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||
| 237 | 5 | ▶ | return $sv->{tool_future} && $sv->{tool_future}[0]; | ||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$sv->{'tool_future'} && $sv->{'tool_future'}[0]
MC/DC0%0/2
$sv->{'tool_future'} && $sv->{'tool_future'}[0]
$sv->{'tool_future'}
$sv->{'tool_future'}[0]
Truth table33%1/3
A && B
A= $sv->{'tool_future'}B= $sv->{'tool_future'}[0]
| |||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||
| 240 | sub Devel::MAT::SV::_future_xs_struct | ||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
_future_xs_struct: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $sv = shift; | |||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $sv->basetype eq "SV" or return undef; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | my $ref = $sv->maybe_outref_named( "the FutureXS structure" ) or | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 247 | croak "Expected $sv to have a FutureXS structure"; | ||||||||||||||||||||||||||||||||||||
| 248 | 0 | return $ref->sv; | |||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||
| 251 | =head2 future_state (SV) | ||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||
| 253 | $state = $sv->future_state; | ||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||
| 255 | Returns a string describing the state of the given C<Future> instance; one of | ||||||||||||||||||||||||||||||||||||
| 256 | C<pending>, C<done>, C<failed> or C<cancelled>. | ||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||
| 258 | =cut | ||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||
| 260 | sub Devel::MAT::SV::future_state | ||||||||||||||||||||||||||||||||||||
| 261 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
future_state: called CC=12 SCAR=31.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 262 | 5 | my $sv = shift; | |||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||
| 264 | 5 | ▶ | $sv->is_future or croak "$sv is not a Future"; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||
| 266 | 5 | ▶ | if( $sv->_future_is_xs ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $struct = $sv->_future_xs_struct; | |||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if( $struct->field_named( "cancelled" ) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||
| 270 | 0 | return "cancelled"; | |||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||
| 272 | elsif( $struct->maybe_field_named( "the failure AV" ) ) { | ||||||||||||||||||||||||||||||||||||
| 273 | 0 | return "failed"; | |||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||
| 275 | elsif( $struct->field_named( "ready" ) ) { | ||||||||||||||||||||||||||||||||||||
| 276 | 0 | return "done"; | |||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||
| 278 | else { | ||||||||||||||||||||||||||||||||||||
| 279 | 0 | return "pending"; | |||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||
| 282 | else { | ||||||||||||||||||||||||||||||||||||
| 283 | 5 | ▶ | $sv->type eq "HASH" or | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 284 | croak "Expected $sv to be a HASH"; | ||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||
| 286 | 5 | my $tmp; | |||||||||||||||||||||||||||||||||||
| 287 | 5 | ▶ | if( $tmp = $sv->value( "cancelled" ) and $tmp->uv ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$tmp = $sv->value("cancelled") and $tmp->uv
MC/DC50%1/2
$tmp = $sv->value("cancelled") and $tmp->uv
$tmp = $sv->value("cancelled")
$tmp->uv
Truth table66%2/3
A and B
A= $tmp = $sv->value("cancelled")B= $tmp->uv
| |||||||||||||||||||||||||||||||||||||
| 288 | 1 | return "cancelled"; | |||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||
| 290 | elsif( $tmp = $sv->value( "failure" ) ) { | ||||||||||||||||||||||||||||||||||||
| 291 | 1 | return "failed"; | |||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||
| 293 | ▶ | elsif( $tmp = $sv->value( "ready" ) and $tmp->uv ) { | |||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$tmp = $sv->value("ready") and $tmp->uv
MC/DC50%1/2
$tmp = $sv->value("ready") and $tmp->uv
$tmp = $sv->value("ready")
$tmp->uv
Truth table66%2/3
A and B
A= $tmp = $sv->value("ready")B= $tmp->uv
| |||||||||||||||||||||||||||||||||||||
| 294 | 1 | return "done"; | |||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||
| 296 | else { | ||||||||||||||||||||||||||||||||||||
| 297 | 2 | return "pending"; | |||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||
| 302 | =head2 future_result | ||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||
| 304 | @result = $sv->future_result; | ||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||
| 306 | Returns a list of SVs containing the result of a successful C<Future>. | ||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||
| 308 | =cut | ||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||
| 310 | sub Devel::MAT::SV::future_result | ||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
future_result: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $sv = shift; | |||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $sv->is_future or croak "$sv is not a Future"; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | if( $sv->_future_is_xs ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $struct = $sv->_future_xs_struct; | |||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||
| 319 | 0 | return $struct->field_named( "the result AV" )->elems; | |||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||
| 321 | else { | ||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | $sv->type eq "HASH" or | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 323 | croak "Expected $sv to be a HASH"; | ||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||
| 325 | 0 | return $sv->value( "result" )->rv->elems; | |||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||
| 329 | =head2 future_failure | ||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||
| 331 | @failure = $sv->future_failure; | ||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||
| 333 | Returns a list of SVs containing the failure of a failed C<Future>. | ||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||
| 335 | =cut | ||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||
| 337 | sub Devel::MAT::SV::future_failure | ||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
future_failure: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $sv = shift; | |||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | $sv->is_future or croak "$sv is not a Future"; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if( $sv->_future_is_xs ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $struct = $sv->_future_xs_struct; | |||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||
| 346 | 0 | return $struct->field_named( "the failure AV" )->elems; | |||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||
| 348 | else { | ||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | $sv->type eq "HASH" or | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 350 | croak "Expected $sv to be a HASH"; | ||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||
| 352 | 0 | return $sv->value( "failure" )->rv->elems; | |||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||
| 356 | sub render_sv_detail | ||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
render_sv_detail: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 359 | 0 | my ( $sv ) = @_; | |||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | $self->is_future( $sv ) or return undef; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $state = $self->future_state( $sv ); | |||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||
| 365 | 0 | return Devel::MAT::UI->make_table( | |||||||||||||||||||||||||||||||||||
| 366 | State => Devel::MAT::UI->make_widget_text_icon( ucfirst $state, "future-$state" ), | ||||||||||||||||||||||||||||||||||||
| 367 | ); | ||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||
| 370 | =head1 EXTENSIONS TO FIND | ||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||
| 372 | =cut | ||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||
| 374 | package # hide | ||||||||||||||||||||||||||||||||||||
| 375 | Devel::MAT::Tool::Find::filter::future; | ||||||||||||||||||||||||||||||||||||
| 376 | 3 | ▶ | use base qw( Devel::MAT::Tool::Find::filter ); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||
| 378 | =head2 find future | ||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||
| 380 | pmat> find future -f | ||||||||||||||||||||||||||||||||||||
| 381 | HASH(2)=Future at 0x55d43c854660: Future(failed) - SCALAR(PV) at 0x55d43c8546f0 = "It failed" | ||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||
| 383 | Lists SVs that are Future instances, optionally matching only futures in a | ||||||||||||||||||||||||||||||||||||
| 384 | given state. | ||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||
| 386 | Takes the following named options | ||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||
| 388 | =over 4 | ||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||
| 390 | =item --pending, -p | ||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||
| 392 | Lists only Futures in the pending state | ||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||
| 394 | =item --done, -d | ||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||
| 396 | Lists only Futures in the done state | ||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||
| 398 | =item --failed, -f | ||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||
| 400 | Lists only Futures in the failed state | ||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||
| 402 | =item --cancelled, -c | ||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||
| 404 | Lists only Futures in the cancelled state | ||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||
| 406 | =back | ||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||
| 408 | =cut | ||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||
| 410 | 3 | ▶ | use constant FILTER_DESC => "Future instances"; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||
| 412 | 3 | ▶ | use constant FILTER_OPTS => ( | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 413 | pending => { help => "only pending futures", | ||||||||||||||||||||||||||||||||||||
| 414 | alias => "p" }, | ||||||||||||||||||||||||||||||||||||
| 415 | done => { help => "only done futures", | ||||||||||||||||||||||||||||||||||||
| 416 | alias => "d" }, | ||||||||||||||||||||||||||||||||||||
| 417 | failed => { help => "only failed futures", | ||||||||||||||||||||||||||||||||||||
| 418 | alias => "f" }, | ||||||||||||||||||||||||||||||||||||
| 419 | cancelled => { help => "only cancelled futures", | ||||||||||||||||||||||||||||||||||||
| 420 | alias => "c" }, | ||||||||||||||||||||||||||||||||||||
| 421 | 3 | ); | |||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||
| 423 | sub build | ||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 426 | 0 | my $inv = shift; | |||||||||||||||||||||||||||||||||||
| 427 | 0 | my %opts = %{ +shift }; | |||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||
| 429 | 0 | my %only; | |||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | $opts{$_} and $only{$_}++ for qw( pending done failed cancelled ); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||
| 433 | 0 | my ( $sv ) = @_; | |||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | return unless $sv->is_future; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $state = $sv->future_state; | |||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | return if %only and !$only{$state}; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
%only and not $only{$state}
MC/DC0%0/2
%only and not $only{$state}
%only
not $only{$state}
Truth table0%0/3
A and not(B)
A= %onlyB= not $only{$state}
| |||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $ret = String::Tagged->from_sprintf( "%s(%s)", | |||||||||||||||||||||||||||||||||||
| 442 | Devel::MAT::Cmd->format_symbol( "Future" ), # TODO: full class name of this instance? | ||||||||||||||||||||||||||||||||||||
| 443 | Devel::MAT::Cmd->format_note( $state, 1 ), | ||||||||||||||||||||||||||||||||||||
| 444 | ); | ||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||
| 446 | match( $state : eq ) { | ||||||||||||||||||||||||||||||||||||
| 447 | case( "done" ) { | ||||||||||||||||||||||||||||||||||||
| 448 | 0 | my @result = $sv->future_result; | |||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | $ret .= " - (empty)" if !@result; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | $ret .= " - " . Devel::MAT::Cmd->format_sv_with_value( $result[0] ) if @result; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | $ret .= ", ..." if @result > 1; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$(Syntax::Keyword::Match/topic) eq "failed" and do {
my(@failure) = $sv->future_failure;
$ret .= ' - (empty)' unless @failure;
if (@failure) {
$ret .= ' - ' . (defined $failure[0]->pv ? "Devel::MAT::Cmd"->format_value($failure[0]->pv, "pv", 1) : "Devel::MAT::Cmd"->format_sv($failure[0]));
$ret .= ', ...' if @failure > 1;
}
}
MC/DC0%0/2
$(Syntax::Keyword::Match/topic) eq "failed" and do {
my(@failure) = $sv->future_failure;
$ret .= ' - (empty)' unless @failure;
if (@failure) {
$ret .= ' - ' . (defined $failure[0]->pv ? "Devel::MAT::Cmd"->format_value($failure[0]->pv, "pv", 1) : "Devel::MAT::Cmd"->format_sv($failure[0]));
$ret .= ', ...' if @failure > 1;
}
}
$(Syntax::Keyword::Match/topic) eq "failed"
do {
my(@failure) = $sv->future_failure;
$ret .= ' - (empty)' unless @failure;
if (@failure) {
$ret .= ' - ' . (defined $failure[0]->pv ? "Devel::MAT::Cmd"->format_value($failure[0]->pv, "pv", 1) : "Devel::MAT::Cmd"->format_sv($failure[0]));
$ret .= ', ...' if @failure > 1;
}
}
Truth table0%0/3
A and B
A= $(Syntax::Keyword::Match/topic) eq "failed"B= do {
my(@failure) = $sv->future_failure;
$ret .= ' - (empty)' unless @failure;
if (@failure) {
$ret .= ' - ' . (defined $failure[0]->pv ? "Devel::MAT::Cmd"->format_value($failure[0]->pv, "pv", 1) : "Devel::MAT::Cmd"->format_sv($failure[0]));
$ret .= ', ...' if @failure > 1;
}
}
| |||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | case( "failed" ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 454 | 0 | my @failure = $sv->future_failure; | |||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | $ret .= " - (empty)" if !@failure; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if( @failure ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | $ret .= " - " . ( defined $failure[0]->pv | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 458 | ? Devel::MAT::Cmd->format_value( $failure[0]->pv, pv => 1 ) | ||||||||||||||||||||||||||||||||||||
| 459 | : Devel::MAT::Cmd->format_sv( $failure[0] ) ); | ||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | $ret .= ", ..." if @failure > 1; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||
| 465 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||
| 467 | 0 | } | |||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||
| 469 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||
| 471 | Paul Evans <leonerd@leonerd.org.uk> | ||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||
| 473 | =cut | ||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||
| 475 | 3 | 0x55AA; | |||||||||||||||||||||||||||||||||||