Complement to change #17976 :
[p5sagit/p5-mst-13.2.git] / ext / Safe / safe3.t
index c924762..6265d14 100644 (file)
@@ -18,16 +18,31 @@ BEGIN {
 use strict;
 use warnings;
 use POSIX qw(ceil);
-use Test::More tests => 1;
+use Test::More tests => 2;
 use Safe;
 
 my $safe = new Safe;
 $safe->deny('add');
 
+my $masksize = ceil( Opcode::opcodes / 8 );
 # Attempt to change the opmask from within the safe compartment
-$safe->reval( qq{\$_[1] = q/\0/ x } . ceil( Opcode::opcodes / 8 ) );
+$safe->reval( qq{\$_[1] = qq/\0/ x } . $masksize );
 
 # Check that it didn't work
 $safe->reval( q{$x + $y} );
 like( $@, qr/^'?addition \(\+\)'? trapped by operation mask/,
-           'opmask still in place' );
+           'opmask still in place with reval' );
+
+my $safe2 = new Safe;
+$safe2->deny('add');
+
+open my $fh, '>nasty.pl' or die "Can't write nasty.pl: $!\n";
+print $fh <<EOF;
+\$_[1] = "\0" x $masksize;
+EOF
+close $fh;
+$safe2->rdo('nasty.pl');
+$safe2->reval( q{$x + $y} );
+like( $@, qr/^'?addition \(\+\)'? trapped by operation mask/,
+           'opmask still in place with rdo' );
+END { unlink 'nasty.pl' }