Subject: | Calling context not handled properly |
The following test script fails:
#!perl
use strict;
use Test::More 'no_plan';
use Time::Out 'timeout';
my $sub = sub {
wantarray ? 'array' : 'scalar';
};
{
my $ret = $sub->();
is $ret, 'scalar';
}
{
my $ret = timeout 100 => $sub;
is $ret, 'scalar'; # array is returned here
}
__END__
Probably the wantarray check has to be done within timeout()'s eval block, where $code is executed, because here the calling context has to be set correctly.