Login
Added test script for perlcritic and modified perlcritic to not "run"
[gknop/Perl-Critic.git] / t / 07_perlcritic.t
CommitLineData
af1acfa2
JRT
1##################################################################
2# $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/t/00_modules.t $
3# $Date: 2005-12-13 16:46:24 -0800 (Tue, 13 Dec 2005) $
4# $Author: thaljef $
5# $Revision: 121 $
6##################################################################
7
8use strict;
9use warnings;
10use File::Spec;
11use Test::More tests => 27;
12
13#-----------------------------------------------------------------------------
14#Load perlcritic like a library so we can test its subroutines
15
16my $perlcritic = File::Spec->catfile( qw(blib script perlcritic) );
17require $perlcritic;
18
19#-----------------------------------------------------------------------------
20
21local @ARGV = qw(-1 -2 -3 -4 -5);
22my %options = get_options();
23is( $options{-severity}, 1);
24
25local @ARGV = qw(-5 -3 -4 -1 -2);
26%options = get_options();
27is( $options{-severity}, 1);
28
29local @ARGV = qw();
30%options = get_options();
31is( $options{-severity}, undef);
32
33local @ARGV = qw(-2 -4 -severity 5);
34%options = get_options();
35is( $options{-severity}, 2);
36
37local @ARGV = qw(-severity 5 -2 -1);
38%options = get_options();
39is( $options{-severity}, 1);
40
41#-----------------------------------------------------------------------------
42
43local @ARGV = qw(-top);
44%options = get_options();
45is( $options{-severity}, 1);
46is( $options{-top}, 20);
47
48local @ARGV = qw(-top 10);
49%options = get_options();
50is( $options{-severity}, 1);
51is( $options{-top}, 10);
52
53local @ARGV = qw(-severity 4 -top);
54%options = get_options();
55is( $options{-severity}, 4);
56is( $options{-top}, 20);
57
58local @ARGV = qw(-severity 4 -top 10);
59%options = get_options();
60is( $options{-severity}, 4);
61is( $options{-top}, 10);
62
63local @ARGV = qw(-severity 5 -2 -top 5);
64%options = get_options();
65is( $options{-severity}, 2);
66is( $options{-top}, 5);
67
68#-----------------------------------------------------------------------------
69
70local @ARGV = qw(-noprofile);
71%options = get_options();
72is( $options{-profile}, q{});
73
74local @ARGV = qw(-profile foo);
75%options = get_options();
76is( $options{-profile}, 'foo');
77
78#-----------------------------------------------------------------------------
79
80local @ARGV = qw(-verbose 2);
81%options = get_options();
82is( $options{-verbose}, 2);
83
84local @ARGV = qw(-verbose %l:%c:%m);
85%options = get_options();
86is( $options{-verbose}, '%l:%c:%m');
87
88#-----------------------------------------------------------------------------
89
90my @perl_files = qw(foo.t foo.pm foo.pl foo.PL);
91for (@perl_files){
92 ok( _is_perl($_), 'Is perl' );
93}
94
95my @not_perl_files = qw(foo.doc foo.txt foo.conf foo);
96for (@not_perl_files){
97 ok( !_is_perl($_), 'Is not perl' );
98}
99
100#-----------------------------------------------------------------------------