X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FEval-WithLexicals.git;a=blobdiff_plain;f=t%2Fhints.t;h=5ce67d80e7a91f46d857c2357c41763cffb1da7b;hp=62cecc8e4cad07ad57363f69f8704d229550bb25;hb=af7a7506a8fba061903fc866183329145f4b06dc;hpb=8d732f3064bb88d682504f365ef1af62c6598b8c diff --git a/t/hints.t b/t/hints.t index 62cecc8..5ce67d8 100644 --- a/t/hints.t +++ b/t/hints.t @@ -1,10 +1,10 @@ -use strictures 1; -# Find the hint value that 'use strictures 1' sets on this perl. -my $strictures_hints; -BEGIN { $strictures_hints = $^H } - +use strictures (); 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 => ''); @@ -24,28 +24,34 @@ $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_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;