Test-API-0.005/000755 000765 000024 00000000000 12326224420 013273 5ustar00davidstaff000000 000000 Test-API-0.005/Changes000644 000765 000024 00000001407 12326224420 014570 0ustar00davidstaff000000 000000 Revision history for Test-API 0.005 2014-04-24 11:09:01-04:00 America/New_York [CHANGED] - common methods treated as private (e.g. AUTOLOAD, BUILD) are ignored 0.004 2014-03-14 11:43:54+01:00 Europe/Paris [ADDED] - class_api_ok function tests methods, which may be provided the module tested or a superclass (Toby Inkster) [CHANGED] - dropped dependencies on superclass and Devel::Symdump (Toby Inkster) 0.003 2014-02-27 06:19:07-05:00 America/New_York [CHANGED] - updated distribution metadata, repo and bugtracker - switched to Dist::Zilla for managing this distribution 0.002 Mon Mar 9 18:30:20 EDT 2009 [ADDED] - import_ok() function 0.001 Sun Mar 8 16:38:11 EDT 2009 - Initial release Test-API-0.005/CONTRIBUTING000644 000765 000024 00000006512 12326224420 015131 0ustar00davidstaff000000 000000 ## HOW TO CONTRIBUTE Thank you for considering contributing to this distribution. This file contains instructions that will help you work with the source code. The distribution is managed with Dist::Zilla. This means than many of the usual files you might expect are not in the repository, but are generated at release time (e.g. Makefile.PL). Generally, **you do not need Dist::Zilla to contribute patches**. You do need Dist::Zilla to create a tarball and/or install from the repository. See below for guidance. ### Getting dependencies See the included `cpanfile` file for a list of dependencies. If you have App::cpanminus 1.6 or later installed, you can use `cpanm` to satisfy dependencies like this: $ cpanm --installdeps . Otherwise, you can install Module::CPANfile 1.0002 or later and then satisfy dependencies with the regular `cpan` client and `cpanfile-dump`: $ cpan `cpanfile-dump` ### Running tests You can run tests directly using the `prove` tool: $ prove -l $ prove -lv t/some_test_file.t For most of my distributions, `prove` is entirely sufficient for you to test any patches you have. I use `prove` for 99% of my testing during development. ### Code style and tidying Please try to match any existing coding style. If there is a `.perltidyrc` file, please install Perl::Tidy and use perltidy before submitting patches. If there is a `tidyall.ini` file, you can also install Code::TidyAll and run `tidyall` on a file or `tidyall -a` to tidy all files. ### Patching documentation Much of the documentation Pod is generated at release time. Depending on the distribution, some of my documentation may be written in a Pod dialect called WikiDoc. (See Pod::WikiDoc on CPAN.) If you would like to submit a documentation edit, please limit yourself to the documentation you see. If you see typos or documentation issues in the generated docs, please email or open a bug ticket instead of patching. ### Installing from the repository If you want to install directly from the repository, you need to have Dist::Zilla installed (see below). If this is a burden to you, I welcome patches against a CPAN tarball instead of the repository. ### Installing and using Dist::Zilla Dist::Zilla is a very powerful authoring tool, optimized for maintaining a large number of distributions with a high degree of automation, but it has a large dependency chain, a bit of a learning curve and requires a number of author-specific plugins. To install it from CPAN, I recommend one of the following approaches for the quickest installation: # using CPAN.pm, but bypassing non-functional pod tests $ cpan TAP::Harness::Restricted $ PERL_MM_USE_DEFAULT=1 HARNESS_CLASS=TAP::Harness::Restricted cpan Dist::Zilla # using cpanm, bypassing *all* tests $ cpanm -n Dist::Zilla In either case, it's probably going to take about 10 minutes. Go for a walk, go get a cup of your favorite beverage, take a bathroom break, or whatever. When you get back, Dist::Zilla should be ready for you. Then you need to install any plugins specific to this distribution: $ cpan `dzil authordeps` $ dzil authordeps | cpanm Once installed, here are some dzil commands you might try: $ dzil build $ dzil test $ dzil xtest To install from the repository, use: $ dzil install You can learn more about Dist::Zilla at http://dzil.org/ Test-API-0.005/cpanfile000644 000765 000024 00000002073 12326224420 015001 0ustar00davidstaff000000 000000 requires "Symbol" => "0"; requires "Test::Builder::Module" => "0.86"; requires "perl" => "5.006"; requires "strict" => "0"; requires "warnings" => "0"; on 'test' => sub { requires "Carp" => "0"; requires "Exporter" => "0"; requires "ExtUtils::MakeMaker" => "0"; requires "File::Spec::Functions" => "0"; requires "List::Util" => "0"; requires "Test::Builder::Tester" => "1.18"; requires "Test::More" => "0"; requires "version" => "0"; }; on 'test' => sub { recommends "CPAN::Meta" => "0"; recommends "CPAN::Meta::Requirements" => "2.120900"; }; on 'configure' => sub { requires "ExtUtils::MakeMaker" => "6.17"; }; on 'develop' => sub { requires "Dist::Zilla" => "5.015"; requires "Dist::Zilla::PluginBundle::DAGOLDEN" => "0.060"; requires "File::Spec" => "0"; requires "File::Temp" => "0"; requires "IO::Handle" => "0"; requires "IPC::Open3" => "0"; requires "Pod::Coverage::TrustPod" => "0"; requires "Test::CPAN::Meta" => "0"; requires "Test::More" => "0"; requires "Test::Pod" => "1.41"; requires "Test::Pod::Coverage" => "1.08"; }; Test-API-0.005/dist.ini000644 000765 000024 00000000215 12326224420 014735 0ustar00davidstaff000000 000000 name = Test-API author = David Golden license = Apache_2_0 copyright_holder = David Golden [@DAGOLDEN] :version = 0.060 Test-API-0.005/lib/000755 000765 000024 00000000000 12326224420 014041 5ustar00davidstaff000000 000000 Test-API-0.005/LICENSE000644 000765 000024 00000026354 12326224420 014312 0ustar00davidstaff000000 000000 This software is Copyright (c) 2014 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Test-API-0.005/Makefile.PL000644 000765 000024 00000003047 12326224420 015251 0ustar00davidstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.015. use strict; use warnings; use 5.006; use ExtUtils::MakeMaker 6.17; my %WriteMakefileArgs = ( "ABSTRACT" => "Test a list of subroutines provided by a module", "AUTHOR" => "David Golden ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.17" }, "DISTNAME" => "Test-API", "EXE_FILES" => [], "LICENSE" => "apache", "NAME" => "Test::API", "PREREQ_PM" => { "Symbol" => 0, "Test::Builder::Module" => "0.86", "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Carp" => 0, "Exporter" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec::Functions" => 0, "List::Util" => 0, "Test::Builder::Tester" => "1.18", "Test::More" => 0, "version" => 0 }, "VERSION" => "0.005", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Exporter" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec::Functions" => 0, "List::Util" => 0, "Symbol" => 0, "Test::Builder::Module" => "0.86", "Test::Builder::Tester" => "1.18", "Test::More" => 0, "strict" => 0, "version" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Test-API-0.005/MANIFEST000644 000765 000024 00000001172 12326224420 014425 0ustar00davidstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.015. CONTRIBUTING Changes LICENSE MANIFEST META.json META.yml Makefile.PL README cpanfile dist.ini lib/Test/API.pm perlcritic.rc t/00-report-prereqs.t t/02-public.t t/03-export.t t/04-class-ok.t t/lib/Child.pm t/lib/Export.pm t/lib/ExportComplex.pm t/lib/NoSubs.pm t/lib/Parent.pm t/lib/PvtFoo.pm t/lib/SubFoo.pm t/lib/UseCarp.pm tidyall.ini xt/author/00-compile.t xt/author/critic.t xt/author/pod-spell.t xt/release/distmeta.t xt/release/minimum-version.t xt/release/pod-coverage.t xt/release/pod-syntax.t xt/release/portability.t xt/release/test-version.t Test-API-0.005/META.json000644 000765 000024 00000004742 12326224420 014723 0ustar00davidstaff000000 000000 { "abstract" : "Test a list of subroutines provided by a module", "author" : [ "David Golden " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.015, CPAN::Meta::Converter version 2.140640", "license" : [ "apache_2_0" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Test-API", "no_index" : { "directory" : [ "t", "xt", "examples", "corpus" ], "package" : [ "DB" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.17" } }, "develop" : { "requires" : { "Dist::Zilla" : "5.015", "Dist::Zilla::PluginBundle::DAGOLDEN" : "0.060", "File::Spec" : "0", "File::Temp" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Meta" : "0", "Test::More" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "Symbol" : "0", "Test::Builder::Module" : "0.86", "perl" : "5.006", "strict" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "0", "CPAN::Meta::Requirements" : "2.120900" }, "requires" : { "Carp" : "0", "Exporter" : "0", "ExtUtils::MakeMaker" : "0", "File::Spec::Functions" : "0", "List::Util" : "0", "Test::Builder::Tester" : "1.18", "Test::More" : "0", "version" : "0" } } }, "provides" : { "Test::API" : { "file" : "lib/Test/API.pm", "version" : "0.005" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/dagolden/Test-API/issues" }, "homepage" : "https://github.com/dagolden/Test-API", "repository" : { "type" : "git", "url" : "https://github.com/dagolden/Test-API.git", "web" : "https://github.com/dagolden/Test-API" } }, "version" : "0.005", "x_authority" : "cpan:DAGOLDEN", "x_contributors" : [ "Toby Inkster " ] } Test-API-0.005/META.yml000644 000765 000024 00000002117 12326224420 014545 0ustar00davidstaff000000 000000 --- abstract: 'Test a list of subroutines provided by a module' author: - 'David Golden ' build_requires: Carp: '0' Exporter: '0' ExtUtils::MakeMaker: '0' File::Spec::Functions: '0' List::Util: '0' Test::Builder::Tester: '1.18' Test::More: '0' version: '0' configure_requires: ExtUtils::MakeMaker: '6.17' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.015, CPAN::Meta::Converter version 2.140640' license: apache meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Test-API no_index: directory: - t - xt - examples - corpus package: - DB provides: Test::API: file: lib/Test/API.pm version: '0.005' requires: Symbol: '0' Test::Builder::Module: '0.86' perl: '5.006' strict: '0' warnings: '0' resources: bugtracker: https://github.com/dagolden/Test-API/issues homepage: https://github.com/dagolden/Test-API repository: https://github.com/dagolden/Test-API.git version: '0.005' x_authority: cpan:DAGOLDEN x_contributors: - 'Toby Inkster ' Test-API-0.005/perlcritic.rc000644 000765 000024 00000001166 12326224420 015765 0ustar00davidstaff000000 000000 severity = 5 verbose = 8 [Variables::ProhibitPunctuationVars] allow = $@ $! [TestingAndDebugging::ProhibitNoStrict] allow = refs [Variables::ProhibitEvilVariables] variables = $DB::single # Turn these off [-BuiltinFunctions::ProhibitStringyEval] [-ControlStructures::ProhibitPostfixControls] [-ControlStructures::ProhibitUnlessBlocks] [-Documentation::RequirePodSections] [-InputOutput::ProhibitInteractiveTest] [-References::ProhibitDoubleSigils] [-RegularExpressions::RequireExtendedFormatting] [-InputOutput::ProhibitTwoArgOpen] [-Modules::ProhibitEvilModules] # Turn this on [Lax::ProhibitStringyEval::ExceptForRequire] Test-API-0.005/README000644 000765 000024 00000007131 12326224420 014155 0ustar00davidstaff000000 000000 NAME Test::API - Test a list of subroutines provided by a module VERSION version 0.005 SYNOPSIS use Test::More tests => 3; use Test::API; require_ok( 'My::Package' ); public_ok ( 'My::Package', @names ); import_ok ( 'My::Package', export => [ 'foo', 'bar' ], export_ok => [ 'baz', 'bam' ], ); class_api_ok( 'My::Class', @methods ); DESCRIPTION This simple test module checks the subroutines provided by a module. This is useful for confirming a planned API in testing and ensuring that other functions aren't unintentionally included via import. USAGE Note: Subroutines starting with an underscore are ignored, as are a number of other methods not intended to be called directly by end-users. import unimport bootstrap AUTOLOAD BUILD BUILDARGS CLONE CLONE_SKIP DESTROY DEMOLISH TIESCALAR TIEARRAY TIEHASH TIEHANDLE FETCH STORE UNTIE FETCHSIZE STORESIZE POP PUSH SHIFT UNSHIFT SPLICE DELETE EXISTS EXTEND CLEAR FIRSTKEY NEXTKEY PRINT PRINTF WRITE READLINE GETC READ CLOSE BINMODE OPEN EOF FILENO SEEK TELL SCALAR MODIFY_REF_ATTRIBUTES MODIFY_SCALAR_ATTRIBUTES MODIFY_ARRAY_ATTRIBUTES MODIFY_HASH_ATTRIBUTES MODIFY_CODE_ATTRIBUTES MODIFY_GLOB_ATTRIBUTES MODIFY_FORMAT_ATTRIBUTES MODIFY_IO_ATTRIBUTES FETCH_REF_ATTRIBUTES FETCH_SCALAR_ATTRIBUTES FETCH_ARRAY_ATTRIBUTES FETCH_HASH_ATTRIBUTES FETCH_CODE_ATTRIBUTES FETCH_GLOB_ATTRIBUTES FETCH_FORMAT_ATTRIBUTES FETCH_IO_ATTRIBUTES Therefore, do not include any of these in a list of expected subroutines. public_ok public_ok( $package, @names ); This function checks that all of the @names provided are available within the $package namespace and that *only* these subroutines are available. This means that subroutines imported from other modules will cause this test to fail unless they are explicitly included in @names. class_api_ok class_api_ok( $class, @names ); A variation of "public_ok" for object-oriented modules. Allows superclasses to fill in "missing" subroutines, but "extra" methods provided by superclasses will not cause the test to fail. import_ok import_ok ( $package, %spec ); This function checks that $package correctly exports an expected list of subroutines and *only* these subroutines. The %spec generally follows the style used by [Exporter], but in lower case: %spec = ( export => [ 'foo', 'bar' ], # exported automatically export_ok => [ 'baz', 'bam' ], # optional exports ); For "export_ok", the test will check for public functions not listed in "export" or "export_ok" that can be imported and will fail if any are found. SEE ALSO * Test::ClassAPI -- more geared towards class trees with inheritance SUPPORT Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker at . You will be notified automatically of any progress on your issue. Source Code This is open source software. The code repository is available for public review and contribution under the terms of the license. git clone https://github.com/dagolden/Test-API.git AUTHOR David Golden CONTRIBUTOR Toby Inkster COPYRIGHT AND LICENSE This software is Copyright (c) 2014 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 Test-API-0.005/t/000755 000765 000024 00000000000 12326224420 013536 5ustar00davidstaff000000 000000 Test-API-0.005/tidyall.ini000644 000765 000024 00000000240 12326224420 015432 0ustar00davidstaff000000 000000 ; Install Code::TidyAll ; run "tidyall -a" to tidy all files ; run "tidyall -g" to tidy only files modified from git [PerlTidy] select = {lib,t}/**/*.{pl,pm,t} Test-API-0.005/xt/000755 000765 000024 00000000000 12326224420 013726 5ustar00davidstaff000000 000000 Test-API-0.005/xt/author/000755 000765 000024 00000000000 12326224420 015230 5ustar00davidstaff000000 000000 Test-API-0.005/xt/release/000755 000765 000024 00000000000 12326224420 015346 5ustar00davidstaff000000 000000 Test-API-0.005/xt/release/distmeta.t000644 000765 000024 00000000172 12326224420 017345 0ustar00davidstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. use Test::CPAN::Meta; meta_yaml_ok(); Test-API-0.005/xt/release/minimum-version.t000644 000765 000024 00000000266 12326224420 020675 0ustar00davidstaff000000 000000 #!perl use Test::More; eval "use Test::MinimumVersion"; plan skip_all => "Test::MinimumVersion required for testing minimum versions" if $@; all_minimum_version_ok( qq{5.010} ); Test-API-0.005/xt/release/pod-coverage.t000644 000765 000024 00000000334 12326224420 020106 0ustar00davidstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Test-API-0.005/xt/release/pod-syntax.t000644 000765 000024 00000000220 12326224420 017633 0ustar00davidstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Test-API-0.005/xt/release/portability.t000644 000765 000024 00000000332 12326224420 020073 0ustar00davidstaff000000 000000 #!perl use strict; use warnings; use Test::More; eval 'use Test::Portability::Files'; plan skip_all => 'Test::Portability::Files required for testing portability' if $@; options(test_one_dot => 0); run_tests(); Test-API-0.005/xt/release/test-version.t000644 000765 000024 00000000643 12326224420 020200 0ustar00davidstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 0.002004 BEGIN { eval "use Test::Version; 1;" or die $@; } my @imports = ( 'version_all_ok' ); my $params = { is_strict => 0, has_version => 1, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; Test-API-0.005/xt/author/00-compile.t000644 000765 000024 00000002032 12326224420 017257 0ustar00davidstaff000000 000000 use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.040 use Test::More tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Test/API.pm' ); # fake home for cpan-testers use File::Temp; local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; Test-API-0.005/xt/author/critic.t000644 000765 000024 00000000435 12326224420 016674 0ustar00davidstaff000000 000000 #!perl use strict; use warnings; use Test::More; use English qw(-no_match_vars); eval "use Test::Perl::Critic"; plan skip_all => 'Test::Perl::Critic required to criticise code' if $@; Test::Perl::Critic->import( -profile => "perlcritic.rc" ) if -e "perlcritic.rc"; all_critic_ok(); Test-API-0.005/xt/author/pod-spell.t000644 000765 000024 00000000432 12326224420 017313 0ustar00davidstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.006007 use Test::Spelling 0.12; use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ David Golden dagolden Toby Inkster mail lib Test API Test-API-0.005/t/00-report-prereqs.t000644 000765 000024 00000014063 12326224420 017136 0ustar00davidstaff000000 000000 #!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.013 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec::Functions; use List::Util qw/max/; use version; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_req = "CPAN::Meta::Requirements"; my $HAS_CPAN_META = eval "require $cpan_meta"; ## no critic my $HAS_CPAN_META_REQ = eval "require $cpan_meta_req; $cpan_meta_req->VERSION('2.120900')"; # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _merge_requires { my ($collector, $prereqs) = @_; for my $phase ( qw/configure build test runtime develop/ ) { next unless exists $prereqs->{$phase}; if ( my $req = $prereqs->{$phase}{'requires'} ) { my $cmr = CPAN::Meta::Requirements->from_string_hash( $req ); $collector->add_requirements( $cmr ); } } } my %include = map {; $_ => 1 } qw( ); my %exclude = map {; $_ => 1 } qw( ); # Add static prereqs to the included modules list my $static_prereqs = do { my $x = { 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '6.17' } }, 'develop' => { 'requires' => { 'Dist::Zilla' => '5.015', 'Dist::Zilla::PluginBundle::DAGOLDEN' => '0.060', 'File::Spec' => '0', 'File::Temp' => '0', 'IO::Handle' => '0', 'IPC::Open3' => '0', 'Pod::Coverage::TrustPod' => '0', 'Test::CPAN::Meta' => '0', 'Test::More' => '0', 'Test::Pod' => '1.41', 'Test::Pod::Coverage' => '1.08' } }, 'runtime' => { 'requires' => { 'Symbol' => '0', 'Test::Builder::Module' => '0.86', 'perl' => '5.006', 'strict' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '0', 'CPAN::Meta::Requirements' => '2.120900' }, 'requires' => { 'Carp' => '0', 'Exporter' => '0', 'ExtUtils::MakeMaker' => '0', 'File::Spec::Functions' => '0', 'List::Util' => '0', 'Test::Builder::Tester' => '1.18', 'Test::More' => '0', 'version' => '0' } } }; $x; }; delete $static_prereqs->{develop} if not $ENV{AUTHOR_TESTING}; $include{$_} = 1 for map { keys %$_ } map { values %$_ } values %$static_prereqs; # Merge requirements for major phases (if we can) my $all_requires; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META_REQ ) { $all_requires = $cpan_meta_req->new; _merge_requires($all_requires, $static_prereqs); } # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; if ( $source && $HAS_CPAN_META ) { if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { my $dynamic_prereqs = $meta->prereqs; delete $dynamic_prereqs->{develop} if not $ENV{AUTHOR_TESTING}; $include{$_} = 1 for map { keys %$_ } map { values %$_ } values %$dynamic_prereqs; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META_REQ ) { _merge_requires($all_requires, $dynamic_prereqs); } } } else { $source = 'static metadata'; } my @modules = sort grep { ! $exclude{$_} } keys %include; my @reports = [qw/Version Module/]; my @dep_errors; my $req_hash = defined($all_requires) ? $all_requires->as_string_hash : {}; for my $mod ( @modules ) { next if $mod eq 'perl'; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e catfile($_, $file) } @INC; if ( $prefix ) { my $ver = MM->parse_version( catfile($prefix, $file) ); $ver = "undef" unless defined $ver; # Newer MM should do this anyway push @reports, [$ver, $mod]; if ( $DO_VERIFY_PREREQS && $all_requires ) { my $req = $req_hash->{$mod}; if ( defined $req && length $req ) { if ( ! defined eval { version->parse($ver) } ) { push @dep_errors, "$mod version '$ver' cannot be parsed (version '$req' required)"; } elsif ( ! $all_requires->accepts_module( $mod => $ver ) ) { push @dep_errors, "$mod version '$ver' is not in required range '$req'"; } } } } else { push @reports, ["missing", $mod]; if ( $DO_VERIFY_PREREQS && $all_requires ) { my $req = $req_hash->{$mod}; if ( defined $req && length $req ) { push @dep_errors, "$mod is not installed (version '$req' required)"; } } } } if ( @reports ) { my $vl = max map { length $_->[0] } @reports; my $ml = max map { length $_->[1] } @reports; splice @reports, 1, 0, ["-" x $vl, "-" x $ml]; diag "\nVersions for all modules listed in $source (including optional ones):\n", map {sprintf(" %*s %*s\n",$vl,$_->[0],-$ml,$_->[1])} @reports; } if ( @dep_errors ) { diag join("\n", "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", "The following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass; # vim: ts=4 sts=4 sw=4 et: Test-API-0.005/t/02-public.t000644 000765 000024 00000003427 12326224420 015426 0ustar00davidstaff000000 000000 # Copyright (c) 2009 by David Golden. All rights reserved. # Licensed under Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. # A copy of the License was distributed with this file or you may obtain a # copy of the License from http://www.apache.org/licenses/LICENSE-2.0 use strict; use warnings; select STDERR; $|++; select STDOUT; $|++; use Test::More; use Test::Builder::Tester 1.18; use Test::API; plan tests => 11; require_ok('t::lib::NoSubs'); require_ok('t::lib::SubFoo'); require_ok('t::lib::UseCarp'); require_ok('t::lib::PvtFoo'); test_out("not ok 1 - public API for t::lib::NonExisting"); test_fail(+2); test_diag("Module 't::lib::NonExisting' not loaded"); public_ok('t::lib::NonExisting'); test_test('public_ok - module not loaded'); test_out("ok 1 - public API for t::lib::NoSubs"); public_ok('t::lib::NoSubs'); test_test('public_ok - none provided, none expected'); test_out("not ok 1 - public API for t::lib::NoSubs"); test_fail(+2); test_diag("missing: foo"); public_ok( 't::lib::NoSubs', 'foo' ); test_test('public_ok - none provided, one expected'); test_out("not ok 1 - public API for t::lib::SubFoo"); test_fail(+2); test_diag("extra: foo"); public_ok('t::lib::SubFoo'); test_test('public_ok - one provided, none expected'); test_out("ok 1 - public API for t::lib::SubFoo"); public_ok( 't::lib::SubFoo', 'foo' ); test_test('public_ok - one provided, one expected'); test_out("not ok 1 - public API for t::lib::UseCarp"); test_fail(+2); test_diag( "missing: foo", "extra: carp confess croak" ); public_ok( 't::lib::UseCarp', 'foo' ); test_test('public_ok - use Carp + missing sub'); test_out("ok 1 - public API for t::lib::PvtFoo"); public_ok('t::lib::PvtFoo'); test_test('public_ok - private provided, none expected'); Test-API-0.005/t/03-export.t000644 000765 000024 00000007444 12326224420 015475 0ustar00davidstaff000000 000000 # Copyright (c) 2009 by David Golden. All rights reserved. # Licensed under Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. # A copy of the License was distributed with this file or you may obtain a # copy of the License from http://www.apache.org/licenses/LICENSE-2.0 use strict; use warnings; select STDERR; $|++; select STDOUT; $|++; use Test::More; use Test::Builder::Tester 1.18; use Test::API; plan tests => 14; require_ok('t::lib::NoSubs'); require_ok('t::lib::Export'); require_ok('t::lib::ExportComplex'); #--------------------------------------------------------------------------# # not loaded #--------------------------------------------------------------------------# test_out("not ok 1 - importing from t::lib::NonExisting"); test_fail(+2); test_diag("Module 't::lib::NonExisting' not loaded"); import_ok('t::lib::NonExisting'); test_test('import_ok - module not loaded'); #--------------------------------------------------------------------------# # nothing exported #--------------------------------------------------------------------------# test_out("ok 1 - importing from t::lib::NoSubs"); import_ok('t::lib::NoSubs'); test_test('import_ok - export: none; expect: none'); test_out("not ok 1 - importing from t::lib::NoSubs"); test_fail(+2); test_diag("not exported: foo"); import_ok( 't::lib::NoSubs', export => 'foo' ); test_test('import_ok - export: none; expect: foo'); #--------------------------------------------------------------------------# # just one sub exported #--------------------------------------------------------------------------# test_out("ok 1 - importing from t::lib::Export"); import_ok( 't::lib::Export', export => [qw/foo/] ); test_test('import_ok - export: foo; expect: foo'); test_out("not ok 1 - importing from t::lib::Export"); test_fail(+2); test_diag("unexpectedly exported: foo"); import_ok('t::lib::Export'); test_test('import_ok - export: foo; expect: none'); #--------------------------------------------------------------------------# # multi-subs exported #--------------------------------------------------------------------------# test_out("ok 1 - importing from t::lib::ExportComplex"); import_ok( 't::lib::ExportComplex', export => [qw/foo bar/], export_ok => [qw/baz bam/] ); test_test('import_ok - export: several; expect: several'); test_out("not ok 1 - importing from t::lib::ExportComplex"); test_fail(+2); test_diag("unexpectedly exported: bar foo"); import_ok( 't::lib::ExportComplex', export => [], export_ok => [qw/baz bam/], ); test_test('import_ok - export: several; expect: none'); test_out("not ok 1 - importing from t::lib::ExportComplex"); test_fail(+2); test_diag("unexpectedly exported: bar"); import_ok( 't::lib::ExportComplex', export => ['foo'], export_ok => [qw/baz bam/] ); test_test('import_ok - export: several; expect: one'); #--------------------------------------------------------------------------# # export_ok #--------------------------------------------------------------------------# test_out("ok 1 - importing from t::lib::ExportComplex"); import_ok( 't::lib::ExportComplex', export => [qw/foo bar/], export_ok => [qw/baz bam/] ); test_test('import_ok - export_ok several functions'); test_out("not ok 1 - importing from t::lib::ExportComplex"); test_fail(+2); test_diag("not optionally exportable: wibble"); import_ok( 't::lib::ExportComplex', export => [qw/foo bar/], export_ok => [qw/wibble baz bam/] ); test_test('import_ok - export_ok a missing function'); test_out("not ok 1 - importing from t::lib::ExportComplex"); test_fail(+2); test_diag("extra optionally exportable: bam baz"); import_ok( 't::lib::ExportComplex', export => [qw/foo bar/], ); test_test('import_ok - export_ok excludes items in @EXPORT_OK'); Test-API-0.005/t/04-class-ok.t000644 000765 000024 00000002310 12326224420 015654 0ustar00davidstaff000000 000000 # Copyright (c) 2009 by David Golden. All rights reserved. # Licensed under Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. # A copy of the License was distributed with this file or you may obtain a # copy of the License from http://www.apache.org/licenses/LICENSE-2.0 use strict; use warnings; select STDERR; $|++; select STDOUT; $|++; use Test::More; use Test::Builder::Tester 1.18; use Test::API; plan tests => 5; require_ok('t::lib::Parent'); require_ok('t::lib::Child'); #--------------------------------------------------------------------------# # not loaded #--------------------------------------------------------------------------# test_out("not ok 1 - public API for class t::lib::Child"); test_fail(+2); test_diag("extra: www"); class_api_ok('t::lib::Child', qw(xxx yyy zzz)); test_test('class_api_ok - missing method'); test_out("ok 1 - public API for class t::lib::Child"); class_api_ok('t::lib::Child', qw(www xxx yyy zzz)); test_test('class_api_ok - complete set of methods'); test_out("ok 1 - public API for class t::lib::Child"); class_api_ok('t::lib::Child', qw(www xxx yyy)); test_test('class_api_ok - missing inherited method'); Test-API-0.005/t/lib/000755 000765 000024 00000000000 12326224420 014304 5ustar00davidstaff000000 000000 Test-API-0.005/t/lib/Child.pm000644 000765 000024 00000000175 12326224420 015670 0ustar00davidstaff000000 000000 package t::lib::Child; use t::lib::Parent; our @ISA = qw(t::lib::Parent); sub www { 2 } sub xxx { 2 } sub BUILD { 1 } 1; Test-API-0.005/t/lib/Export.pm000644 000765 000024 00000000210 12326224420 016114 0ustar00davidstaff000000 000000 package t::lib::Export; use strict; use warnings; use Exporter; our @ISA = qw/Exporter/; our @EXPORT = qw/foo/; sub foo { 1 } 1; Test-API-0.005/t/lib/ExportComplex.pm000644 000765 000024 00000000420 12326224420 017447 0ustar00davidstaff000000 000000 package t::lib::ExportComplex; use strict; use warnings; use Exporter; our @ISA = qw/Exporter/; our @EXPORT = qw/foo bar/; our @EXPORT_OK = qw/baz bam/; sub foo { 1 } sub bar { 2 } sub baz { 3 } sub bam { 4 } sub bamboozle { 99 } # not exported at all 1; Test-API-0.005/t/lib/NoSubs.pm000644 000765 000024 00000000117 12326224420 016052 0ustar00davidstaff000000 000000 package t::lib::NoSubs; use strict; use warnings; # this package is empty 1; Test-API-0.005/t/lib/Parent.pm000644 000765 000024 00000000107 12326224420 016071 0ustar00davidstaff000000 000000 package t::lib::Parent; sub xxx { 1 } sub yyy { 1 } sub zzz { 1 } 1; Test-API-0.005/t/lib/PvtFoo.pm000644 000765 000024 00000000132 12326224420 016053 0ustar00davidstaff000000 000000 package t::lib::PvtFoo; use strict; use warnings; sub _foo { 1 } sub AUTOLOAD { 1 } 1; Test-API-0.005/t/lib/SubFoo.pm000644 000765 000024 00000000105 12326224420 016033 0ustar00davidstaff000000 000000 package t::lib::SubFoo; use strict; use warnings; sub foo { 1 } 1; Test-API-0.005/t/lib/UseCarp.pm000644 000765 000024 00000000101 12326224420 016174 0ustar00davidstaff000000 000000 package t::lib::UseCarp; use strict; use warnings; use Carp; 1; Test-API-0.005/lib/Test/000755 000765 000024 00000000000 12326224420 014760 5ustar00davidstaff000000 000000 Test-API-0.005/lib/Test/API.pm000644 000765 000024 00000022533 12326224420 015734 0ustar00davidstaff000000 000000 use 5.006; use strict; use warnings; package Test::API; # ABSTRACT: Test a list of subroutines provided by a module our $VERSION = '0.005'; # VERSION use Symbol (); use Test::Builder::Module 0.86; our @ISA = qw/Test::Builder::Module/; our @EXPORT = qw/public_ok import_ok class_api_ok/; #--------------------------------------------------------------------------# sub import_ok ($;@) { ## no critic my $package = shift; my %spec = @_; for my $key (qw/export export_ok/) { $spec{$key} ||= []; $spec{$key} = [ $spec{$key} ] unless ref $spec{$key} eq 'ARRAY'; } my $tb = _builder(); my @errors; my %flagged; my $label = "importing from $package"; return 0 unless _check_loaded( $package, $label ); # test export { my $test_pkg = *{ Symbol::gensym() }{NAME}; eval "package $test_pkg; use $package;"; ## no critic my ( $ok, $missing, $extra ) = _public_ok( $test_pkg, @{ $spec{export} } ); if ( !$ok ) { push @errors, "not exported: @$missing" if @$missing; @flagged{@$missing} = (1) x @$missing if @$missing; push @errors, "unexpectedly exported: @$extra" if @$extra; @flagged{@$extra} = (1) x @$extra if @$extra; } } # test export_ok my @exportable; for my $fcn ( _public_fcns($package) ) { next if $flagged{$fcn}; # already complaining about this so skip next if grep { $fcn eq $_ } @{ $spec{export} }; # exported by default my $pkg_name = *{ Symbol::gensym() }{NAME}; eval "package $pkg_name; use $package '$fcn';"; ## no critic my ( $ok, $missing, $extra ) = _public_ok( $pkg_name, $fcn ); if ($ok) { push @exportable, $fcn; } } my ( $missing, $extra ) = _difference( $spec{export_ok}, \@exportable, ); push @errors, "not optionally exportable: @$missing" if @$missing; push @errors, "extra optionally exportable: @$extra" if @$extra; # notify of results $tb->ok( !@errors, "importing from $package" ); $tb->diag($_) for @errors; return !@errors; } #--------------------------------------------------------------------------# sub public_ok ($;@) { ## no critic my ( $package, @expected ) = @_; my $tb = _builder(); my $label = "public API for $package"; return 0 unless _check_loaded( $package, $label ); my ( $ok, $missing, $extra ) = _public_ok( $package, @expected ); $tb->ok( $ok, $label ); if ( !$ok ) { $tb->diag("missing: @$missing") if @$missing; $tb->diag("extra: @$extra") if @$extra; } return $ok; } #--------------------------------------------------------------------------# sub class_api_ok ($;@) { ## no critic my ( $package, @expected ) = @_; my $tb = _builder(); my $label = "public API for class $package"; return 0 unless _check_loaded( $package, $label ); my ( $ok, $missing, $extra ) = _public_ok( $package, @expected ); # Call ->can to check if missing methods might be provided # by parent classes... if ( !$ok ) { @$missing = grep { not $package->can($_) } @$missing; $ok = not( scalar(@$missing) + scalar(@$extra) ); } $tb->ok( $ok, $label ); if ( !$ok ) { $tb->diag("missing: @$missing") if @$missing; $tb->diag("extra: @$extra") if @$extra; } return $ok; } #--------------------------------------------------------------------------# sub _builder { return __PACKAGE__->builder; } #--------------------------------------------------------------------------# sub _check_loaded { my ( $package, $label ) = @_; ( my $path = $package ) =~ s{::}{/}g; $path .= ".pm"; if ( $INC{$path} ) { return 1; } else { my $tb = _builder(); local $Test::Builder::Level = $Test::Builder::Level + 1; $tb->ok( 0, $label ); $tb->diag("Module '$package' not loaded"); return; } } #--------------------------------------------------------------------------# sub _difference { my ( $array1, $array2 ) = @_; my ( %only1, %only2 ); @only1{@$array1} = (1) x @$array1; delete @only1{@$array2}; @only2{@$array2} = (1) x @$array2; delete @only2{@$array1}; return ( [ sort keys %only1 ], [ sort keys %only2 ] ); } #--------------------------------------------------------------------------# # list adapted from Pod::Coverage my %private = map { ; $_ => 1 } qw( import unimport bootstrap AUTOLOAD BUILD BUILDARGS CLONE CLONE_SKIP DESTROY DEMOLISH meta TIESCALAR TIEARRAY TIEHASH TIEHANDLE FETCH STORE UNTIE FETCHSIZE STORESIZE POP PUSH SHIFT UNSHIFT SPLICE DELETE EXISTS EXTEND CLEAR FIRSTKEY NEXTKEY PRINT PRINTF WRITE READLINE GETC READ CLOSE BINMODE OPEN EOF FILENO SEEK TELL SCALAR MODIFY_REF_ATTRIBUTES MODIFY_SCALAR_ATTRIBUTES MODIFY_ARRAY_ATTRIBUTES MODIFY_HASH_ATTRIBUTES MODIFY_CODE_ATTRIBUTES MODIFY_GLOB_ATTRIBUTES MODIFY_FORMAT_ATTRIBUTES MODIFY_IO_ATTRIBUTES FETCH_REF_ATTRIBUTES FETCH_SCALAR_ATTRIBUTES FETCH_ARRAY_ATTRIBUTES FETCH_HASH_ATTRIBUTES FETCH_CODE_ATTRIBUTES FETCH_GLOB_ATTRIBUTES FETCH_FORMAT_ATTRIBUTES FETCH_IO_ATTRIBUTES ); sub _public_fcns { my ($package) = @_; no strict qw(refs); return grep { substr( $_, 0, 1 ) ne '_' && !$private{$_} && $_ !~ /^\(/ } map { ( my $f = $_ ) =~ s/^\*$package\:://; $f } grep { defined( *$_{CODE} ) } values( %{"$package\::"} ); } #--------------------------------------------------------------------------# sub _public_ok ($;@) { ## no critic my ( $package, @expected ) = @_; my @fcns = _public_fcns($package); my ( $missing, $extra ) = _difference( \@expected, \@fcns ); return ( !@$missing && !@$extra, $missing, $extra ); } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::API - Test a list of subroutines provided by a module =head1 VERSION version 0.005 =head1 SYNOPSIS use Test::More tests => 3; use Test::API; require_ok( 'My::Package' ); public_ok ( 'My::Package', @names ); import_ok ( 'My::Package', export => [ 'foo', 'bar' ], export_ok => [ 'baz', 'bam' ], ); class_api_ok( 'My::Class', @methods ); =head1 DESCRIPTION This simple test module checks the subroutines provided by a module. This is useful for confirming a planned API in testing and ensuring that other functions aren't unintentionally included via import. =head1 USAGE Note: Subroutines starting with an underscore are ignored, as are a number of other methods not intended to be called directly by end-users. import unimport bootstrap AUTOLOAD BUILD BUILDARGS CLONE CLONE_SKIP DESTROY DEMOLISH TIESCALAR TIEARRAY TIEHASH TIEHANDLE FETCH STORE UNTIE FETCHSIZE STORESIZE POP PUSH SHIFT UNSHIFT SPLICE DELETE EXISTS EXTEND CLEAR FIRSTKEY NEXTKEY PRINT PRINTF WRITE READLINE GETC READ CLOSE BINMODE OPEN EOF FILENO SEEK TELL SCALAR MODIFY_REF_ATTRIBUTES MODIFY_SCALAR_ATTRIBUTES MODIFY_ARRAY_ATTRIBUTES MODIFY_HASH_ATTRIBUTES MODIFY_CODE_ATTRIBUTES MODIFY_GLOB_ATTRIBUTES MODIFY_FORMAT_ATTRIBUTES MODIFY_IO_ATTRIBUTES FETCH_REF_ATTRIBUTES FETCH_SCALAR_ATTRIBUTES FETCH_ARRAY_ATTRIBUTES FETCH_HASH_ATTRIBUTES FETCH_CODE_ATTRIBUTES FETCH_GLOB_ATTRIBUTES FETCH_FORMAT_ATTRIBUTES FETCH_IO_ATTRIBUTES Therefore, do not include any of these in a list of expected subroutines. =head2 public_ok public_ok( $package, @names ); This function checks that all of the C<@names> provided are available within the C<$package> namespace and that *only* these subroutines are available. This means that subroutines imported from other modules will cause this test to fail unless they are explicitly included in C<@names>. =head2 class_api_ok class_api_ok( $class, @names ); A variation of C for object-oriented modules. Allows superclasses to fill in "missing" subroutines, but "extra" methods provided by superclasses will not cause the test to fail. =head2 import_ok import_ok ( $package, %spec ); This function checks that C<$package> correctly exports an expected list of subroutines and *only* these subroutines. The C<%spec> generally follows the style used by [Exporter], but in lower case: %spec = ( export => [ 'foo', 'bar' ], # exported automatically export_ok => [ 'baz', 'bam' ], # optional exports ); For C, the test will check for public functions not listed in C or C that can be imported and will fail if any are found. =head1 SEE ALSO =over 4 =item * L -- more geared towards class trees with inheritance =back =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan =head1 SUPPORT =head2 Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker at L. You will be notified automatically of any progress on your issue. =head2 Source Code This is open source software. The code repository is available for public review and contribution under the terms of the license. L git clone https://github.com/dagolden/Test-API.git =head1 AUTHOR David Golden =head1 CONTRIBUTOR Toby Inkster =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 =cut