In perl 5.22, PV can return an empty string as well as undefined, so we
need to test the length before using it as a variable name.
Revision history for Eval-WithLexicals
+ - fix failures on threaded perl 5.22 (RT#102841)
+
1.003002 - 2014-12-23
- fix test failures on perl 5.21.7 (RT#101086; thanks, Father Chrysostomos!)
sub capture_list {
my $pad_capture = \&Eval::WithLexicals::Cage::pad_capture;
- my @names = grep defined && $_ ne '&', map $_->PV, grep $_->can('PV'),
+ my @names = grep defined && length && $_ ne '&', map $_->PV, grep $_->can('PV'),
svref_2object($pad_capture)->OUTSIDE->PADLIST->ARRAYelt(0)->ARRAY;
$Eval::WithLexicals::current_code .=
'+{ '.join(', ', map "'$_' => \\$_", @names).' };'
is $eval->hints->{q{%^H}}->{hint_hash_pragma}, 'param',
"Lexical pragma captured";
+$eval->eval('my $x = 1');
+is_deeply(
+ $eval->lexicals->{'$x'}, \1,
+ 'Lexical captured when preserving hints',
+);
+
done_testing;