Skip to content

Commit

Permalink
preserve global variables with local, not copy/restore
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbs committed Jan 7, 2023
1 parent 8bb2c23 commit 3e987aa
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/Test/Deep.pm
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,15 @@ while (my ($pkg, $name) = splice @constructors, 0, 2)
my $file = "$full_pkg.pm";
$file =~ s#::#/#g;
my $sub = sub {

# We might be in the middle of testing one of the globals
# that require() overwrites. To simplify test authorship,
# we put those overwritten values back below.
my $dollar_at = $@;
my $dollar_bang = $!;
my $dollar_e = $^E;
# We might be in the middle of testing one of the globals that require()
# overwrites. To simplify test authorship, we'll preserve any existing
# value.
local $@;
local $!;
local $^E;

require $file;

$@ = $dollar_at;
$! = $dollar_bang;
$^E = $dollar_e;

return $full_pkg->new(@_);
};
{
Expand Down

0 comments on commit 3e987aa

Please sign in to comment.