X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FEval-WithLexicals.git;a=blobdiff_plain;f=t%2Fhints.t;h=88bbec36f6719486a119091c4b334a525f7b695b;hp=f5681b3d4178eee719dc52e6a2d2d16aa43221e1;hb=c97f63974c1d1d0b422306ab24391fd256cbeceb;hpb=2b376bd0dc102f9019e007d889a844f94b3a87b9 diff --git a/t/hints.t b/t/hints.t index f5681b3..88bbec3 100644 --- a/t/hints.t +++ b/t/hints.t @@ -1,15 +1,10 @@ use strictures (); -my $strictures_hints; -BEGIN { - local $ENV{PERL_STRICTURES_EXTRA} = 0; - strictures->VERSION(1); strictures->import(); - # Find the hint value that 'use strictures 1' sets on this perl. - $strictures_hints = $^H; -} -use strictures 1; - use Test::More; use Eval::WithLexicals; +use lib 't/lib'; + +use strictures 1; +use get_strictures_hints qw($strictures_hints $strictures_warn); my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new(prelude => ''); @@ -33,24 +28,29 @@ $eval->eval('use strictures 1'); like $@, qr/requires explicit package/, 'Correct message in $@'; } -is_deeply( - $eval->hints->{q{$^H}}, \$strictures_hints, +is( + ${$eval->hints->{q{$^H}}}, $strictures_hints, 'Hints are set per strictures' ); +is( + (unpack "H*", ${$eval->hints->{q{${^WARNING_BITS}}}}), + (unpack "H*", $strictures_warn), + 'Warning bits are set per strictures' +); + is_deeply( $eval->lexicals, { }, 'Lexical not stored' ); # Assumption about perl internals: sort pragma will set a key in %^H. - -$eval->eval(q{ { use sort 'stable' } }), -ok !exists $eval->hints->{q{%^H}}->{sort}, +$eval->eval(q{ { use hint_hash_pragma 'param' } }), +ok !exists $eval->hints->{q{%^H}}->{hint_hash_pragma}, "Lexical pragma used below main scope not captured"; -$eval->eval(q{ use sort 'stable' }), -ok exists $eval->hints->{q{%^H}}->{sort}, +$eval->eval(q{ use hint_hash_pragma 'param' }), +is $eval->hints->{q{%^H}}->{hint_hash_pragma}, 'param', "Lexical pragma captured"; done_testing;