You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to use Test::Strict to test that a particular module was
included. Maybe there are better ways to do this but Test::Strict was
already there. This meant I ended up parsing the same file twice, although
I'm suspicious that that's a red herring. The flip flop operator in
_strict_ok retained its state between the first and second run through the
file and in the second go around assumed it was in a pod block from the
beginning. The patch replaces the flip-flop operator with an explicit
state variable.
In addition, pod directives can't begin with whitespace (on either side of
the =) so I removed that from the regex.
The 'bit' is that this will be treated by _strict_ok as a pod block, but
not by perl:
-----
$x
=42;
print "still perl - $x\n";
-----
I don't know how to deal with that except by being perl, so I didn't.
People who write code like that are on their own.
Patch:
--- /home/mking/perl5/lib/site_perl/5.26.0/Test/Strict.pm 2016-12-01 15:04:42.000000000 +0000
+++ lib/Test/Strict.pm 2018-07-06 13:53:16.435049602 +0000
@@ -225,9 +225,12 @@
sub _strict_ok {
my ($in) = @_;
local $_;
+ my $pod;
while (<$in>) {
next if (/^\s*#/); # Skip comments
- next if (/^\s*=.+/ .. /^\s*=(cut|back|end)/); # Skip pod
+ $pod = 0, next if /^=(cut|back|end)/;
+ $pod = 1, next if /^=\S+/;
+ next if $pod; # Skip pod
last if (/^\s*(__END__|__DATA__)/); # End of code
foreach my $name (modules_enabling_strict()) {
# TODO: improve this matching (e.g. see TODO test)
Cheers,
Matthew
The text was updated successfully, but these errors were encountered:
Issue raised by email directly (chohag@jtan.com):
Actually 2 (and a bit). First the weird one.
I wanted to use Test::Strict to test that a particular module was
included. Maybe there are better ways to do this but Test::Strict was
already there. This meant I ended up parsing the same file twice, although
I'm suspicious that that's a red herring. The flip flop operator in
_strict_ok retained its state between the first and second run through the
file and in the second go around assumed it was in a pod block from the
beginning. The patch replaces the flip-flop operator with an explicit
state variable.
In addition, pod directives can't begin with whitespace (on either side of
the =) so I removed that from the regex.
The 'bit' is that this will be treated by _strict_ok as a pod block, but
not by perl:
I don't know how to deal with that except by being perl, so I didn't.
People who write code like that are on their own.
Patch:
Cheers,
Matthew
The text was updated successfully, but these errors were encountered: