X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FEval-WithLexicals.git;a=blobdiff_plain;f=t%2Fhints.t;h=15db971b7a250c15cb5afa0f29de4e528abfbe3f;hp=6a07969e18f83428e45f96532f2b7e6fbd2ec6b2;hb=a214c345e2de0ddd1e2ab205d942e2b1d7bb47b1;hpb=14786ff863ce8fbc95583e3a39b9ca29c4f0958c diff --git a/t/hints.t b/t/hints.t index 6a07969..15db971 100644 --- a/t/hints.t +++ b/t/hints.t @@ -3,22 +3,8 @@ use Test::More; use Eval::WithLexicals; use lib 't/lib'; -my $strictures_hints; -my $strictures_warn; -{ - local $ENV{PERL_STRICTURES_EXTRA} = 0; - eval q{ - use strictures 1; - BEGIN { - # Find the hint value that 'use strictures 1' sets on this perl. - $strictures_hints = $^H; - $strictures_warn = ${^WARNING_BITS}; - }; - 1; - } or die $@; -}; - use strictures 1; +use get_strictures_hints qw($strictures_hints $strictures_warn); my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new(prelude => ''); @@ -38,8 +24,9 @@ $eval->eval('use strictures 1'); { local $SIG{__WARN__} = sub { }; - ok !eval { $eval->eval('$x') }, 'Unable to use undeclared variable'; - like $@, qr/requires explicit package/, 'Correct message in $@'; + ok !eval { $eval->eval('${"x"}') }, 'Unable to use undeclared variable'; + like $@, qr/Can't use string .* as a SCALAR ref/, + 'Correct message in $@'; } is( @@ -67,4 +54,10 @@ $eval->eval(q{ use hint_hash_pragma 'param' }), is $eval->hints->{q{%^H}}->{hint_hash_pragma}, 'param', "Lexical pragma captured"; +$eval->eval('my $x = 1'); +is_deeply( + $eval->lexicals->{'$x'}, \1, + 'Lexical captured when preserving hints', +); + done_testing;