| 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
| |||||||||||||||
| 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
| |||||||||||||||
| 38 | |||||||||||||||
| 39 | 528 | ▶ | return @out if $want; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 40 | 528 | ▶ | return $out[0] if defined $want; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 41 | 180 | return; | |||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 30 | 1; | |||||||||||||
| 45 | |||||||||||||||
| 46 | # ABSTRACT: Internal utilities | ||||||||||||||
| 47 | |||||||||||||||
| 48 | __END__ | ||||||||||||||