diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-10-17 07:39:16 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-10-17 07:39:16 +0000 |
commit | da651d81005ef8c18ead4b92198101ba5698a3be (patch) | |
tree | 680a95bbc6995e6a5c406868b74e08bc4c55dc79 /ext/Safe | |
parent | 8261f8eb698db59828f3e3dd7a1ee82976ab259e (diff) | |
download | perl-da651d81005ef8c18ead4b92198101ba5698a3be.tar.gz |
More tests for Safe
p4raw-id: //depot/perl@32117
Diffstat (limited to 'ext/Safe')
-rw-r--r-- | ext/Safe/t/safeuniversal.t | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/ext/Safe/t/safeuniversal.t b/ext/Safe/t/safeuniversal.t index 6690f5fb54..d37d7ca146 100644 --- a/ext/Safe/t/safeuniversal.t +++ b/ext/Safe/t/safeuniversal.t @@ -1,7 +1,7 @@ #!perl BEGIN { - if($ENV{PERL_CORE}) { + if ($ENV{PERL_CORE}) { chdir 't' if -d 't'; @INC = '../lib'; } @@ -16,9 +16,10 @@ BEGIN { use strict; use Test::More; use Safe; -plan(tests => 2); +plan(tests => 6); my $c = new Safe; +$c->permit(qw(require caller)); my $r = $c->reval(q! sub UNIVERSAL::isa { "pwned" } @@ -27,3 +28,19 @@ my $r = $c->reval(q! is( $r, "pwned", "isa overriden in compartment" ); is( (bless[],"Foo")->isa("Foo"), 1, "... but not outside" ); + +sub Foo::foo {} + +$r = $c->reval(q! + sub UNIVERSAL::can { "pwned" } + (bless[],"Foo")->can("foo"); +!); + +is( $r, "pwned", "can overriden in compartment" ); +is( (bless[],"Foo")->can("foo"), \&Foo::foo, "... but not outside" ); + +$r = $c->reval(q! + utf8::is_utf8("\x{100}"); +!); +is( $@, '', 'can call utf8::is_valid' ); +is( $r, 1, '... returns 1' ); |