summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/dist/Safe/t/saferegexp.t
blob: 2719ca120256f40426c4ce5fe01e0e73680ba3c5 (plain) (blame)
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
34
#!perl -w

BEGIN {
    require Config; import Config;
    if ($Config{'extensions'} !~ /\bOpcode\b/) {
        print "1..0\n";
        exit 0;
    }
}

use Test::More tests => 3;
use Safe;

my $c; my $r;
my $snippet = q{
    my $foo = qr/foo/;
    ref $foo;
};
$c = new Safe;
$r = $c->reval($snippet);
is( $r, "Safe::Root0::Regexp" );
$r or diag $@;

# once more with the same compartment
# (where DESTROY has been cleaned up)
$r = $c->reval($snippet);
is( $r, "Safe::Root0::Regexp" );
$r or diag $@;

# try with a new compartment
$c = new Safe;
$r = $c->reval($snippet);
is( $r, "Safe::Root1::Regexp" );
$r or diag $@;