sub default_themes { qw/dynamic maintenance/ }
sub applies_to { 'PPI::Document' }
+my $tag_obj = sub {
+ my $obj = '' . $_[0];
+ $obj = '{' if $obj =~ /^\s*\{/;
+ $obj;
+};
+
sub violates_dynamic {
my ($self, undef, $doc) = @_;
for (@errs) {
my ($obj, $meth, $line) = @$_[0, 1, 3];
$line -= $offset;
- my $tag = join "\0", $line, $meth, $obj;
+ my $tag = join "\0", $line, $meth, $tag_obj->($obj);
push @{$errs_tags{$tag}}, [ $obj, $meth ];
}
my $pos = $elt->location;
return 0 unless $pos;
- my $tag = join "\0", $pos->[0], $elt, $elt->snext_sibling;
+ my $tag = join "\0", $pos->[0], $elt, $tag_obj->($elt->snext_sibling);
if (my $errs = $errs_tags{$tag}) {
push @violations, do { my $e = pop @$errs; push @$e, $elt; $e };
delete $errs_tags{$tag} unless @$errs;
my ($tests, $reports, $subtests);
BEGIN {
- $tests = 15;
- $reports = 25;
+ $tests = 25;
+ $reports = 42;
$subtests = 3;
}
qr/^Indirect call of method \"\Q$meth\E\" on $obj/,
}
+sub zap (&) { }
+
{
local $/ = "####";
$obj;
----
[ 'new', '$obj', 2, 9 ], [ 'new', '$obj', 3, 7 ]
+####
+my $x = main::zap { };
+----
+####
+my $x = meh { };
+----
+[ 'meh', '{', 1, 9 ]
+####
+my $x = meh {
+ 1
+};
+----
+[ 'meh', '{', 1, 9 ]
+####
+my $x =
+ meh { 1; 1
+ };
+----
+[ 'meh', '{', 2, 2 ]
+####
+my $x = meh {
+ new X;
+};
+----
+[ 'meh', '{', 1, 9 ], [ 'new', 'X', 2, 2 ]
+####
+our $obj;
+my $x = meh {
+ new $obj;
+}
+----
+[ 'meh', '{', 2, 9 ], [ 'new', '$obj', 3, 2 ]
+####
+my $x = meh { } new
+ X;
+----
+[ 'meh', '{', 1, 9 ], [ 'new', 'X', 1, 17 ]
+####
+our $obj;
+my $x = meh { } new
+ $obj;
+----
+[ 'meh', '{', 2, 9 ], [ 'new', '$obj', 2, 17 ]
+####
+our $obj;
+my $x = meh { new X } new $obj;
+----
+[ 'meh', '{', 2, 9 ], [ 'new', 'X', 2, 15 ], [ 'new', '$obj', 2, 23 ]
+####
+our $obj;
+my $x = meh { new $obj } new X;
+----
+[ 'meh', '{', 2, 9 ], [ 'new', '$obj', 2, 15 ], [ 'new', 'X', 2, 26 ]