summaryrefslogtreecommitdiff
path: root/ext/Safe/safe3.t
blob: c924762faa5aa5ec85d772f11e8748356ca0b977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!perl

BEGIN {
    if ($ENV{PERL_CORE}) {
	chdir 't' if -d 't';
	@INC = '../lib';
	require Config; import Config;
	if ($Config{'extensions'} !~ /\bOpcode\b/
	    && $Config{'extensions'} !~ /\bPOSIX\b/
	    && $Config{'osname'} ne 'VMS')
	{
	    print "1..0\n";
	    exit 0;
	}
    }
}

use strict;
use warnings;
use POSIX qw(ceil);
use Test::More tests => 1;
use Safe;

my $safe = new Safe;
$safe->deny('add');

# Attempt to change the opmask from within the safe compartment
$safe->reval( qq{\$_[1] = q/\0/ x } . ceil( Opcode::opcodes / 8 ) );

# Check that it didn't work
$safe->reval( q{$x + $y} );
like( $@, qr/^'?addition \(\+\)'? trapped by operation mask/,
	    'opmask still in place' );