Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (29 sloc) 0.681 kb
use strict;
use warnings;
use Test::More;
use TryCatch;
my $last_context;
sub fun {
my ($should_die) = @_;
try {
die 1 if $should_die;
$last_context = wantarray;
}
catch ($e where { /^1/ }) {
$last_context = wantarray;
}
}
my @v;
$v[0] = fun();
is($last_context, '', "Scalar try context preserved");
@v = fun();
is($last_context, 1, "Array try context preserved");
fun();
is($last_context, undef, "void try context preserved");
$v[0] = fun(1);
is($last_context, '', "Scalar catch context preserved");
@v = fun(1);
is($last_context, 1, "Array catch context preserved");
fun(1);
is($last_context, undef, "void catch context preserved");
done_testing;
Jump to Line
Something went wrong with that request. Please try again.