From: Rafael Garcia-Suarez Date: Wed, 17 Oct 2007 07:39:16 +0000 (+0000) Subject: More tests for Safe X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=da651d81005ef8c18ead4b92198101ba5698a3be;p=p5sagit%2Fp5-mst-13.2.git More tests for Safe p4raw-id: //depot/perl@32117 --- diff --git a/ext/Safe/t/safeuniversal.t b/ext/Safe/t/safeuniversal.t index 6690f5f..d37d7ca 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' );