This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/charset_tools.pl: Improve function names
[perl5.git] / dist / Safe / t / saferegexp.t
1 #!perl -w
2
3 BEGIN {
4     require Config; import Config;
5     if ($Config{'extensions'} !~ /\bOpcode\b/) {
6         print "1..0\n";
7         exit 0;
8     }
9 }
10
11 use Test::More tests => 3;
12 use Safe;
13
14 my $c; my $r;
15 my $snippet = q{
16     my $foo = qr/foo/;
17     ref $foo;
18 };
19 $c = new Safe;
20 $r = $c->reval($snippet);
21 is( $r, "Safe::Root0::Regexp" );
22 $r or diag $@;
23
24 # once more with the same compartment
25 # (where DESTROY has been cleaned up)
26 $r = $c->reval($snippet);
27 is( $r, "Safe::Root0::Regexp" );
28 $r or diag $@;
29
30 # try with a new compartment
31 $c = new Safe;
32 $r = $c->reval($snippet);
33 is( $r, "Safe::Root1::Regexp" );
34 $r or diag $@;