Login
Now sorting the directory contents so we critique files in a
[gknop/Perl-Critic.git] / t / 20_policies_classhierarchies.t
CommitLineData
bf159007
JRT
1##################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##################################################################
7
8use strict;
9use warnings;
10use Test::More tests => 2;
11use Perl::Critic::Config;
12use Perl::Critic;
13
14# common P::C testing tools
15use lib qw(t/tlib);
16use PerlCriticTestUtils qw(pcritique);
17PerlCriticTestUtils::block_perlcriticrc();
18
19my $code ;
20my $policy;
21my %config;
22
23#-----------------------------------------------------------------------------
24
25$code = <<'END_PERL';
26my $self = bless {};
27my $self = bless [];
28
29#Critic doesn't catch these,
30#cuz they parse funny
31#my $self = bless( {} );
32#my $self = bless( [] );
33
34END_PERL
35
36$policy = 'ClassHierarchies::ProhibitOneArgBless';
37is( pcritique($policy, \$code), 2, $policy );
38
39#-----------------------------------------------------------------------------
40
41$code = <<'END_PERL';
42my $self = bless {}, 'foo';
43my $self = bless( {}, 'foo' );
44my $self = bless [], 'foo';
45my $self = bless( [], 'foo' );
46END_PERL
47
48$policy = 'ClassHierarchies::ProhibitOneArgBless';
49is( pcritique($policy, \$code), 0, $policy );