This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
New test for Safe
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 12 Oct 2007 09:43:20 +0000 (09:43 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 12 Oct 2007 09:43:20 +0000 (09:43 +0000)
p4raw-id: //depot/perl@32104

MANIFEST
ext/Safe/t/safeuniversal.t [new file with mode: 0644]

index 2339727..69fe314 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -991,6 +991,7 @@ ext/Safe/t/safe1.t          See if Safe works
 ext/Safe/t/safe2.t             See if Safe works
 ext/Safe/t/safe3.t             See if Safe works
 ext/Safe/t/safeops.t           Tests that all ops can be trapped by Safe
+ext/Safe/t/safeuniversal.t     Tests Safe with functions from universal.c
 ext/SDBM_File/Makefile.PL      SDBM extension makefile writer
 ext/SDBM_File/sdbm/biblio      SDBM kit
 ext/SDBM_File/sdbm/CHANGES     SDBM kit
diff --git a/ext/Safe/t/safeuniversal.t b/ext/Safe/t/safeuniversal.t
new file mode 100644 (file)
index 0000000..6690f5f
--- /dev/null
@@ -0,0 +1,29 @@
+#!perl
+
+BEGIN {
+    if($ENV{PERL_CORE}) {
+       chdir 't' if -d 't';
+       @INC = '../lib';
+    }
+    require Config;
+    import Config;
+    if ($Config{'extensions'} !~ /\bOpcode\b/) {
+       print "1..0\n";
+       exit 0;
+    }
+}
+
+use strict;
+use Test::More;
+use Safe;
+plan(tests => 2);
+
+my $c = new Safe;
+
+my $r = $c->reval(q!
+    sub UNIVERSAL::isa { "pwned" }
+    (bless[],"Foo")->isa("Foo");
+!);
+
+is( $r, "pwned", "isa overriden in compartment" );
+is( (bless[],"Foo")->isa("Foo"), 1, "... but not outside" );