X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F10-basic.t;h=314f4f576288d2873a4618c841baeeab665c17be;hb=4421e107580f32a6c992f44d01b1d2818d65ee87;hp=55215c40110bc19d09d86893aa21b60d45224aea;hpb=ef89faf5a36a866b83462cad90209f9cc68a7e41;p=perl%2Fmodules%2FPerl-Critic-Policy-Dynamic-NoIndirect.git diff --git a/t/10-basic.t b/t/10-basic.t index 55215c4..314f4f5 100644 --- a/t/10-basic.t +++ b/t/10-basic.t @@ -5,7 +5,7 @@ use warnings; my ($tests, $reports, $subtests); BEGIN { - $tests = 25; + $tests = 27; $reports = 42; $subtests = 3; } @@ -26,6 +26,7 @@ sub expect { sub zap (&) { } +TEST: { local $/ = "####"; @@ -35,13 +36,24 @@ sub zap (&) { } s/^\s+//s; my ($code, $expected) = split /^-{4,}$/m, $_, 2; - my @expected = eval $expected; - - my @violations = eval { pcritique_with_violations($policy, \$code) }; + my @expected; + { + local $@; + @expected = eval $expected; + if ($@) { + diag "Compilation of expected code $id failed: $@"; + next TEST; + } + } - if ($@) { - diag "Compilation $id failed: $@"; - next; + my @violations; + { + local $@; + @violations = eval { pcritique_with_violations($policy, \$code) }; + if ($@) { + diag "Critique test $id failed: $@"; + next TEST; + } } is @violations, @expected, "right count of violations $id"; @@ -51,7 +63,7 @@ sub zap (&) { } unless ($exp) { fail "Unexpected violation for chunk $id: " . $v->description; - next; + next TEST; } my $pos = $v->location; @@ -71,6 +83,9 @@ my $x = new X; ---- [ 'new', 'X', 1, 9 ] #### +use indirect; my $x = new X; +---- +#### my $x = new X; $x = new X; ---- [ 'new', 'X', 1, 9 ], [ 'new', 'X', 1, 21 ] @@ -104,6 +119,10 @@ my $x = new new; [ 'new', 'new', 1, 9 ] #### our $obj; +use indirect; my $x = new $obj; +---- +#### +our $obj; my $x = new $obj; ---- [ 'new', '$obj', 2, 9 ]