Skip to content

Commit

Permalink
fix load-old tests on 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed Aug 19, 2016
1 parent ee8ffc3 commit d9e7524
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
18 changes: 16 additions & 2 deletions xt/load-old-scalar-util.t
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,22 @@ END_SUB_UTIL
);
unshift @INC, sub {
if (my $code = $modules{$_[1]}) {
open my $fh, '<', \$code;
return $fh;
if ("$]" >= 5.008) {
open my $fh, '<', \$code
or die "error loading module: $!";
return $fh;
}
else {
my $pos = 0;
my $last = length $code;
return (sub {
return 0 if $pos == $last;
my $next = (1 + index $code, "\n", $pos) || $last;
$_ .= substr $code, $pos, $next - $pos;
$pos = $next;
return 1;
});
}
}
return;
};
Expand Down
18 changes: 16 additions & 2 deletions xt/load-old-sub-util.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,22 @@ END_SUB_UTIL
);
unshift @INC, sub {
if (my $code = $modules{$_[1]}) {
open my $fh, '<', \$code;
return $fh;
if ("$]" >= 5.008) {
open my $fh, '<', \$code
or die "error loading module: $!";
return $fh;
}
else {
my $pos = 0;
my $last = length $code;
return (sub {
return 0 if $pos == $last;
my $next = (1 + index $code, "\n", $pos) || $last;
$_ .= substr $code, $pos, $next - $pos;
$pos = $next;
return 1;
});
}
}
return;
};
Expand Down

0 comments on commit d9e7524

Please sign in to comment.