Skip to content

Commit

Permalink
added new function: get_full_functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bayashi committed Feb 14, 2013
1 parent a241f2f commit f8e0474
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/Module/Functions.pm
Expand Up @@ -9,6 +9,7 @@ use parent qw/Exporter/;
use Sub::Identify ();

our @EXPORT = qw(get_public_functions);
our @EXPORT_OK = qw(get_full_functions);

sub get_public_functions {
my $klass = shift || caller(0);
Expand All @@ -24,6 +25,16 @@ sub get_public_functions {
return @functions;
}

sub get_full_functions {
my $klass = shift || caller(0);
my @functions;
no strict 'refs';
while (my ($k, $v) = each %{"${klass}::"}) {
push @functions, $k;
}
return @functions;
}

1;
__END__
Expand Down
14 changes: 14 additions & 0 deletions t/02_full_functions.t
@@ -0,0 +1,14 @@
use strict;
use warnings;
use utf8;
use Test::More;
use lib 't/lib/';
use Bar;
use Module::Functions qw/get_full_functions/;

is_deeply(
[ sort( get_full_functions('Bar') ) ],
[qw/BEGIN EXPORT ISA _barbar bar catfile import/]
);

done_testing;
14 changes: 14 additions & 0 deletions t/lib/Bar.pm
@@ -0,0 +1,14 @@
package Bar;
use strict;
use warnings;
use utf8;
use parent qw/Exporter/;

use File::Spec::Functions qw/catfile/;

sub bar { '5963' }

sub _barbar { '0843' }

1;

0 comments on commit f8e0474

Please sign in to comment.