NAME

Perl::Critic::TestUtils - Utility functions for testing new Policies

SYNOPSIS

use Perl::Critic::TestUtils qw(critique pcritique fcritique);

my $code = '<<END_CODE';
package Foo::Bar;
$foo = frobulator();
$baz = $foo ** 2;
1;
END_CODE

# Critique code against all loaded policies...
my $perl_critic_config = { -severity => 2 };
my $violation_count = critique( \$code, $perl_critic_config);

# Critique code against one policy...
my $custom_policy = 'Miscellanea::ProhibitFrobulation'
my $violation_count = pcritique( $custom_policy, \$code );

# Critique code against one filename-related policy...
my $custom_policy = 'Modules::RequireFilenameMatchesPackage'
my $violation_count = fcritique( $custom_policy, \$code, 'Foo/Bar.pm' );

DESCRIPTION

This module is used by Perl::Critic only for self-testing. It provides a few handy subroutines for testing new Perl::Critic::Policy modules. Look at the test scripts that ship with Perl::Critic for more examples of how to use these subroutines.

EXPORTS

critique( $code_string_ref, $config_ref )
pcritique( $policy_name, $code_string_ref, $config_ref )
fcritique( $policy_name, $code_string_ref, $filename, $config_ref )
block_perlcriticrc()

AUTHOR

Chris Dolan <cdolan@cpan.org>

COPYRIGHT

Copyright (c) 2005-2006 Chris Dolan. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.