4 require Config; import Config;
5 if ($Config{'extensions'} !~ /\bOpcode\b/ && $Config{'osname'} ne 'VMS') {
15 package test; # test from somewhere other than main
19 use Opcode 1.00, qw(opdesc opset opset_to_ops opset_to_hex
20 opmask_add full_opset empty_opset opcodes opmask define_optag);
26 # create and destroy some automatic Safe compartments first
27 $cpt = new Safe or die;
28 $cpt = new Safe or die;
29 $cpt = new Safe or die;
31 $cpt = new Safe "Root" or die;
36 $cpt->share(qw($foo));
38 is(${$cpt->varglob('foo')}, 42);
40 ${$cpt->varglob('foo')} = 9;
44 is($cpt->reval('$foo'), 9);
45 is($cpt->reval('$::foo'), 9, "check 'main' has been changed");
46 is($cpt->reval('$main::foo'), 9, "check 'main' has been changed");
47 is($cpt->reval('$test::foo'), undef,
48 "check we can't see our test package");
49 is($cpt->reval('${"test::foo"}'), undef,
50 "check we can't see our test package");
53 is($cpt->reval('$foo'), undef,
54 'erasing the compartment deleted all variables');
56 # Note that we *must* use $cpt->varglob here because if we used
57 # $Root::foo etc we would still see the original values!
58 # This seems to be because the compiler has created an extra ref.
60 is(${$cpt->varglob('foo')}, undef);