Jerry D. Hedden [Fri, 7 Aug 2009 09:28:15 +0000 (11:28 +0200)]
[RT CPAN #48505]
The "no warnings 'redefined'" directives in the compartments
in t/safeuniversal.t cause test failures under 5.8.9 because
warnings.pm has a 'use Carp' directive and Carp.pm uses
'eval' to 'require Carp::Heavy'.
The attached patch replaces the "no warnings 'redefined'"
directive with a $SIG{__WARN__} trap for 5.8.9. While the
redefine warning for UNIVERSAL::can is suppressed by the
trap, the warning UNIVERSAL::isa still shows up. However,
the failing test will now pass under 5.8.9.
my $c = new Safe;
$c->permit(qw(require caller));
-my $r = $c->reval(q!
- no warnings 'redefine';
+my $no_warn_redef = ($] != 5.008009)
+ ? q(no warnings 'redefine';)
+ : q($SIG{__WARN__}=sub{};);
+my $r = $c->reval($no_warn_redef . q!
sub UNIVERSAL::isa { "pwned" }
(bless[],"Foo")->isa("Foo");
!);
sub Foo::foo {}
-$r = $c->reval(q!
- no warnings 'redefine';
+$r = $c->reval($no_warn_redef . q!
sub UNIVERSAL::can { "pwned" }
(bless[],"Foo")->can("foo");
!);