Fix bug #17744, suggested by Andreas Jurenda,
[p5sagit/p5-mst-13.2.git] / ext / Safe / safe3.t
CommitLineData
33f7e1aa 1#!perl
2
3BEGIN {
4 if ($ENV{PERL_CORE}) {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 require Config; import Config;
8 if ($Config{'extensions'} !~ /\bOpcode\b/
9 && $Config{'extensions'} !~ /\bPOSIX\b/
10 && $Config{'osname'} ne 'VMS')
11 {
12 print "1..0\n";
13 exit 0;
14 }
15 }
16}
17
18use strict;
19use warnings;
20use POSIX qw(ceil);
21use Test::More tests => 1;
22use Safe;
23
24my $safe = new Safe;
25$safe->deny('add');
26
27# Attempt to change the opmask from within the safe compartment
28$safe->reval( qq{\$_[1] = q/\0/ x } . ceil( Opcode::opcodes / 8 ) );
29
30# Check that it didn't work
31$safe->reval( q{$x + $y} );
32like( $@, qr/^'?addition \(\+\)'? trapped by operation mask/,
33 'opmask still in place' );