File tree 13 files changed +76
-130
lines changed
13 files changed +76
-130
lines changed Original file line number Diff line number Diff line change 1
1
# !./perl -w
2
2
$| =1;
3
+ use Config;
3
4
BEGIN {
4
- require Config; Config-> import ;
5
5
if ($Config {' extensions' } !~ / \b Opcode\b / && $Config {' osname' } ne ' VMS' ) {
6
6
print " 1..0\n " ;
7
7
exit 0;
8
8
}
9
-
10
9
}
11
10
12
11
# Tests Todo:
@@ -24,11 +23,11 @@ use Test::More;
24
23
25
24
my $cpt ;
26
25
# create and destroy some automatic Safe compartments first
27
- $cpt = new Safe or die ;
28
- $cpt = new Safe or die ;
29
- $cpt = new Safe or die ;
26
+ $cpt = Safe-> new or die ;
27
+ $cpt = Safe-> new or die ;
28
+ $cpt = Safe-> new or die ;
30
29
31
- $cpt = new Safe " Root" or die ;
30
+ $cpt = Safe-> new( " Root" ) or die ;
32
31
33
32
foreach (1..3) {
34
33
$foo = 42;
Original file line number Diff line number Diff line change 1
1
# !./perl -w
2
2
$| =1;
3
+ use Config;
3
4
BEGIN {
4
- require Config; Config-> import ;
5
5
if ($Config {' extensions' } !~ / \b Opcode\b / && $Config {' osname' } ne ' VMS' ) {
6
6
print " 1..0\n " ;
7
7
exit 0;
@@ -28,10 +28,10 @@ $Root::foo .= "";
28
28
29
29
my $cpt ;
30
30
# create and destroy a couple of automatic Safe compartments first
31
- $cpt = new Safe or die ;
32
- $cpt = new Safe or die ;
31
+ $cpt = Safe-> new or die ;
32
+ $cpt = Safe-> new or die ;
33
33
34
- $cpt = new Safe " Root" ;
34
+ $cpt = Safe-> new( " Root" ) ;
35
35
36
36
$cpt -> permit(qw( :base_io) );
37
37
Original file line number Diff line number Diff line change 1
1
# !perl -w
2
2
3
- BEGIN {
4
- require Config; Config-> import ;
5
- if ($Config {' extensions' } !~ / \b Opcode\b /
6
- && $Config {' extensions' } !~ / \b POSIX\b /
7
- && $Config {' osname' } ne ' VMS' )
8
- {
9
- print " 1..0\n " ;
10
- exit 0;
11
- }
12
- }
3
+ use Config;
4
+ use Test::More
5
+ $Config {' extensions' } =~ / \b Opcode\b /
6
+ || $Config {' extensions' } =~ / \b POSIX\b /
7
+ || $Config {' osname' } eq ' VMS'
8
+ ? (tests => 2)
9
+ : (skip_all => " no Opcode and POSIX extensions and we're not on VMS" );
13
10
14
11
use strict;
15
12
use warnings;
16
13
use POSIX qw( ceil) ;
17
- use Test::More tests => 2;
18
14
use Safe;
19
15
20
- my $safe = new Safe;
16
+ my $safe = Safe-> new ;
21
17
$safe -> deny(' add' );
22
18
23
19
my $masksize = ceil( Opcode::opcodes / 8 );
@@ -30,7 +26,7 @@ $safe->reval( q{$x + $y} );
30
26
ok( $@ =~ / ^'?addition \(\+\) '? trapped by operation mask/ ,
31
27
' opmask still in place with reval' );
32
28
33
- my $safe2 = new Safe;
29
+ my $safe2 = Safe-> new ;
34
30
$safe2 -> deny(' add' );
35
31
36
32
open my $fh , ' >nasty.pl' or die " Can't write nasty.pl: $! \n " ;
Original file line number Diff line number Diff line change 1
1
# !perl
2
2
3
- BEGIN {
4
- require Config;
5
- Config-> import ;
6
- if ($Config {' extensions' } !~ / \b Opcode\b / ) {
7
- print " 1..0\n " ;
8
- exit 0;
9
- }
10
- # Can we load the version module ?
11
- eval { require version; 1 } or do {
12
- print " 1..0 # no version.pm\n " ;
13
- exit 0;
14
- };
15
- delete $INC {" version.pm" };
16
- }
3
+ use Config;
4
+ use Test::More
5
+ $Config {' extensions' } =~ / \b Opcode\b /
6
+ && eval { require version; delete $INC {" version.pm" }; 1 }
7
+ ? (tests => 4)
8
+ : (skip_all => " no Opcode extension or can't load version.pm" );
17
9
18
10
use strict;
19
- use Test::More;
20
11
use Safe;
21
- plan(tests => 4);
22
12
23
- my $c = new Safe;
13
+ my $c = Safe-> new ;
24
14
$c -> permit(qw( require caller entereval unpack rand) );
25
15
my $r = $c -> reval(q{ use version; 1 } );
26
16
ok( defined $r , " Can load version.pm in a Safe compartment" ) or diag $@ ;
Original file line number Diff line number Diff line change 1
- BEGIN {
2
- if ($] < 5.010) {
3
- print " 1..0\n " ;
4
- exit 0;
5
- }
6
- require Config;
7
- Config-> import ;
8
- if ($Config {' extensions' } !~ / \b Opcode\b / ) {
9
- print " 1..0\n " ;
10
- exit 0;
11
- }
12
- }
13
-
14
1
use strict;
15
- use Test::More;
2
+ use Config;
3
+ use Test::More
4
+ $] < 5.010 || $Config {' extensions' } =~ / \b Opcode\b /
5
+ ? (tests => 1)
6
+ : (skip_all => " pre-5.10 perl or no Opcode extension" );
16
7
use Safe;
17
- plan(tests => 1);
18
8
19
9
BEGIN { Safe-> new }
20
10
" foo" =~ / (?<foo>fo*)/ ;
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ sub testop {
46
46
my ($op , $opname , $code ) = @_ ;
47
47
pass(" $op : skipped" ) and return if $code =~ / ^SKIP/ ;
48
48
pass(" $op : skipped" ) and return if $code =~ m : //|~~: && $] < 5.010;
49
- my $c = new Safe;
49
+ my $c = Safe-> new ;
50
50
$c -> deny_only($op );
51
51
$c -> reval($code );
52
52
like($@ , qr / '\Q $opname \E ' trapped by operation mask/ , $op );
Original file line number Diff line number Diff line change 1
1
# !perl -w
2
2
3
- BEGIN {
4
- require Config; Config-> import ;
5
- if ($Config {' extensions' } !~ / \b Opcode\b / ) {
6
- print " 1..0\n " ;
7
- exit 0;
8
- }
9
- }
10
-
11
- use Test::More tests => 3;
3
+ use Config;
4
+ use Test::More
5
+ $Config {' extensions' } =~ / \b Opcode\b /
6
+ ? (tests => 3)
7
+ : (skip_all => " no Opcode extension" );
12
8
use Safe;
13
9
14
10
my $c ; my $r ;
15
11
my $snippet = q{
16
12
my $foo = qr/foo/;
17
13
ref $foo;
18
14
} ;
19
- $c = new Safe;
15
+ $c = Safe-> new ;
20
16
$r = $c -> reval($snippet );
21
17
is( $r , " Safe::Root0::Regexp" );
22
18
$r or diag $@ ;
@@ -28,7 +24,7 @@ is( $r, "Safe::Root0::Regexp" );
28
24
$r or diag $@ ;
29
25
30
26
# try with a new compartment
31
- $c = new Safe;
27
+ $c = Safe-> new ;
32
28
$r = $c -> reval($snippet );
33
29
is( $r , " Safe::Root1::Regexp" );
34
30
$r or diag $@ ;
Original file line number Diff line number Diff line change 1
1
# !perl
2
2
3
- BEGIN {
4
- require Config;
5
- Config-> import ;
6
- if ($Config {' extensions' } !~ / \b Opcode\b / ) {
7
- print " 1..0\n " ;
8
- exit 0;
9
- }
10
- }
11
-
12
3
use strict;
13
4
use warnings;
14
- use Test::More;
5
+ use Config;
6
+ use Test::More
7
+ $Config {' extensions' } =~ / \b Opcode\b /
8
+ ? (tests => 1)
9
+ : (skip_all => " no Opcode extension" );
15
10
use Safe;
16
- plan(tests => 1);
17
11
18
- my $c = new Safe;
12
+ my $c = Safe-> new ;
19
13
20
14
{
21
15
package My::Controller ;
Original file line number Diff line number Diff line change 1
1
# !perl
2
-
3
- BEGIN {
4
- require Config;
5
- Config-> import ;
6
- if ($Config {' extensions' } !~ / \b Opcode\b / ) {
7
- print " 1..0\n " ;
8
- exit 0;
9
- }
10
- }
11
-
12
2
use strict;
13
3
use warnings;
14
- use Test::More;
4
+
5
+ use Config;
6
+ use Test::More
7
+ $Config {' extensions' } =~ / \b Opcode\b /
8
+ ? (tests => 2)
9
+ : (skip_all => " no Opcode extension" );
15
10
use Safe;
16
- plan(tests => 2);
17
11
18
12
$SIG {$_ } = $_ for keys %SIG ;
19
13
my %saved_SIG = %SIG ;
Original file line number Diff line number Diff line change 1
1
# !perl -w
2
- $| =1;
3
- BEGIN {
4
- require Config; Config-> import ;
5
- if ($Config {' extensions' } !~ / \b Opcode\b / && $Config {' osname' } ne ' VMS' ) {
6
- print " 1..0\n " ;
7
- exit 0;
8
- }
9
- }
2
+ use Config;
3
+ use Test::More
4
+ $Config {' extensions' } =~ / \b Opcode\b / || $Config {' osname' } eq ' VMS'
5
+ ? (tests => 10)
6
+ : (skip_all => " no Opcode extension and we're not on VMS" );
10
7
11
8
use Safe 1.00;
12
- use Test::More tests => 10;
9
+
10
+ $| = 1;
13
11
14
12
my $safe = Safe-> new(' PLPerl' );
15
13
$safe -> permit_only(qw( :default sort) );
Original file line number Diff line number Diff line change 1
1
# !perl
2
2
3
- BEGIN {
4
- require Config;
5
- Config-> import ;
6
- if ($Config {' extensions' } !~ / \b Opcode\b / ) {
7
- print " 1..0\n " ;
8
- exit 0;
9
- }
10
- }
3
+ use Config;
4
+ use Test::More
5
+ $Config {' extensions' } =~ / \b Opcode\b /
6
+ ? (tests => 6)
7
+ : (skip_all => " no Opcode extension" );
11
8
12
9
use strict;
13
10
use warnings;
14
- use Test::More;
15
11
use Safe;
16
- plan(tests => 6);
17
12
18
- my $c = new Safe;
13
+ my $c = Safe-> new ;
19
14
$c -> permit(qw( require caller) );
20
15
21
16
my $no_warn_redef = ($] != 5.008009)
Original file line number Diff line number Diff line change 1
1
# !perl -w
2
- $| =1;
3
- BEGIN {
4
- require Config; Config-> import ;
5
- if ($Config {' extensions' } !~ / \b Opcode\b / && $Config {' osname' } ne ' VMS' ) {
6
- print " 1..0\n " ;
7
- exit 0;
8
- }
9
- }
10
-
11
- use Test::More tests => 7;
2
+ use Config;
3
+ use Test::More
4
+ $Config {' extensions' } =~ / \b Opcode\b / || $Config {' osname' } eq ' VMS'
5
+ ? (tests => 7)
6
+ : (skip_all => " no Opcode extension and we're not on VMS" );
12
7
13
8
use Safe 1.00;
14
9
use Opcode qw( full_opset) ;
15
10
11
+ $| = 1;
16
12
pass;
17
13
18
14
my $safe = Safe-> new(' PLPerl' );
Original file line number Diff line number Diff line change 1
1
# !perl -w
2
2
3
- $| =1;
4
- BEGIN {
5
- require Config; Config-> import ;
6
- if ($Config {' extensions' } !~ / \b Opcode\b / && $Config {' osname' } ne ' VMS' ) {
7
- print " 1..0\n " ;
8
- exit 0;
9
- }
10
- }
3
+ use Config;
4
+ use Test::More
5
+ $Config {' extensions' } =~ / \b Opcode\b / || $Config {' osname' } eq ' VMS'
6
+ ? (tests => 10)
7
+ : (skip_all => " no Opcode extension and we're not on VMS" );
11
8
12
9
use strict;
13
10
use Safe 1.00;
14
- use Test::More tests => 10;
11
+
12
+ $| = 1;
15
13
16
14
my $safe = Safe-> new(' PLPerl' );
17
15
$safe -> permit_only(qw( :default sort) );
You can’t perform that action at this time.
0 commit comments