3 use Eval::WithLexicals;
7 use get_strictures_hints qw($strictures_hints $strictures_warn);
9 my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new(prelude => '');
12 [ $eval->eval('$x = 1') ],
14 'Basic non-strict eval ok'
22 $eval->eval('use strictures 1');
25 local $SIG{__WARN__} = sub { };
27 ok !eval { $eval->eval('$x') }, 'Unable to use undeclared variable';
28 like $@, qr/requires explicit package/, 'Correct message in $@';
32 ${$eval->hints->{q{$^H}}}, $strictures_hints,
33 'Hints are set per strictures'
37 (unpack "H*", ${$eval->hints->{q{${^WARNING_BITS}}}}),
38 (unpack "H*", $strictures_warn),
39 'Warning bits are set per strictures'
47 # Assumption about perl internals: sort pragma will set a key in %^H.
48 $eval->eval(q{ { use hint_hash_pragma 'param' } }),
49 ok !exists $eval->hints->{q{%^H}}->{hint_hash_pragma},
50 "Lexical pragma used below main scope not captured";
52 $eval->eval(q{ use hint_hash_pragma 'param' }),
53 is $eval->hints->{q{%^H}}->{hint_hash_pragma}, 'param',
54 "Lexical pragma captured";