Eviscerate README.macos to match the state of the world
[p5sagit/p5-mst-13.2.git] / dist / Safe / t / safe1.t
CommitLineData
76d62587 1#!./perl -w
2$|=1;
3BEGIN {
76d62587 4 require Config; import Config;
5 if ($Config{'extensions'} !~ /\bOpcode\b/ && $Config{'osname'} ne 'VMS') {
6 print "1..0\n";
7 exit 0;
8 }
ac5e3691 9
76d62587 10}
11
12# Tests Todo:
13# 'main' as root
14
15package test; # test from somewhere other than main
16
17use vars qw($bar);
18
19use Opcode 1.00, qw(opdesc opset opset_to_ops opset_to_hex
20 opmask_add full_opset empty_opset opcodes opmask define_optag);
21
22use Safe 1.00;
23
24my $last_test; # initalised at end
25print "1..$last_test\n";
26
27my $t = 1;
28my $cpt;
29# create and destroy some automatic Safe compartments first
30$cpt = new Safe or die;
31$cpt = new Safe or die;
32$cpt = new Safe or die;
33
34$cpt = new Safe "Root" or die;
35
36foreach(1..3) {
37 $foo = 42;
38
39 $cpt->share(qw($foo));
40
41 print ${$cpt->varglob('foo')} == 42 ? "ok $t\n" : "not ok $t\n"; $t++;
42
43 ${$cpt->varglob('foo')} = 9;
44
45 print $foo == 9 ? "ok $t\n" : "not ok $t\n"; $t++;
46
47 print $cpt->reval('$foo') == 9 ? "ok $t\n" : "not ok $t\n"; $t++;
48 # check 'main' has been changed:
49 print $cpt->reval('$::foo') == 9 ? "ok $t\n" : "not ok $t\n"; $t++;
50 print $cpt->reval('$main::foo') == 9 ? "ok $t\n" : "not ok $t\n"; $t++;
51 # check we can't see our test package:
52 print $cpt->reval('$test::foo') ? "not ok $t\n" : "ok $t\n"; $t++;
53 print $cpt->reval('${"test::foo"}') ? "not ok $t\n" : "ok $t\n"; $t++;
54
55 $cpt->erase; # erase the compartment, e.g., delete all variables
56
57 print $cpt->reval('$foo') ? "not ok $t\n" : "ok $t\n"; $t++;
58
59 # Note that we *must* use $cpt->varglob here because if we used
60 # $Root::foo etc we would still see the original values!
61 # This seems to be because the compiler has created an extra ref.
62
63 print ${$cpt->varglob('foo')} ? "not ok $t\n" : "ok $t\n"; $t++;
64}
65
66print "ok $last_test\n";
67BEGIN { $last_test = 28 }