Login
Add new policy Variables::ProhibitMatchVars
[gknop/Perl-Critic.git] / t / 00_modules.t
CommitLineData
27c1472f
JRT
1##################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##################################################################
7
59b05e08
JRT
8use strict;
9use warnings;
6bf9b465 10use PPI::Document;
b672fd9e 11use Test::More tests => 548; # Add 9 for each new policy created
59b05e08
JRT
12use English qw(-no_match_vars);
13
9ad4bbe8 14our $VERSION = '0.14';
59b05e08
JRT
15$VERSION = eval $VERSION; ## pc:skip
16
17my $obj = undef;
18
19#---------------------------------------------------------------
20
21use_ok('Perl::Critic');
22can_ok('Perl::Critic', 'new');
59b05e08 23can_ok('Perl::Critic', 'critique');
7e86d49a
JRT
24can_ok('Perl::Critic', 'policies');
25can_ok('Perl::Critic', 'add_policy');
59b05e08
JRT
26
27#Set -profile to avoid messing with .perlcriticrc
28$obj = Perl::Critic->new( -profile => 'NONE' );
29isa_ok($obj, 'Perl::Critic');
30is($obj->VERSION(), $VERSION);
31
32#---------------------------------------------------------------
33
34use_ok('Perl::Critic::Config');
35can_ok('Perl::Critic::Config', 'new');
7e86d49a 36can_ok('Perl::Critic::Config', 'policies');
dff08b70 37can_ok('Perl::Critic::Config', 'add_policy');
59b05e08 38can_ok('Perl::Critic::Config', 'find_profile_path');
dff08b70
JRT
39can_ok('Perl::Critic::Config', 'site_policies');
40can_ok('Perl::Critic::Config', 'native_policies');
59b05e08
JRT
41
42#Set -profile to avoid messing with .perlcriticrc
43$obj = Perl::Critic::Config->new( -profile => 'NONE');
44isa_ok($obj, 'Perl::Critic::Config');
45is($obj->VERSION(), $VERSION);
46
47#---------------------------------------------------------------
48
49use_ok('Perl::Critic::Policy');
50can_ok('Perl::Critic::Policy', 'new');
51can_ok('Perl::Critic::Policy', 'violates');
dff08b70 52can_ok('Perl::Critic::Policy', 'applies_to');
9f1d5408
JRT
53can_ok('Perl::Critic::Policy', 'default_severity');
54can_ok('Perl::Critic::Policy', 'get_severity');
55can_ok('Perl::Critic::Policy', 'set_severity');
59b05e08
JRT
56
57$obj = Perl::Critic::Policy->new();
58isa_ok($obj, 'Perl::Critic::Policy');
59is($obj->VERSION(), $VERSION);
60
61#---------------------------------------------------------------
62
63use_ok('Perl::Critic::Violation');
64can_ok('Perl::Critic::Violation', 'new');
65can_ok('Perl::Critic::Violation', 'explanation');
66can_ok('Perl::Critic::Violation', 'description');
67can_ok('Perl::Critic::Violation', 'location');
6bf9b465 68can_ok('Perl::Critic::Violation', 'source');
59b05e08
JRT
69can_ok('Perl::Critic::Violation', 'policy');
70can_ok('Perl::Critic::Violation', 'to_string');
71
6bf9b465
JRT
72my $code = 'Hello World;';
73my $doc = PPI::Document->new(\$code);
74$obj = Perl::Critic::Violation->new(undef, undef, $doc, undef);
59b05e08
JRT
75isa_ok($obj, 'Perl::Critic::Violation');
76is($obj->VERSION(), $VERSION);
77
78#---------------------------------------------------------------
79
dff08b70 80for my $mod ( Perl::Critic::Config::native_policies() ) {
59b05e08
JRT
81
82 use_ok($mod);
83 can_ok($mod, 'new');
84 can_ok($mod, 'violates');
dff08b70 85 can_ok($mod, 'applies_to');
9f1d5408
JRT
86 can_ok($mod, 'default_severity');
87 can_ok($mod, 'get_severity');
88 can_ok($mod, 'set_severity');
59b05e08
JRT
89
90 $obj = $mod->new();
91 isa_ok($obj, 'Perl::Critic::Policy');
92 is($obj->VERSION(), $VERSION, "Version of $mod");
93}
94