strictures v1 enables all fatal warnings, which included anything custom
registered by other modules. Moo will delay loading modules for as long
as possible, which means some things, like Class::Method::Modifiers,
won't be loaded until the WithHintPersistence role is applied at object
creation time. This may what causes vars.pm to be loaded, which
registers a warning category and can break the test.
If we delay checking the expected hints until immediately before going
the eval test, all warning categories should be loaded.
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 => '');
'Lexical not stored'
);
+my ($strictures_hints, $strictures_warn) = get_strictures_hints::hints();
$eval->eval('use strictures 1');
{
package get_strictures_hints;
-local $ENV{PERL_STRICTURES_EXTRA} = 0;
-our $strictures_hints;
-our $strictures_warn;
+sub hints {
+ local $ENV{PERL_STRICTURES_EXTRA} = 0;
+ my $strictures_hints;
+ my $strictures_warn;
-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 $@;
+ 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 $@;
-require Exporter;
-*import = \&Exporter::import;
-our @EXPORT = qw($strictures_hints $strictures_warn);
+ return ($strictures_hints, $strictures_warn);
+}
1;