diff options
author | Aaron Crane <arc@cpan.org> | 2016-05-13 13:50:01 +0100 |
---|---|---|
committer | Aaron Crane <arc@cpan.org> | 2016-05-16 13:47:10 +0100 |
commit | a26223c9fe9f719139f4223d916e9ed21e354873 (patch) | |
tree | 34066373183d5b08fa012b32411eccd56903907c | |
parent | 1cb852db7b10e30cf24e4510b02cfa3361b07978 (diff) | |
download | perl-a26223c9fe9f719139f4223d916e9ed21e354873.tar.gz |
POSIX: test that all subroutines are exported
-rw-r--r-- | ext/POSIX/t/export.t | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/ext/POSIX/t/export.t b/ext/POSIX/t/export.t index 5f71b32bb7..ff852eda17 100644 --- a/ext/POSIX/t/export.t +++ b/ext/POSIX/t/export.t @@ -182,7 +182,7 @@ my %expect = ( ], ); -plan (tests => 2 * keys %expect); +plan (tests => 2 * keys(%expect) + keys(%POSIX::)); while (my ($var, $expect) = each %expect) { my $have = *{$POSIX::{$var}}{ARRAY}; @@ -190,3 +190,23 @@ while (my ($var, $expect) = each %expect) { "Correct number of entries for \@POSIX::$var"); is_deeply([sort @$have], $expect, "Correct entries for \@POSIX::$var"); } + +my %no_export_needed = map +($_ => 1), + qw(AUTOLOAD bootstrap constant croak import load_imports + unimplemented_message usage); + +my %exported = map +($_ => 1), + (@POSIX::EXPORT, @POSIX::EXPORT_OK, map @$_, values %POSIX::EXPORT_TAGS); + +for my $name (sort keys %POSIX::) { + my $code = do { no strict 'refs'; \&{"POSIX::$name"} }; + if (!defined &$code) { + pass("$name need not be exported as it does not name a subroutine"); + } + elsif ($no_export_needed{$name}) { + pass("$name need not be exported as it is part of the internals"); + } + else { + ok($exported{$name}, "subroutine POSIX::$name is exported somehow"); + } +} |