1#!perl
2
3BEGIN {
4    require Config;
5    import Config;
6    if ($Config{'extensions'} !~ /\bOpcode\b/) {
7	print "1..0\n";
8	exit 0;
9    }
10    # Can we load the version module ?
11    eval { require version; 1 } or do {
12	print "1..0 # no version.pm\n";
13	exit 0;
14    };
15    delete $INC{"version.pm"};
16}
17
18use strict;
19use Test::More;
20use Safe;
21plan(tests => 3);
22
23my $c = new Safe;
24$c->permit(qw(require caller entereval unpack rand));
25my $r = $c->reval(q{ use version; 1 });
26ok( defined $r, "Can load version.pm in a Safe compartment" ) or diag $@;
27
28$r = $c->reval(q{ version->new(1.2) });
29is(ref $r, "Safe::Root0::version", "version objects rerooted");
30$r or diag $@;
31
32# Does this test really belong here?  We are testing the "loading" of
33# a perl version number.
34# This should died because of strictures under 5.12+ and because of the
35# perl version in 5.10-.
36ok !$c->reval(q{use 5.012; $undeclared; 1}),
37   'reval does not prevent use 5.012 from enabling strict';
38