Moose/Util.pm

filter: Statementstmt 100% 29 / 29 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 91.1% 41 / 45 CC 6 SCAR 14.0
CC
6
Cov
92%
context_do
6.1
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« Moose/Role/Executor.pm ↑ Summary Moose/Executor/Parallel.pm »
1 package Test::Class::Moose::Util;
2  
3 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 30 our $VERSION = '1.00';
7  
8 30 ▶use Test2::API qw( context );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 30 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 30 our @EXPORT_OK = qw( context_do );
13  
14 # This is identical to the version in Test2::API except we set level to 0
15 # rather than 1.
16 538 ▶sub context_do (&;@) {
Subroutine context_do: called CC=6 SCAR=18.0
Pod undocumented
17 538 my $code = shift;
18 538 my @args = @_;
19  
20 538 my $ctx = context( level => 0 );
21  
22 538 my $want = wantarray;
23  
24 538 my @out;
25 538 my $ok = eval {
26 538 ▶ $want ? @out
Branch: 2 branches
BranchTrueFalseTotal
$want ? : 0 538 538
defined $want ? : 348 190 538
27 = $code->( $ctx, @args )
28 : defined($want) ? $out[0]
29 = $code->( $ctx, @args )
30 : $code->( $ctx, @args );
31 528 1;
32 };
33 528 my $err = $@;
34  
35 528 $ctx->release;
36  
37 528 ▶ die $err unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 528 528
38  
39 528 ▶ return @out if $want;
Branch: 1 branch
BranchTrueFalseTotal
if $want 0 528 528
40 528 ▶ return $out[0] if defined $want;
Branch: 1 branch
BranchTrueFalseTotal
if defined $want 348 180 528
41 180 return;
42 }
43  
44 30 1;
45  
46 # ABSTRACT: Internal utilities
47  
48 __END__
« Moose/Role/Executor.pm ↑ Summary Moose/Executor/Parallel.pm »