Some de-cruftification of README.vms.
[p5sagit/p5-mst-13.2.git] / dist / Safe / t / safeuniversal.t
CommitLineData
144c260c 1#!perl
2
3BEGIN {
144c260c 4 require Config;
5 import Config;
6 if ($Config{'extensions'} !~ /\bOpcode\b/) {
7 print "1..0\n";
8 exit 0;
9 }
10}
11
12use strict;
40b9d4d9 13use warnings;
144c260c 14use Test::More;
15use Safe;
da651d81 16plan(tests => 6);
144c260c 17
18my $c = new Safe;
da651d81 19$c->permit(qw(require caller));
144c260c 20
d4808f62 21my $no_warn_redef = ($] != 5.008009)
22 ? q(no warnings 'redefine';)
23 : q($SIG{__WARN__}=sub{};);
24my $r = $c->reval($no_warn_redef . q!
144c260c 25 sub UNIVERSAL::isa { "pwned" }
26 (bless[],"Foo")->isa("Foo");
27!);
28
29is( $r, "pwned", "isa overriden in compartment" );
30is( (bless[],"Foo")->isa("Foo"), 1, "... but not outside" );
da651d81 31
32sub Foo::foo {}
33
d4808f62 34$r = $c->reval($no_warn_redef . q!
da651d81 35 sub UNIVERSAL::can { "pwned" }
36 (bless[],"Foo")->can("foo");
37!);
38
39is( $r, "pwned", "can overriden in compartment" );
40is( (bless[],"Foo")->can("foo"), \&Foo::foo, "... but not outside" );
41
42$r = $c->reval(q!
43 utf8::is_utf8("\x{100}");
44!);
45is( $@, '', 'can call utf8::is_valid' );
46is( $r, 1, '... returns 1' );