3 ##############################################################################
4 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/t/12_policylisting.t $
5 # $Date: 2008-06-06 00:48:04 -0500 (Fri, 06 Jun 2008) $
8 ##############################################################################
14 use English qw<-no_match_vars>;
18 use Perl::Critic::UserProfile;
19 use Perl::Critic::PolicyFactory (-test => 1);
20 use Perl::Critic::PolicyListing;
22 #-----------------------------------------------------------------------------
24 my $profile = Perl::Critic::UserProfile->new( -profile => 'NONE' );
25 my @policy_names = Perl::Critic::PolicyFactory::site_policy_names();
26 my $factory = Perl::Critic::PolicyFactory->new( -profile => $profile );
27 my @policies = map { $factory->create_policy( -name => $_ ) } @policy_names;
28 my $listing = Perl::Critic::PolicyListing->new( -policies => \@policies );
29 my $policy_count = scalar @policies;
31 plan( tests => $policy_count + 1);
33 #-----------------------------------------------------------------------------
34 # These tests verify that the listing has the right number of lines (one per
35 # policy) and that each line matches the expected pattern. This indirectly
36 # verifies that each core policy declares at least one theme.
38 my $listing_as_string = "$listing";
39 my @listing_lines = split /\n/, $listing_as_string;
40 my $line_count = scalar @listing_lines;
41 is( $line_count, $policy_count, qq{Listing has all $policy_count policies} );
44 my $listing_pattern = qr{\A\d [\w:]+ \[[\w\s]+\]\z};
45 for my $line ( @listing_lines ) {
46 like($line, $listing_pattern, 'Listing format matches expected pattern');
49 #-----------------------------------------------------------------------------
51 # ensure we run true if this test is loaded by
52 # t/12_policylisting.t_without_optional_dependencies.t
55 #-----------------------------------------------------------------------------
58 # cperl-indent-level: 4
60 # indent-tabs-mode: nil
61 # c-indentation-style: bsd
63 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :