From: Graham Knop Date: Thu, 28 May 2015 04:59:47 +0000 (-0400) Subject: clean up hint capturing code X-Git-Tag: v2.000001~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2Fstrictures.git;a=commitdiff_plain;h=9f180a366b9e5ce01c2dda475a5648a2c0d291c1 clean up hint capturing code Use a clean eval sub so main capture code can have strict applied. --- diff --git a/t/strictures.t b/t/strictures.t index 9cf35bd..411bcce 100644 --- a/t/strictures.t +++ b/t/strictures.t @@ -1,25 +1,27 @@ BEGIN { $ENV{PERL_STRICTURES_EXTRA} = 0 } +sub _eval { eval $_[0] } + +use strict; +use warnings; +use Test::More qw(no_plan); + sub capture_hints { my $code = shift; - my ($hints, $warning_bits); $code .= q{ ; - BEGIN { - # ignore lexicalized hints - $hints = $^H & ~ 0x20000; - $warning_bits = defined ${^WARNING_BITS} ? (unpack "H*", ${^WARNING_BITS}) : undef; - }; - 1; + my @h; + BEGIN { @h = ( $^H, ${^WARNING_BITS} ) } + @h; }; - eval $code or die $@; + my ($hints, $warning_bits) = _eval $code or die $@; + # ignore lexicalized hints + $hints &= ~ 0x20000; + $warning_bits = unpack "H*", $warning_bits + if defined $warning_bits; return ($hints, $warning_bits); } -use strict; -use warnings; -use Test::More qw(no_plan); - sub compare_hints { my ($code_want, $code_got, $name) = @_; my ($want_hints, $want_warnings) = capture_hints $code_want;