(plus tests to check this)
p4raw-id: //depot/perl@24374
sub longmess {
{
- local $@;
- # XXX fix require to not clear $@?
+ local($@, $!);
+ # XXX fix require to not clear $@ or $!?
# don't use require unless we need to (for Safe compartments)
require Carp::Heavy unless $INC{"Carp/Heavy.pm"};
}
sub shortmess { # Short-circuit &longmess if called via multiple packages
{
- local $@;
- # XXX fix require to not clear $@?
+ local($@, $!);
+ # XXX fix require to not clear $@ or $!?
# don't use require unless we need to (for Safe compartments)
require Carp::Heavy unless $INC{"Carp/Heavy.pm"};
}
use Carp qw(carp cluck croak confess);
-plan tests => 19;
+plan tests => 21;
ok 1;
main::w(1);
}
}
+
+# Check that croak() and confess() don't clobber $!
+runperl(prog => 'use Carp; $@=q{Phooey}; $!=42; croak(q{Dead})', stderr => 1);
+is($?>>8, 42, 'croak() doesn\'t clobber $!');
+runperl(prog => 'use Carp; $@=q{Phooey}; $!=42; confess(q{Dead})', stderr => 1);
+is($?>>8, 42, 'confess() doesn\'t clobber $!');