## name basic failure
## failures 1
## cut

sub _foo {};

#-----------------------------------------------------------------------------

## name basic pass
## failures 0
## cut

sub _foo {};
_foo;

#-----------------------------------------------------------------------------

## name Method call is OK
## failures 0
## cut

sub _foo {};
$self->_foo();

#-----------------------------------------------------------------------------

## name Method call where invocant is "shift"
## failures 0
## cut

sub _foo {};
shift->_foo;

#-----------------------------------------------------------------------------

## name other builtin-function followed by private method call
## failures 0
## cut

sub _foo {};
pop->_foo();

#-----------------------------------------------------------------------------

## name Maybe non-obvious failure
## failures 1
## cut

sub _foo {};

$self->SUPER::_foo();

#-----------------------------------------------------------------------------

## name Forward references do not count
## failures 0
## cut

sub _foo;

#-----------------------------------------------------------------------------

## name User-configured exceptions.
## parms { allow => '_foo _bar _baz' }
## failures 0
## cut

sub _foo {};
sub _bar ($) {};
sub _baz : method {};

#-----------------------------------------------------------------------------

## name private_name_regex passing
## failures 0
## parms { private_name_regex => '_(?!_|parse_)\w+' }
## cut

sub __foo {};
sub __bar ($) {};
sub __baz : method {};
sub _parse_my_argument {};

#-----------------------------------------------------------------------------

## name private_name_regex failure
## failures 3
## parms { private_name_regex => '_(?!_)\w+' }
## cut

sub _foo {};
sub _bar ($) {};
sub _baz : method {};

#-----------------------------------------------------------------------------

## name reference to private subroutine
## failures 0
## cut

sub _foo {};
my $bar = \&_foo;

#-----------------------------------------------------------------------------

## name goto to private subroutine
## failures 0
## cut

sub _foo {};
sub bar {
    goto &_foo;
}

#-----------------------------------------------------------------------------

## name private subroutine used in overload
## failures 0
## cut

use overload ( cmp => '_compare' );
sub _compare {};

#-----------------------------------------------------------------------------

## name private subroutine used in overload, the bad way
## failures 0
## cut

use overload ( cmp => _compare => foo => 'bar' );
sub _compare {};

#-----------------------------------------------------------------------------

## name private subroutine used in overload, by reference
## failures 0
## cut

use overload ( cmp => \&_compare );
sub _compare {};

#-----------------------------------------------------------------------------

## name recursive but otherwise unused subroutine
## failures 2
## cut

sub _foo {
    my ( $arg ) = @_;
    return $arg <= 1 ? $arg : $arg * _foo( $arg - 1 );
}

sub _bar {
    --$_[0] > 0 and goto &_bar;
    return $_[0];
}

#-----------------------------------------------------------------------------

## name recursive subroutine called outside itself
## failures 0
## cut

_foo( 3 );
sub _foo {
    my ( $arg ) = @_;
    return $arg <= 1 ? $arg : $arg * _foo( $arg - 1 );
}

_bar( 1.3 );
sub _bar {
    --$_[0] > 0 and goto &_bar;
    return $_[0];
}

#-----------------------------------------------------------------------------

## name subroutine declared in someone else's name space
## failures 0
## cut

sub _Foo::_foo {}

#-----------------------------------------------------------------------------

## name Subroutine called in replacement portion of s/.../.../e
## failures 0
## cut

s/ ( foo ) / _bar( $1 ) /smxe;

sub _bar {
    my ( $foo ) = @_;
    return $foo x 3;
}

#-----------------------------------------------------------------------------

## name Subroutine called in regexp interpolation
## failures 0
## cut

s/ ( foo ) /@{[ _bar( $1 ) ]}/smx;

sub _bar {
    my ( $foo ) = @_;
    return $foo x 3;
}

#-----------------------------------------------------------------------------

## name Subroutine called in regexp embedded code
## failures 0
## cut

m/ (?{ _foo() }) /smx;

sub _foo {
    return 'bar';
}

#-----------------------------------------------------------------------------

## name RT 61311: dies on "&_name" call
## failures 0
## cut

sub first {
    &_second();
}

sub _second {
    print "A private sub\n";
}

#-----------------------------------------------------------------------------


##############################################################################
#      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/Perl-Critic/t/Subroutines/ProhibitUnusedPrivateSubroutines.run $
#     $Date: 2010-09-13 22:25:14 -0700 (Mon, 13 Sep 2010) $
#   $Author: wyant $
# $Revision: 3922 $
##############################################################################

# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 78
#   indent-tabs-mode: nil
#   c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :