X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FEval-WithLexicals.git;a=blobdiff_plain;f=t%2Fhints.t;h=7040b4258cd67539b99c10d4fd258db5c57f169f;hp=15db971b7a250c15cb5afa0f29de4e528abfbe3f;hb=6c8bf56cd4942ec40e37a6db79d4bab121e1cff8;hpb=a214c345e2de0ddd1e2ab205d942e2b1d7bb47b1 diff --git a/t/hints.t b/t/hints.t index 15db971..7040b42 100644 --- a/t/hints.t +++ b/t/hints.t @@ -4,7 +4,7 @@ use Eval::WithLexicals; use lib 't/lib'; use strictures 1; -use get_strictures_hints qw($strictures_hints $strictures_warn); +use get_strictures_hints; my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new(prelude => ''); @@ -19,6 +19,7 @@ is_deeply( 'Lexical not stored' ); +my ($strictures_hints, $strictures_warn) = get_strictures_hints::hints(); $eval->eval('use strictures 1'); { @@ -35,10 +36,45 @@ is( ); is( - (unpack "H*", ${$eval->hints->{q{${^WARNING_BITS}}}}), + (unpack "H*", ${ $eval->hints->{'${^WARNING_BITS}'} }), (unpack "H*", $strictures_warn), 'Warning bits are set per strictures' -); +) or do { + my @cats = + map { + [ $_ => $warnings::Bits{$_} ], + [ "fatal $_" => $warnings::DeadBits{$_} ], + } + grep $_ ne 'all', + keys %warnings::Bits; + + my %info; + for my $check ( + [ missing => $strictures_warn ], + [ extra => ${ $eval->hints->{'${^WARNING_BITS}'} } ], + ) { + my $bits = $check->[1]; + $info{$check->[0]} = { + map { ($bits & $_->[1]) =~ /[^\0]/ ? ( $_->[0] => 1 ) : () } + @cats + }; + } + + { + my @extra = keys %{$info{extra}}; + my @missing = keys %{$info{missing}}; + delete @{$info{missing}}{ @extra }; + delete @{$info{extra}}{ @missing }; + } + + for my $type (qw(missing extra)) { + my @found = grep $info{$type}{$_}, map $_->[0], @cats; + diag "$type:" + if @found; + diag " $_" + for @found; + } +}; is_deeply( $eval->lexicals, { },