#!./perl -w
$|=1;
BEGIN {
print "1..0\n";
exit 0;
}
}
# Tests Todo:
# 'main' as root
use Safe 1.00;
my $last_test; # initalised at end
print "1..$last_test\n";
# Set up a package namespace of things to be visible to the unsafe code
$bar = "invisible";
# Stop perl from moaning about identifies which are apparently only used once
my $cpt;
# create and destroy a couple of automatic Safe compartments first
print "ok 1\n";
} else {
print "#$@" if $@;
print "not ok 1\n";
}
});
print $@ ? "not ok 7\n#$@" : "ok 7\n";
$foo = "ok 8\n";
@glob = qw(not ok 16);
$cpt->share('$"') unless $Config{use5005threads};
$cpt->reval(q{
package other;
sub other_sayok { print "ok @_\n" }
package main;
print $foo ? $foo : "not ok 8\n";
print $bar{key} ? $bar{key} : "not ok 9\n";
(@baz) ? print "@baz\n" : print "not ok 10\n";
print $glob;
other::other_sayok(12);
$foo =~ s/8/14/;
$bar{new} = "ok 15\n";
@glob = qw(ok 16);
});
print $@ ? "not ok 13\n#$@" : "ok 13\n";
$" = ' ';
print $foo, $bar{new}, "@glob\n";
$Root::foo = "not ok 17";
@Root::bar = "ok";
push(@Root::bar, "18"); # Two steps to prevent "Identifier used only once..."
print "$Root::foo\n";
use strict;
print 1 ? "ok 19\n" : "not ok 19\n";
print 1 ? "ok 20\n" : "not ok 20\n";
my $m1 = $cpt->mask;
$cpt->trap("negate");
my $m2 = $cpt->mask;
my @masked = opset_to_ops($m1);
print $m2 eq opset("negate", @masked) ? "ok 21\n" : "not ok 21\n";
print eval { $cpt->mask("a bad mask") } ? "not ok 22\n" : "ok 22\n";
print $cpt->reval("2 + 2") == 4 ? "ok 23\n" : "not ok 23\n";
$cpt->mask(empty_opset);
print $t_array[2] == 4 ? "ok 27\n" : "not ok 27\n";
print defined $t_scalar2 ? "not ok 28\n" : "ok 28\n";
print $@ =~ /foo bar/ ? "ok 29\n" : "not ok 29\n";
# --- rdo
my $t = 30;
$! = 0;
open(NOSUCH, $nosuch);
if ($@) {
my $errno = $!;
die "Eek! Attempting to open $nosuch failed, but \$! is still 0" unless $!;
$! = 0;
$cpt->rdo($nosuch);
print $! == $errno ? "ok $t\n" : sprintf "not ok $t # \"$!\" is %d (expected %d)\n", $!, $errno; $t++;
} else {
}
close(NOSUCH);
# test #31 is gone.
# print X "999\n";
# close X;
# $cpt->permit_only('const', 'leaveeval');
# unlink $rdo_file;
#}
#else {
# print "# test $t skipped, can't open file: $!\nok $t\n"; $t++;
#}
print "ok $last_test\n";
BEGIN { $last_test = 32 }