Syntax-Feature-Try

 view release on metacpan or  search on metacpan

t/last_op_in_block.t  view on Meta::CPAN

use test_tools qw/ test_syntax_error compile_ok /;

use syntax 'try';

our $wantarray;

sub save_local_context {
    $wantarray = wantarray;
}

sub test_void_context(&) {
    my ($coderef) = @_;
    local $Test::Builder::Level = $Test::Builder::Level + 1;

    my $scalar = $coderef->();
    is($wantarray, undef, "for scalar context it is undef");

    my @array = $coderef->();
    is($wantarray, undef, "for list context it is undef");

    $coderef->();

t/wantarray.t  view on Meta::CPAN

/;

use FindBin qw/ $Bin /;
use lib "$Bin/lib";
use test_tools qw/ test_syntax_error compile_ok /;

use syntax 'try';

our $wantarray;

sub test_wantarray(&) {
    my ($coderef) = @_;
    local $Test::Builder::Level = $Test::Builder::Level + 1;

    my $scalar = $coderef->();
    is($wantarray, '', "scalar context ok");

    my @array = $coderef->();
    is($wantarray, 1, "list context ok");

    $coderef->();



( run in 0.470 second using v1.01-cache-2.11-cpan-49f99fa48dc )