Updated Maintainers.pl to note that p5p/blead is responsible for IO
[p5sagit/p5-mst-13.2.git] / ext / Safe / t / safe3.t
1 #!perl -w
2
3 BEGIN {
4     if ($ENV{PERL_CORE}) {
5         chdir 't' if -d 't';
6         @INC = '../lib';
7     }
8     require Config; import Config;
9     if ($Config{'extensions'} !~ /\bOpcode\b/
10         && $Config{'extensions'} !~ /\bPOSIX\b/
11         && $Config{'osname'} ne 'VMS')
12     {
13         print "1..0\n";
14         exit 0;
15     }
16 }
17
18 use strict;
19 use warnings;
20 use POSIX qw(ceil);
21 use Test::More tests => 2;
22 use Safe;
23
24 my $safe = new Safe;
25 $safe->deny('add');
26
27 my $masksize = ceil( Opcode::opcodes / 8 );
28 # Attempt to change the opmask from within the safe compartment
29 $safe->reval( qq{\$_[1] = qq/\0/ x } . $masksize );
30
31 # Check that it didn't work
32 $safe->reval( q{$x + $y} );
33 # Written this way to keep the Test::More that comes with perl 5.6.2 happy
34 ok( $@ =~ /^'?addition \(\+\)'? trapped by operation mask/,
35             'opmask still in place with reval' );
36
37 my $safe2 = new Safe;
38 $safe2->deny('add');
39
40 open my $fh, '>nasty.pl' or die "Can't write nasty.pl: $!\n";
41 print $fh <<EOF;
42 \$_[1] = "\0" x $masksize;
43 EOF
44 close $fh;
45 $safe2->rdo('nasty.pl');
46 $safe2->reval( q{$x + $y} );
47 # Written this way to keep the Test::More that comes with perl 5.6.2 happy
48 ok( $@ =~ /^'?addition \(\+\)'? trapped by operation mask/,
49             'opmask still in place with rdo' );
50 END { unlink 'nasty.pl' }