Test-Routine-0.027/000755 000767 000024 00000000000 13340653227 014176 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/LICENSE000644 000767 000024 00000043663 13340653227 015217 0ustar00rjbsstaff000000 000000 This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2010 by Ricardo Signes. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2010 by Ricardo Signes. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Test-Routine-0.027/Changes000644 000767 000024 00000012024 13340653227 015470 0ustar00rjbsstaff000000 000000 Revision history for Test-Routine 0.027 2018-08-26 21:40:35-04:00 America/New_York - no changes since 0.026 0.026 2018-07-15 12:14:57-04:00 America/Toronto (TRIAL RELEASE) - add test_routine_test_traits method to apply more traits to test objects - add skip_reason to test objects to allow them to say "skip me on this run" - drop use of undocumented "with_caller" feature from Moose::Exporter 0.025 2017-04-13 17:43:19-04:00 America/New_York - remove fresh_instance; it wasn't documented, and it probably was not going to work out - the Runner no longer caches the test_instance, so its BUILD and DEMOLISH should now be called usefully - Test::Routine::Common now adds stub BUILD and DEMOLISH so you can use method modifiers on them 0.024 2017-01-16 13:03:18-05:00 America/New_York - tests are now run with Test::Abortable's subtest() instead of Test2::API directly; this means they can be safely aborted with exceptions that conform to the Test::Abortable rules; see its docs for more information 0.023 2016-11-28 17:41:32+11:00 Australia/Melbourne - When running subtests, use Test2::API rather than Test::More. This means that Test::Routine tests that never use Test::Builder for their own testing won't load it at all, but it also means that you'll need to be on a pretty recent Test-Simple distribution. - (no code changes from 0.022, just a non-trial release) 0.022 2016-07-18 20:13:38-04:00 America/New_York (TRIAL RELEASE) - fix the mxms.t tests for Test2 changes (really, we should update the tests to use an event-intercepting hub for our tests) 0.021 2016-07-18 12:45:57-04:00 America/New_York (TRIAL RELEASE) - When running subtests, use Test2::API rather than Test::More. This means that Test::Routine tests that never use Test::Builder for their own testing won't load it at all, but it also means that you'll need to be on a pretty recent Test-Simple distribution. 0.020 2014-09-01 22:02:27-04:00 America/New_York - generation of Test::Routine::Manual::Demo is fixed - notice another possible case of name conflict; we may change how this works in the future, but only safely 0.019 2014-07-04 09:54:01-04:00 America/New_York - cope with alternate indenting of subtest leader 0.018 2014-01-11 14:13:19-05:00 America/New_York - avoid an uninitialized warning on 5.8 from new TEST_METHOD code 0.017 2013-12-03 21:38:07 America/New_York - add TEST_METHOD env var to limit tests run (thanks, Dagfinn Ilmari Mannsåker!) 0.016 2013-10-25 22:33:15 America/New_York update mxms.t to handle Test::Builder 0.99 replace use of Class::MOP::load_class with Class::Load 0.015 2012-03-16 16:37:21 America/New_York correct run_me to work with a single hashref argument 0.014 2011-09-11 08:47:21 America/New_York fix a nit in the SYNOPSIS: the runner is run_me not test_me (thanks, Alex White!) 0.013 2011-09-08 16:46:01 America/New_York MooseX::Method::Signatures is not a prereq, it's optionally used in some tests; the dist prereqs have been corrected to reflect this 0.012 2011-06-01 22:09:50 America/New_York reject test names that conflict with Moose::Object methods 0.011 2011-05-31 10:49:59 America/New_York install tests with package separators in their name under munged names (bug reported by Piers Cawley) 0.010 2011-04-07 23:06:32 America/New_York interoperate with MooseX::Method::Signatures (thanks, Jesse Luehrs) 0.009 2011-02-06 21:24:22 America/New_York eliminate the 5.12-only ... operator 0.008 2011-02-03 21:02:08 America/New_York eliminate a bogus prereq; sorry about that; thanks Glenn Fowler 0.007 2011-02-03 16:21:44 America/New_York We now forbid two tests with the same name. This may seem to be backwards incompatible, but the previous behavior was to silently replace each test in turn, so that tests written would simply not run. To allow safer routine composition, we have made duplicate names fatal, rather than adding arbitrary distinguishing suffixes. 0.006 2011-01-26 15:27:00 America/New_York correctly generate the Demo.pod (thanks, Yanick Champoux) 0.005 2010-12-19 21:53:36 America/New_York tiny but critical bug in synopsis (thanks, Piers Cawley) 0.004 2010-10-27 19:46:19 America/New_York correct a bug in test execution order 0.003 2010-10-18 23:02:32 America/New_York PLEASE UPDATE YOUR CODE: run_* now come from Test::Runner::Util 0.002 2010-09-30 09:26:43 America/New_York lower required perl to 5.8.x raise required Test::More to 0.96 0.001 2010-09-29 11:25:57 America/New_York first release Test-Routine-0.027/MANIFEST000644 000767 000024 00000001261 13340653227 015327 0ustar00rjbsstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.012. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Test/Routine.pm lib/Test/Routine/Common.pm lib/Test/Routine/Compositor.pm lib/Test/Routine/Manual/Demo.pm lib/Test/Routine/Runner.pm lib/Test/Routine/Test.pm lib/Test/Routine/Test/Role.pm lib/Test/Routine/Util.pm t/00-report-prereqs.dd t/00-report-prereqs.t t/abort.t t/demo/01-demo.t t/demo/02-simple.t t/demo/03-advice.t t/demo/04-misc.t t/demo/05-multiple.t t/dupe.t t/lib/NoGood.pm t/lib/NoGood2.pm t/method-filter.t t/mxms.t t/test-traits.t t/todo/mxrp.t t/unsafe-name.t xt/author/pod-syntax.t xt/release/changes_has_content.t Test-Routine-0.027/t/000755 000767 000024 00000000000 13340653227 014441 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/xt/000755 000767 000024 00000000000 13340653227 014631 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/README000644 000767 000024 00000000555 13340653227 015063 0ustar00rjbsstaff000000 000000 This archive contains the distribution Test-Routine, version 0.027: composable units of assertion This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v6.012. Test-Routine-0.027/META.yml000644 000767 000024 00000030214 13340653227 015447 0ustar00rjbsstaff000000 000000 --- abstract: 'composable units of assertion' author: - 'Ricardo Signes ' build_requires: ExtUtils::MakeMaker: '0' File::Spec: '0' Math::Trig: '0' Test::Builder::Tester: '0' Test::Fatal: '0' Test::Moose: '0' Test::More: '0.96' lib: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Test-Routine requires: Carp: '0' Class::Load: '0' Moose: '0' Moose::Exporter: '0' Moose::Meta::Class: '0' Moose::Meta::Method: '0' Moose::Role: '0' Moose::Util: '0' Moose::Util::TypeConstraints: '0' Params::Util: '0' Scalar::Util: '0' Sub::Exporter: '0' Sub::Exporter::Util: '0' Test2::API: '1.302045' Test::Abortable: '0.002' Test::More: '0.96' Try::Tiny: '0' namespace::autoclean: '0' namespace::clean: '0' strict: '0' warnings: '0' resources: bugtracker: https://github.com/rjbs/Test-Routine/issues homepage: https://github.com/rjbs/Test-Routine repository: https://github.com/rjbs/Test-Routine.git version: '0.027' x_Dist_Zilla: perl: version: '5.026001' plugins: - class: inc::BuildDemo name: =inc::BuildDemo version: ~ - class: Dist::Zilla::Plugin::Git::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . Dist::Zilla::Plugin::Git::GatherDir: include_untracked: 0 name: '@Filter/Git::GatherDir' version: '2.045' - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@Filter/CheckPrereqsIndexed' version: '0.020' - class: Dist::Zilla::Plugin::CheckExtraTests name: '@Filter/CheckExtraTests' version: '0.029' - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: 0 check_all_prereqs: 0 modules: - Dist::Zilla::PluginBundle::RJBS phase: build run_under_travis: 0 skip: [] name: '@Filter/RJBS-Outdated' version: '0.055' - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: 1 check_all_prereqs: 0 modules: [] phase: release run_under_travis: 0 skip: [] name: '@Filter/CPAN-Outdated' version: '0.055' - class: Dist::Zilla::Plugin::PruneCruft name: '@Filter/@Filter/PruneCruft' version: '6.012' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Filter/@Filter/ManifestSkip' version: '6.012' - class: Dist::Zilla::Plugin::MetaYAML name: '@Filter/@Filter/MetaYAML' version: '6.012' - class: Dist::Zilla::Plugin::License name: '@Filter/@Filter/License' version: '6.012' - class: Dist::Zilla::Plugin::Readme name: '@Filter/@Filter/Readme' version: '6.012' - class: Dist::Zilla::Plugin::ExecDir name: '@Filter/@Filter/ExecDir' version: '6.012' - class: Dist::Zilla::Plugin::ShareDir name: '@Filter/@Filter/ShareDir' version: '6.012' - class: Dist::Zilla::Plugin::Manifest name: '@Filter/@Filter/Manifest' version: '6.012' - class: Dist::Zilla::Plugin::TestRelease name: '@Filter/@Filter/TestRelease' version: '6.012' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Filter/@Filter/ConfirmRelease' version: '6.012' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Filter/@Filter/UploadToCPAN' version: '6.012' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 9 name: '@Filter/MakeMaker' version: '6.012' - class: Dist::Zilla::Plugin::Git::NextVersion config: Dist::Zilla::Plugin::Git::NextVersion: first_version: '0.001' version_by_branch: 1 version_regexp: (?^:^([0-9]+\.[0-9]+)$) Dist::Zilla::Role::Git::Repo: git_version: 2.18.0 repo_root: . name: '@Filter/Git::NextVersion' version: '2.045' - class: Dist::Zilla::Plugin::PkgVersion name: '@Filter/PkgVersion' version: '6.012' - class: Dist::Zilla::Plugin::MetaConfig name: '@Filter/MetaConfig' version: '6.012' - class: Dist::Zilla::Plugin::MetaJSON name: '@Filter/MetaJSON' version: '6.012' - class: Dist::Zilla::Plugin::NextRelease name: '@Filter/NextRelease' version: '6.012' - class: Dist::Zilla::Plugin::Test::ChangesHasContent name: '@Filter/Test::ChangesHasContent' version: '0.011' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Filter/PodSyntaxTests' version: '6.012' - class: Dist::Zilla::Plugin::Test::ReportPrereqs name: '@Filter/Test::ReportPrereqs' version: '0.027' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@Filter/TestMoreWithSubtests' version: '6.012' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: config_plugins: - '@RJBS' finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.015' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.015' - class: Pod::Weaver::Plugin::SingleEncoding name: '@RJBS/SingleEncoding' version: '4.015' - class: Pod::Weaver::Section::Name name: '@RJBS/Name' version: '4.015' - class: Pod::Weaver::Section::Version name: '@RJBS/Version' version: '4.015' - class: Pod::Weaver::Section::Region name: '@RJBS/Prelude' version: '4.015' - class: Pod::Weaver::Section::Generic name: '@RJBS/Synopsis' version: '4.015' - class: Pod::Weaver::Section::Generic name: '@RJBS/Description' version: '4.015' - class: Pod::Weaver::Section::Generic name: '@RJBS/Overview' version: '4.015' - class: Pod::Weaver::Section::Generic name: '@RJBS/Stability' version: '4.015' - class: Pod::Weaver::Section::Collect name: Attributes version: '4.015' - class: Pod::Weaver::Section::Collect name: Methods version: '4.015' - class: Pod::Weaver::Section::Collect name: Functions version: '4.015' - class: Pod::Weaver::Section::Leftovers name: '@RJBS/Leftovers' version: '4.015' - class: Pod::Weaver::Section::Region name: '@RJBS/postlude' version: '4.015' - class: Pod::Weaver::Section::Authors name: '@RJBS/Authors' version: '4.015' - class: Pod::Weaver::Section::Contributors name: '@RJBS/Contributors' version: '0.009' - class: Pod::Weaver::Section::Legal name: '@RJBS/Legal' version: '4.015' - class: Pod::Weaver::Plugin::Transformer name: '@RJBS/List' version: '4.015' name: '@Filter/PodWeaver' version: '4.009' - class: Dist::Zilla::Plugin::GithubMeta name: '@Filter/GithubMeta' version: '0.58' - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes - dist.ini allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.18.0 repo_root: . name: '@Filter/@Git/Check' version: '2.045' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: v%v%n%n%c Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes - dist.ini allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.18.0 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Filter/@Git/Commit' version: '2.045' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ changelog: Changes signed: 0 tag: '0.027' tag_format: '%v' tag_message: v%v Dist::Zilla::Role::Git::Repo: git_version: 2.18.0 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Filter/@Git/Tag' version: '2.045' - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - 'rjbs :' - 'github :' remotes_must_exist: 0 Dist::Zilla::Role::Git::Repo: git_version: 2.18.0 repo_root: . name: '@Filter/@Git/Push' version: '2.045' - class: Dist::Zilla::Plugin::Git::Contributors config: Dist::Zilla::Plugin::Git::Contributors: git_version: 2.18.0 include_authors: 0 include_releaser: 1 order_by: name paths: [] name: '@Filter/Git::Contributors' version: '0.034' - class: Dist::Zilla::Plugin::AutoPrereqs name: AutoPrereqs version: '6.012' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: '6.012' - class: Dist::Zilla::Plugin::PruneFiles name: PruneFiles version: '6.012' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.012' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.012' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.012' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.012' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.012' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.012' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.012' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.012' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.012' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.012' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.012' x_contributors: - 'Alex White ' - 'Dagfinn Ilmari Mannsåker ' - 'gregor herrmann ' - 'Jesse Luehrs ' - 'Yanick Champoux ' x_generated_by_perl: v5.26.1 x_serialization_backend: 'YAML::Tiny version 1.73' Test-Routine-0.027/lib/000755 000767 000024 00000000000 13340653227 014744 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/Makefile.PL000644 000767 000024 00000004506 13340653227 016155 0ustar00rjbsstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012. use strict; use warnings; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "composable units of assertion", "AUTHOR" => "Ricardo Signes ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Test-Routine", "LICENSE" => "perl", "NAME" => "Test::Routine", "PREREQ_PM" => { "Carp" => 0, "Class::Load" => 0, "Moose" => 0, "Moose::Exporter" => 0, "Moose::Meta::Class" => 0, "Moose::Meta::Method" => 0, "Moose::Role" => 0, "Moose::Util" => 0, "Moose::Util::TypeConstraints" => 0, "Params::Util" => 0, "Scalar::Util" => 0, "Sub::Exporter" => 0, "Sub::Exporter::Util" => 0, "Test2::API" => "1.302045", "Test::Abortable" => "0.002", "Test::More" => "0.96", "Try::Tiny" => 0, "namespace::autoclean" => 0, "namespace::clean" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "Math::Trig" => 0, "Test::Builder::Tester" => 0, "Test::Fatal" => 0, "Test::Moose" => 0, "Test::More" => "0.96", "lib" => 0 }, "VERSION" => "0.027", "test" => { "TESTS" => "t/*.t t/demo/*.t t/todo/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Class::Load" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "Math::Trig" => 0, "Moose" => 0, "Moose::Exporter" => 0, "Moose::Meta::Class" => 0, "Moose::Meta::Method" => 0, "Moose::Role" => 0, "Moose::Util" => 0, "Moose::Util::TypeConstraints" => 0, "Params::Util" => 0, "Scalar::Util" => 0, "Sub::Exporter" => 0, "Sub::Exporter::Util" => 0, "Test2::API" => "1.302045", "Test::Abortable" => "0.002", "Test::Builder::Tester" => 0, "Test::Fatal" => 0, "Test::Moose" => 0, "Test::More" => "0.96", "Try::Tiny" => 0, "lib" => 0, "namespace::autoclean" => 0, "namespace::clean" => 0, "strict" => 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-Routine-0.027/META.json000644 000767 000024 00000046201 13340653227 015622 0ustar00rjbsstaff000000 000000 { "abstract" : "composable units of assertion", "author" : [ "Ricardo Signes " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Test-Routine", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" }, "suggests" : { "JSON::PP" : "2.27300" } }, "develop" : { "requires" : { "Encode" : "0", "Test::More" : "0", "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "Carp" : "0", "Class::Load" : "0", "Moose" : "0", "Moose::Exporter" : "0", "Moose::Meta::Class" : "0", "Moose::Meta::Method" : "0", "Moose::Role" : "0", "Moose::Util" : "0", "Moose::Util::TypeConstraints" : "0", "Params::Util" : "0", "Scalar::Util" : "0", "Sub::Exporter" : "0", "Sub::Exporter::Util" : "0", "Test2::API" : "1.302045", "Test::Abortable" : "0.002", "Test::More" : "0.96", "Try::Tiny" : "0", "namespace::autoclean" : "0", "namespace::clean" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::Spec" : "0", "Math::Trig" : "0", "Test::Builder::Tester" : "0", "Test::Fatal" : "0", "Test::Moose" : "0", "Test::More" : "0.96", "lib" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/rjbs/Test-Routine/issues" }, "homepage" : "https://github.com/rjbs/Test-Routine", "repository" : { "type" : "git", "url" : "https://github.com/rjbs/Test-Routine.git", "web" : "https://github.com/rjbs/Test-Routine" } }, "version" : "0.027", "x_Dist_Zilla" : { "perl" : { "version" : "5.026001" }, "plugins" : [ { "class" : "inc::BuildDemo", "name" : "=inc::BuildDemo", "version" : null }, { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." }, "Dist::Zilla::Plugin::Git::GatherDir" : { "include_untracked" : 0 } }, "name" : "@Filter/Git::GatherDir", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@Filter/CheckPrereqsIndexed", "version" : "0.020" }, { "class" : "Dist::Zilla::Plugin::CheckExtraTests", "name" : "@Filter/CheckExtraTests", "version" : "0.029" }, { "class" : "Dist::Zilla::Plugin::PromptIfStale", "config" : { "Dist::Zilla::Plugin::PromptIfStale" : { "check_all_plugins" : 0, "check_all_prereqs" : 0, "modules" : [ "Dist::Zilla::PluginBundle::RJBS" ], "phase" : "build", "run_under_travis" : 0, "skip" : [] } }, "name" : "@Filter/RJBS-Outdated", "version" : "0.055" }, { "class" : "Dist::Zilla::Plugin::PromptIfStale", "config" : { "Dist::Zilla::Plugin::PromptIfStale" : { "check_all_plugins" : 1, "check_all_prereqs" : 0, "modules" : [], "phase" : "release", "run_under_travis" : 0, "skip" : [] } }, "name" : "@Filter/CPAN-Outdated", "version" : "0.055" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Filter/@Filter/PruneCruft", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Filter/@Filter/ManifestSkip", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Filter/@Filter/MetaYAML", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Filter/@Filter/License", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@Filter/@Filter/Readme", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Filter/@Filter/ExecDir", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Filter/@Filter/ShareDir", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Filter/@Filter/Manifest", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Filter/@Filter/TestRelease", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Filter/@Filter/ConfirmRelease", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Filter/@Filter/UploadToCPAN", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 9 } }, "name" : "@Filter/MakeMaker", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::Git::NextVersion", "config" : { "Dist::Zilla::Plugin::Git::NextVersion" : { "first_version" : "0.001", "version_by_branch" : 1, "version_regexp" : "(?^:^([0-9]+\\.[0-9]+)$)" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.18.0", "repo_root" : "." } }, "name" : "@Filter/Git::NextVersion", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@Filter/PkgVersion", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Filter/MetaConfig", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Filter/MetaJSON", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@Filter/NextRelease", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::Test::ChangesHasContent", "name" : "@Filter/Test::ChangesHasContent", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Filter/PodSyntaxTests", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::Test::ReportPrereqs", "name" : "@Filter/Test::ReportPrereqs", "version" : "0.027" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@Filter/TestMoreWithSubtests", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "config_plugins" : [ "@RJBS" ], "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@RJBS/SingleEncoding", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@RJBS/Name", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@RJBS/Version", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@RJBS/Prelude", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Synopsis", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Description", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Overview", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Stability", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Attributes", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Methods", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Functions", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@RJBS/Leftovers", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@RJBS/postlude", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@RJBS/Authors", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Contributors", "name" : "@RJBS/Contributors", "version" : "0.009" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@RJBS/Legal", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@RJBS/List", "version" : "4.015" } ] } }, "name" : "@Filter/PodWeaver", "version" : "4.009" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "@Filter/GithubMeta", "version" : "0.58" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "config" : { "Dist::Zilla::Plugin::Git::Check" : { "untracked_files" : "die" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes", "dist.ini" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.18.0", "repo_root" : "." } }, "name" : "@Filter/@Git/Check", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "v%v%n%n%c" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes", "dist.ini" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.18.0", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Filter/@Git/Commit", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "changelog" : "Changes", "signed" : 0, "tag" : "0.027", "tag_format" : "%v", "tag_message" : "v%v" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.18.0", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Filter/@Git/Tag", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "config" : { "Dist::Zilla::Plugin::Git::Push" : { "push_to" : [ "rjbs :", "github :" ], "remotes_must_exist" : 0 }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.18.0", "repo_root" : "." } }, "name" : "@Filter/@Git/Push", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::Git::Contributors", "config" : { "Dist::Zilla::Plugin::Git::Contributors" : { "git_version" : "2.18.0", "include_authors" : 0, "include_releaser" : 1, "order_by" : "name", "paths" : [] } }, "name" : "@Filter/Git::Contributors", "version" : "0.034" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "AutoPrereqs", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::PruneFiles", "name" : "PruneFiles", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.012" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.012" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.012" } }, "x_contributors" : [ "Alex White ", "Dagfinn Ilmari Manns\u00e5ker ", "gregor herrmann ", "Jesse Luehrs ", "Yanick Champoux " ], "x_generated_by_perl" : "v5.26.1", "x_serialization_backend" : "Cpanel::JSON::XS version 4.04" } Test-Routine-0.027/dist.ini000644 000767 000024 00000000717 13340653227 015647 0ustar00rjbsstaff000000 000000 name = Test-Routine author = Ricardo Signes license = Perl_5 copyright_holder = Ricardo Signes copyright_year = 2010 [=inc::BuildDemo] [@Filter] -bundle = @RJBS -remove = AutoPrereqs [AutoPrereqs] skip = HashTester skip = Test::ThingHasID skip = MooseX::Role::Parameterized skip = t::lib::NoGood skip = MooseX::Method::Signatures [Prereqs] Test::More = 0.96 ; subtest with implicit done_testing [PruneFiles] filename = inc/BuildDemo.pm Test-Routine-0.027/lib/Test/000755 000767 000024 00000000000 13340653227 015663 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/lib/Test/Routine/000755 000767 000024 00000000000 13340653227 017310 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/lib/Test/Routine.pm000644 000767 000024 00000043175 13340653227 017660 0ustar00rjbsstaff000000 000000 use strict; use warnings; package Test::Routine; # ABSTRACT: composable units of assertion $Test::Routine::VERSION = '0.027'; #pod =head1 SYNOPSIS #pod #pod # mytest.t #pod use Test::More; #pod use Test::Routine; #pod use Test::Routine::Util; #pod #pod has fixture => ( #pod is => 'ro', #pod lazy => 1, #pod clearer => 'reset_fixture', #pod default => sub { ...expensive setup... }, #pod ); #pod #pod test "we can use our fixture to do stuff" => sub { #pod my ($self) = @_; #pod #pod $self->reset_fixture; # this test requires a fresh one #pod #pod ok( $self->fixture->do_things, "do_things returns true"); #pod ok( ! $self->fixture->no_op, "no_op returns false"); #pod #pod for my $item ($self->fixture->contents) { #pod isa_ok($item, 'Fixture::Entry'); #pod } #pod }; #pod #pod test "fixture was recycled" => sub { #pod my ($self) = @_; #pod #pod my $fixture = $self->fixture; # we don't expect a fresh one #pod #pod is( $self->fixture->things_done, 1, "we have done one thing already"); #pod }; #pod #pod run_me; #pod done_testing; #pod #pod =head1 DESCRIPTION #pod #pod Test::Routine is a very simple framework for writing your tests as composable #pod units of assertion. In other words: roles. #pod #pod For a walkthrough of tests written with Test::Routine, see #pod L. #pod #pod Test::Routine is similar to L in some ways. These similarities #pod are largely superficial, but the idea of "tests bound together in reusable #pod units" is a useful one to understand when coming to Test::Routine. If you are #pod already familiar with Test::Class, it is the differences rather than the #pod similarities that will be more important to understand. If you are not #pod familiar with Test::Class, there is no need to understand it prior to using #pod Test::Routine. #pod #pod On the other hand, an understanding of the basics of L is absolutely #pod essential. Test::Routine composes tests from Moose classes, roles, and #pod attributes. Without an understanding of those, you will not be able to use #pod Test::Routine. The L is an excellent resource for learning #pod Moose, and has links to other online tutorials and documentation. #pod #pod =head2 The Concepts #pod #pod =head2 The Basics of Using Test::Routine #pod #pod There actually isn't much to Test::Routine I than the basics. It does #pod not provide many complex features, instead delegating almost everything to the #pod Moose object system. #pod #pod =head3 Writing Tests #pod #pod To write a set of tests (a test routine, which is a role), you add C to your package. C
is an acceptable target for turning #pod into a test routine, meaning that you may use Test::Routine in your F<*.t> #pod files in your distribution. #pod #pod C-ing Test::Routine will turn your package into a role that composes #pod L, and will give you the C declarator for adding #pod tests to your routine. Test::Routine::Common adds the C method that #pod will be called to run each test. #pod #pod The C declarator is very simple, and will generally be called like this: #pod #pod test $NAME_OF_TEST => sub { #pod my ($self) = @_; #pod #pod is($self->foo, 123, "we got the foo we expected"); #pod ... #pod ... #pod }; #pod #pod This defines a test with a given name, which will be invoked like a method on #pod the test object (described below). Tests are ordered by declaration within the #pod file, but when multiple test routines are run in a single test, the ordering of #pod the routines is B. #pod #pod C may also be given a different name for the installed method and the #pod test description. This isn't usually needed, but can make things clearer when #pod referring to tests as methods: #pod #pod test $NAME_OF_TEST_METHOD => { description => $TEST_DESCRIPTION } => sub { #pod ... #pod } #pod #pod Each test will be run by the C method. To add setup or teardown #pod behavior, advice (method modifiers) may be attached to that method. For #pod example, to call an attribute clearer before each test, you could add: #pod #pod before run_test => sub { #pod my ($self) = @_; #pod #pod $self->clear_some_attribute; #pod }; #pod #pod =head3 Running Tests #pod #pod To run tests, you will need to use L, which will provide #pod two functions for running tests: C and C. The former is #pod given a set of packages to compose and run as tests. The latter runs the #pod caller, assuming it to be a test routine. #pod #pod C can be called in several ways: #pod #pod run_tests( $desc, $object ); #pod #pod run_tests( $desc, \@packages, $arg ); #pod #pod run_tests( $desc, $package, $arg ); # equivalent to ($desc, [$pkg], $arg) #pod #pod In the first case, the object is assumed to be a fully formed, testable object. #pod In other words, you have already created a class that composes test routines #pod and have built an instance of it. #pod #pod In the other cases, C will produce an instance for you. It divides #pod the given packages into classes and roles. If more than one class was given, #pod an exception is thrown. A new class is created subclassing the given class and #pod applying the given roles. If no class was in the list, Moose::Object is used. #pod The new class's C is called with the given C<$arg> (if any). #pod #pod The composition mechanism makes it easy to run a test routine without first #pod writing a class to which to apply it. This is what makes it possible to write #pod your test routine in the C
package and run it directly from your F<*.t> #pod file. The following is a valid, trivial use of Test::Routine: #pod #pod use Test::More; #pod use Test::Routine; #pod use Test::Routine::Util; #pod #pod test demo_test => sub { pass("everything is okay") }; #pod #pod run_tests('our tests', 'main'); #pod done_testing; #pod #pod In this circumstance, though, you'd probably use C, which runs the #pod tests in the caller. You'd just replace the C line with #pod C<< run_me; >>. A description for the run may be supplied, if you like. #pod #pod Each call to C or C generates a new instance, and you can #pod call them as many times, with as many different arguments, as you like. Since #pod Test::Routine can't know how many times you'll call different test routines, #pod you are responsible for calling C> when #pod you're done testing. #pod #pod =head4 Running individual tests #pod #pod If you only want to run a subset of the tests, you can set the #pod C environment variable to a regular expression that matches #pod the names of the tests you want to run. #pod #pod For example, to run just the test named C in the #pod C class. #pod #pod use Test::More; #pod use Test::Routine::Util; #pod #pod $ENV{TEST_METHOD} = 'customer profile'; #pod run_tests('one test', 'MyTests'); #pod done_testing; #pod #pod To run all tests with C in the name: #pod #pod use Test::More; #pod use Test::Routine::Util; #pod #pod $ENV{TEST_METHOD}= '.*customer.*'; #pod run_tests('some tests', 'MyTests'); #pod done_testing; #pod #pod If you specify an invalid regular expression, your tests will not be #pod run: #pod #pod use Test::More; #pod use Test::Routine::Util #pod #pod $ENV{TEST_METHOD} = 'C++' #pod run_tests('invalid', 'MyTests'); #pod done_testing; #pod #pod When you run it: #pod #pod 1..0 #pod # No tests run! #pod not ok 1 - No tests run for subtest "invalid" #pod #pod =cut use Moose::Exporter; use Moose::Role (); use Moose::Util (); use Scalar::Util qw(blessed); use Test::Routine::Common; use Test::Routine::Test; Moose::Exporter->setup_import_methods( as_is => [ qw(test) ], also => 'Moose::Role', ); sub init_meta { my ($class, %arg) = @_; my $meta = Moose::Role->init_meta(%arg); my $role = $arg{for_class}; Moose::Util::apply_all_roles($role, 'Test::Routine::Common'); return $meta; } my $i = 0; sub test { my $caller = caller(); my $name = shift; my ($arg, $body); if (blessed($_[0]) && $_[0]->isa('Class::MOP::Method')) { $arg = {}; $body = shift; } else { $arg = Params::Util::_HASH0($_[0]) ? { %{shift()} } : {}; $body = shift; } # This could really have been done with a MooseX like InitArgs or Alias in # Test::Routine::Test, but since this is a test library, I'd actually like to # keep prerequisites fairly limited. -- rjbs, 2010-09-28 if (exists $arg->{desc}) { Carp::croak "can't supply both 'desc' and 'description'" if exists $arg->{description}; $arg->{description} = delete $arg->{desc}; } $arg->{description} = $name unless defined $arg->{description}; $name =~ s/(?:::|')/_/g; my $class = Moose::Meta::Class->initialize($caller); my %origin; @origin{qw(file line nth)} = ((caller(0))[1,2], $i++); my $method; if (blessed($body) && $body->isa('Class::MOP::Method')) { my $method_metaclass = Moose::Util::with_traits( blessed($body), 'Test::Routine::Test::Role', ($caller->can('test_routine_test_traits') ? $caller->test_routine_test_traits : ()), ); $method = $method_metaclass->meta->rebless_instance( $body, %$arg, name => $name, package_name => $caller, _origin => \%origin, ); } else { my $test_class = 'Test::Routine::Test'; if ($caller->can('test_routine_test_traits')) { my @traits = $caller->test_routine_test_traits; $test_class = Moose::Meta::Class->create_anon_class( superclasses => [ $test_class ], cache => 1, roles => \@traits, )->name; } $method = $test_class->wrap( %$arg, name => $name, body => $body, package_name => $caller, _origin => \%origin, ); } Carp::croak "can't have two tests with the same name ($name)" if $class->get_method($name); Carp::croak "there's already a subroutine named $name in $caller" if $caller->can($name); Carp::croak "can't name a test after a Moose::Object method ($name)" if Moose::Object->can($name); $class->add_method($name => $method); } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine - composable units of assertion =head1 VERSION version 0.027 =head1 SYNOPSIS # mytest.t use Test::More; use Test::Routine; use Test::Routine::Util; has fixture => ( is => 'ro', lazy => 1, clearer => 'reset_fixture', default => sub { ...expensive setup... }, ); test "we can use our fixture to do stuff" => sub { my ($self) = @_; $self->reset_fixture; # this test requires a fresh one ok( $self->fixture->do_things, "do_things returns true"); ok( ! $self->fixture->no_op, "no_op returns false"); for my $item ($self->fixture->contents) { isa_ok($item, 'Fixture::Entry'); } }; test "fixture was recycled" => sub { my ($self) = @_; my $fixture = $self->fixture; # we don't expect a fresh one is( $self->fixture->things_done, 1, "we have done one thing already"); }; run_me; done_testing; =head1 DESCRIPTION Test::Routine is a very simple framework for writing your tests as composable units of assertion. In other words: roles. For a walkthrough of tests written with Test::Routine, see L. Test::Routine is similar to L in some ways. These similarities are largely superficial, but the idea of "tests bound together in reusable units" is a useful one to understand when coming to Test::Routine. If you are already familiar with Test::Class, it is the differences rather than the similarities that will be more important to understand. If you are not familiar with Test::Class, there is no need to understand it prior to using Test::Routine. On the other hand, an understanding of the basics of L is absolutely essential. Test::Routine composes tests from Moose classes, roles, and attributes. Without an understanding of those, you will not be able to use Test::Routine. The L is an excellent resource for learning Moose, and has links to other online tutorials and documentation. =head2 The Concepts =head2 The Basics of Using Test::Routine There actually isn't much to Test::Routine I than the basics. It does not provide many complex features, instead delegating almost everything to the Moose object system. =head3 Writing Tests To write a set of tests (a test routine, which is a role), you add C to your package. C
is an acceptable target for turning into a test routine, meaning that you may use Test::Routine in your F<*.t> files in your distribution. C-ing Test::Routine will turn your package into a role that composes L, and will give you the C declarator for adding tests to your routine. Test::Routine::Common adds the C method that will be called to run each test. The C declarator is very simple, and will generally be called like this: test $NAME_OF_TEST => sub { my ($self) = @_; is($self->foo, 123, "we got the foo we expected"); ... ... }; This defines a test with a given name, which will be invoked like a method on the test object (described below). Tests are ordered by declaration within the file, but when multiple test routines are run in a single test, the ordering of the routines is B. C may also be given a different name for the installed method and the test description. This isn't usually needed, but can make things clearer when referring to tests as methods: test $NAME_OF_TEST_METHOD => { description => $TEST_DESCRIPTION } => sub { ... } Each test will be run by the C method. To add setup or teardown behavior, advice (method modifiers) may be attached to that method. For example, to call an attribute clearer before each test, you could add: before run_test => sub { my ($self) = @_; $self->clear_some_attribute; }; =head3 Running Tests To run tests, you will need to use L, which will provide two functions for running tests: C and C. The former is given a set of packages to compose and run as tests. The latter runs the caller, assuming it to be a test routine. C can be called in several ways: run_tests( $desc, $object ); run_tests( $desc, \@packages, $arg ); run_tests( $desc, $package, $arg ); # equivalent to ($desc, [$pkg], $arg) In the first case, the object is assumed to be a fully formed, testable object. In other words, you have already created a class that composes test routines and have built an instance of it. In the other cases, C will produce an instance for you. It divides the given packages into classes and roles. If more than one class was given, an exception is thrown. A new class is created subclassing the given class and applying the given roles. If no class was in the list, Moose::Object is used. The new class's C is called with the given C<$arg> (if any). The composition mechanism makes it easy to run a test routine without first writing a class to which to apply it. This is what makes it possible to write your test routine in the C
package and run it directly from your F<*.t> file. The following is a valid, trivial use of Test::Routine: use Test::More; use Test::Routine; use Test::Routine::Util; test demo_test => sub { pass("everything is okay") }; run_tests('our tests', 'main'); done_testing; In this circumstance, though, you'd probably use C, which runs the tests in the caller. You'd just replace the C line with C<< run_me; >>. A description for the run may be supplied, if you like. Each call to C or C generates a new instance, and you can call them as many times, with as many different arguments, as you like. Since Test::Routine can't know how many times you'll call different test routines, you are responsible for calling C> when you're done testing. =head4 Running individual tests If you only want to run a subset of the tests, you can set the C environment variable to a regular expression that matches the names of the tests you want to run. For example, to run just the test named C in the C class. use Test::More; use Test::Routine::Util; $ENV{TEST_METHOD} = 'customer profile'; run_tests('one test', 'MyTests'); done_testing; To run all tests with C in the name: use Test::More; use Test::Routine::Util; $ENV{TEST_METHOD}= '.*customer.*'; run_tests('some tests', 'MyTests'); done_testing; If you specify an invalid regular expression, your tests will not be run: use Test::More; use Test::Routine::Util $ENV{TEST_METHOD} = 'C++' run_tests('invalid', 'MyTests'); done_testing; When you run it: 1..0 # No tests run! not ok 1 - No tests run for subtest "invalid" =head1 AUTHOR Ricardo Signes =head1 CONTRIBUTORS =for stopwords Alex White Dagfinn Ilmari Mannsåker gregor herrmann Jesse Luehrs Yanick Champoux =over 4 =item * Alex White =item * Dagfinn Ilmari Mannsåker =item * gregor herrmann =item * Jesse Luehrs =item * Yanick Champoux =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Test-Routine-0.027/lib/Test/Routine/Runner.pm000644 000767 000024 00000007667 13340653227 021137 0ustar00rjbsstaff000000 000000 package Test::Routine::Runner; # ABSTRACT: tools for running Test::Routine tests $Test::Routine::Runner::VERSION = '0.027'; use Moose; #pod =head1 OVERVIEW #pod #pod A Test::Routine::Runner takes a callback for building test instances, then uses #pod it to build instances and run the tests on it. The Test::Routine::Runner #pod interface is still undergoing work, but the Test::Routine::Util exports for #pod running tests, described in L, are #pod more stable. Please use those instead, unless you are willing to deal with #pod interface breakage. #pod #pod =cut use Carp qw(confess croak); use Scalar::Util qw(reftype); use Test2::API 1.302045 (); use Try::Tiny; use Moose::Util::TypeConstraints; use namespace::clean; # XXX: THIS CODE BELOW WILL BE REMOVED VERY SOON -- rjbs, 2010-10-18 use Sub::Exporter -setup => { exports => [ run_tests => \'_curry_tester', run_me => \'_curry_tester', ], groups => [ default => [ qw(run_me run_tests) ] ], }; sub _curry_tester { my ($class, $name) = @_; use Test::Routine::Util; my $sub = Test::Routine::Util->_curry_tester($name); return sub { warn "you got $name from Test::Routine::Runner; use Test::Routine::Util instead; Test::Routine::Runner's exports will be removed soon\n"; goto &$sub; } } # XXX: THIS CODE ABOVE WILL BE REMOVED VERY SOON -- rjbs, 2010-10-18 subtype 'Test::Routine::_InstanceBuilder', as 'CodeRef'; subtype 'Test::Routine::_Instance', as 'Object', where { $_->does('Test::Routine::Common') }; coerce 'Test::Routine::_InstanceBuilder', from 'Test::Routine::_Instance', via { my $instance = $_; sub { $instance } }; has _instance_builder => ( is => 'ro', isa => 'Test::Routine::_InstanceBuilder', coerce => 1, traits => [ 'Code' ], init_arg => 'instance_from', required => 1, handles => { 'build_test_instance' => 'execute_method', }, ); has description => ( is => 'ro', isa => 'Str', required => 1, ); sub run { my ($self) = @_; my $test_instance = $self->build_test_instance; my @tests = grep { Moose::Util::does_role($_, 'Test::Routine::Test::Role') } $test_instance->meta->get_all_methods; my $re = $ENV{TEST_METHOD}; if (defined $re and length $re) { my $filter = try { qr/$re/ } # compile the the regex separately ... catch { croak("TEST_METHOD ($re) is not a valid regular expression: $_") }; $filter = qr/\A$filter\z/; # ... so it can't mess with the anchoring @tests = grep { $_->description =~ $filter } @tests; } # As a side note, I wonder whether there is any way to format the code below # to not look stupid. -- rjbs, 2010-09-28 my @ordered_tests = sort { $a->_origin->{file} cmp $b->_origin->{file} || $a->_origin->{nth} <=> $b->_origin->{nth} } @tests; Test2::API::run_subtest($self->description, sub { TEST: for my $test (@ordered_tests) { my $ctx = Test2::API::context; if (my $reason = $test->skip_reason($test_instance)) { $ctx->skip($test->name, $reason); } else { $test_instance->run_test( $test ); } $ctx->release; } }); } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Runner - tools for running Test::Routine tests =head1 VERSION version 0.027 =head1 OVERVIEW A Test::Routine::Runner takes a callback for building test instances, then uses it to build instances and run the tests on it. The Test::Routine::Runner interface is still undergoing work, but the Test::Routine::Util exports for running tests, described in L, are more stable. Please use those instead, unless you are willing to deal with interface breakage. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Test-Routine-0.027/lib/Test/Routine/Test/000755 000767 000024 00000000000 13340653227 020227 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/lib/Test/Routine/Util.pm000644 000767 000024 00000005430 13340653227 020565 0ustar00rjbsstaff000000 000000 use strict; use warnings; package Test::Routine::Util; # ABSTRACT: helpful exports for dealing with test routines $Test::Routine::Util::VERSION = '0.027'; #pod =head1 OVERVIEW #pod #pod Test::Routine::Util is documented in L. Please consult those for more information. #pod #pod Both C and C are simple wrappers around the process of #pod composing given Test::Routine roles into a class and instance using #pod L, creating a L object and #pod telling it to execute the tests on the test instance. #pod #pod =cut use Scalar::Util qw(reftype); use Sub::Exporter::Util qw(curry_method); use Test::Routine::Compositor; use Test::Routine::Runner (); use Sub::Exporter -setup => { exports => [ run_tests => \'_curry_tester', run_me => \'_curry_tester', ], groups => [ default => [ qw(run_me run_tests) ] ], }; our $UPLEVEL = 0; sub _curry_tester { my ($class, $name, $arg) = @_; Carp::confess("the $name generator does not accept any arguments") if keys %$arg; return sub { local $UPLEVEL = $UPLEVEL + 1; $class->$name(@_); }; } sub run_me { my ($class, $desc, $arg) = @_; if (@_ == 2 and (reftype $desc || '') eq 'HASH') { ($desc, $arg) = (undef, $desc); } my $caller = caller($UPLEVEL); local $UPLEVEL = $UPLEVEL + 1; $class->run_tests($desc, $caller, $arg); } sub _runner_class { 'Test::Routine::Runner' } sub _compositor_class { 'Test::Routine::Compositor' } sub run_tests { my ($class, $desc, $inv, $arg) = @_; my @caller = caller($UPLEVEL); $desc = defined($desc) ? $desc : sprintf 'tests from %s, line %s', $caller[1], $caller[2]; my $builder = $class->_compositor_class->instance_builder($inv, $arg); my $self = $class->_runner_class->new({ description => $desc, instance_from => $builder, }); $self->run; } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Util - helpful exports for dealing with test routines =head1 VERSION version 0.027 =head1 OVERVIEW Test::Routine::Util is documented in L. Please consult those for more information. Both C and C are simple wrappers around the process of composing given Test::Routine roles into a class and instance using L, creating a L object and telling it to execute the tests on the test instance. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Test-Routine-0.027/lib/Test/Routine/Test.pm000644 000767 000024 00000002104 13340653227 020562 0ustar00rjbsstaff000000 000000 package Test::Routine::Test; # ABSTRACT: a test method in a Test::Routine role $Test::Routine::Test::VERSION = '0.027'; use Moose; extends 'Moose::Meta::Method'; with 'Test::Routine::Test::Role'; #pod =head1 OVERVIEW #pod #pod Test::Routine::Test is a very simple subclass of L, used #pod primarily to identify which methods in a class are tests. It also has #pod attributes used for labeling and ordering test runs. #pod #pod =cut 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Test - a test method in a Test::Routine role =head1 VERSION version 0.027 =head1 OVERVIEW Test::Routine::Test is a very simple subclass of L, used primarily to identify which methods in a class are tests. It also has attributes used for labeling and ordering test runs. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Test-Routine-0.027/lib/Test/Routine/Common.pm000644 000767 000024 00000002503 13340653227 021076 0ustar00rjbsstaff000000 000000 package Test::Routine::Common; # ABSTRACT: a role composed by all Test::Routine roles $Test::Routine::Common::VERSION = '0.027'; use Moose::Role; #pod =head1 OVERVIEW #pod #pod Test::Routine::Common provides the C method described in L. #pod #pod =cut use Test::Abortable 0.002 (); use Test2::API 1.302045 (); use namespace::autoclean; sub BUILD { } sub DEMOLISH { } sub run_test { my ($self, $test) = @_; my $ctx = Test2::API::context(); my ($file, $line) = @{ $test->_origin }{ qw(file line) }; $ctx->trace->set_detail("at $file line $line"); my $name = $test->name; Test::Abortable::subtest($test->description, sub { $self->$name }); $ctx->release; } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Common - a role composed by all Test::Routine roles =head1 VERSION version 0.027 =head1 OVERVIEW Test::Routine::Common provides the C method described in L. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Test-Routine-0.027/lib/Test/Routine/Manual/000755 000767 000024 00000000000 13340653227 020525 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/lib/Test/Routine/Compositor.pm000644 000767 000024 00000004155 13340653227 022011 0ustar00rjbsstaff000000 000000 use strict; use warnings; package Test::Routine::Compositor; # ABSTRACT: the tool for turning test routines into runnable classes $Test::Routine::Compositor::VERSION = '0.027'; use Carp qw(confess); use Class::Load; use Moose::Meta::Class; use Params::Util qw(_CLASS); use Scalar::Util qw(blessed); use namespace::clean; sub _invocant_for { my ($self, $thing, $arg) = @_; confess "can't supply preconstructed object for running tests" if $arg and blessed $thing; return $thing if blessed $thing; $arg ||= {}; my $new_class = $self->_class_for($thing); $new_class->name->new($arg); } sub _class_for { my ($class, $inv) = @_; confess "can't supply preconstructed object for test class construction" if blessed $inv; $inv = [ $inv ] if _CLASS($inv); my @bases; my @roles; for my $item (@$inv) { Class::Load::load_class($item); my $target = $item->meta->isa('Moose::Meta::Class') ? \@bases : $item->meta->isa('Moose::Meta::Role') ? \@roles : confess "can't run tests for this weird thing: $item"; push @$target, $item; } confess "can't build a test class from multiple base classes" if @bases > 1; @bases = 'Moose::Object' unless @bases; my $new_class = Moose::Meta::Class->create_anon_class( superclasses => \@bases, cache => 1, (@roles ? (roles => \@roles) : ()), ); return $new_class->name; } sub instance_builder { my ($class, $inv, $arg) = @_; confess "can't supply preconstructed object and constructor arguments" if $arg and blessed $inv; return sub { $inv } if blessed $inv; my $new_class = $class->_class_for($inv); $arg ||= {}; return sub { $new_class->new($arg); }; } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Compositor - the tool for turning test routines into runnable classes =head1 VERSION version 0.027 =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Test-Routine-0.027/lib/Test/Routine/Manual/Demo.pm000644 000767 000024 00000100031 13340653227 021742 0ustar00rjbsstaff000000 000000 use strict; use warnings; package Test::Routine::Manual::Demo; # ABSTRACT: a walkthrough, in code, of Test::Routine $Test::Routine::Manual::Demo::VERSION = '0.027'; #pod =head1 The Demo #pod #pod =head2 t/demo/01-demo.t #pod #pod #!/bin/env perl #pod use strict; #pod use warnings; #pod #pod # This test is both a test and an example of how Test::Routine works! Welcome #pod # to t/01-demo.t, I will be your guide, rjbs. #pod #pod { #pod # This block defines the HashTester package. It's a Test::Routine, meaning #pod # it's a role. We define state that the test will need to keep and any #pod # requirements we might have. #pod # #pod # Before we can run this test, we'll need to compose the role into a class so #pod # that we can make an instance. #pod package HashTester; #pod use Test::Routine; #pod #pod # We import stuff from Test::More because, well, who wants to re-write all #pod # those really useful test routines that exist out there? Maybe somebody, #pod # but not me. #pod use Test::More; #pod #pod # ...but then we use namespace::autoclean to get rid of the routines once #pod # we've bound to them. This is just standard Moose practice, anyway, right? #pod use namespace::autoclean; #pod #pod # Finally, some state! Every test will get called as method on an instance, #pod # and it will have this attribute. Here are some points of interest: #pod # #pod # - We're giving this attribute a builder, so it will try to get built with a #pod # call to $self->build_hash_to_test -- so each class that composes this #pod # role can provide means for these attributes (fixtures) to be generated as #pod # needed. #pod # #pod # - We are not adding "requires 'build_hash_to_test'", because then we can #pod # apply this role to Moose::Object and instantiate it with a given value #pod # in the constructor. There will be an example of this below. This lets #pod # us re-use these tests in many variations without having to write class #pod # after class. #pod # #pod # - We don't use lazy_build because it would create a clearer. If someone #pod # then cleared our lazy_build fixture, it could not be re-built in the #pod # event that we'd gotten it explicitly from the constructor! #pod # #pod # Using Moose attributes for our state and fixtures allows us to get all of #pod # their powerful behaviors like types, delegation, traits, and so on, and #pod # allows us to decompose shared behavior into roles. #pod # #pod has hash_to_test => ( #pod is => 'ro', #pod isa => 'HashRef', #pod builder => 'build_hash_to_test', #pod ); #pod #pod # Here, we're just declaring an actual test that we will run. This sub will #pod # get installed as a method with a name that won't get clobbered easily. The #pod # method will be found later by run_tests so we can find and execute all #pod # tests on an instance. #pod # #pod # There is nothing magical about this method! Calling this method is #pod # performed in a Test::More subtest block. A TAP plan can be issued with #pod # "plan", and we can issue TODO or SKIP directives the same way. There is #pod # none of the return-to-skip magic that we find in Test::Class. #pod # #pod # The string after "test" is used as the method name -- which means we're #pod # getting a method name with spaces in it. This can be slightly problematic #pod # if you try to use, say, ::, in a method name. For the most part, it works #pod # quite well -- but look at the next test for an example of how to give an #pod # explicit description. #pod test "only one key in hash" => sub { #pod my ($self) = @_; #pod #pod my $hash = $self->hash_to_test; #pod #pod is(keys %$hash, 1, "we have one key in our test hash"); #pod is(2+2, 4, "universe still okay"); #pod }; #pod #pod # The only thing of note here is that we're passing a hashref of extra args #pod # to the test method constructor. "desc" lets us set the test's description, #pod # which is used in the test output, so we can avoid weird method names being #pod # installed. Also note that we order tests more or less by order of #pod # definition, not by name or description. #pod test second_test => { desc => "Test::Routine demo!" } => sub { #pod pass("We're running this test second"); #pod pass("...notice that the subtest's label is the 'desc' above"); #pod pass("...and not the method name!"); #pod }; #pod } #pod #pod { #pod # This package is one fixture against which we can run the HashTester #pod # routine. It has the only thing it needs: a build_hash_to_test method. #pod # Obviously real examples would have more to them than this. #pod package ProcessHash; #pod use Moose; #pod with 'HashTester'; #pod #pod use namespace::autoclean; #pod #pod sub build_hash_to_test { return { $$ => $^T } } #pod } #pod #pod # Now we're into the body of the test program: where tests actually get run. #pod #pod # We use Test::Routine::Util to get its "run_tests" routine, which runs the #pod # tests on an instance, building it if needed. #pod use Test::Routine::Util; #pod #pod # We use Test::More to get done_testing. We don't assume that run_tests is the #pod # entire test, because that way we can (as we do here) run multiple test #pod # instances, and can intersperse other kinds of sanity checks amongst the #pod # Test::Routine-style tests. #pod use Test::More; #pod #pod is(2+2, 4, "universe still makes sense") or BAIL_OUT("PANIC!"); #pod #pod # The first arg is a description for the subtest that will be run. The second, #pod # here, is a class that will be instantiated and tested. #pod run_tests('ProcessHash class' => 'ProcessHash'); #pod #pod # Here, the second argument is an instance of a class to test. #pod run_tests('ProcessHash obj' => ProcessHash->new({ hash_to_test => { 1 => 0 }})); #pod #pod # We could also just supply a class name and a set of args to pass to new. #pod # The below is very nearly equivalent to the above: #pod run_tests('ProcessHash new' => ProcessHash => { hash_to_test => { 1 => 0 }}); #pod #pod # ...and here, the second arg is not a class or instance at all, but the #pod # Test::Routine role (by name). Since we know we can't instantiate a role, #pod # run_tests will try to compose it with Moose::Object. Then the args are used #pod # as the args to ->new on the new class, as above. This lets us write #pod # Test::Routines that can be tested with the right state to start with, or #pod # Test::Routines that need to be composed with testing fixture classes. #pod run_tests( #pod 'HashTester with given state', #pod HashTester => { #pod hash_to_test => { a => 1 }, #pod }, #pod ); #pod #pod # There's one more interesting way to run out tests, but it's demonstrated in #pod # 02-simple.t instead of here. Go check that out. #pod #pod # ...and we're done! #pod done_testing; #pod #pod #pod =head2 t/demo/02-simple.t #pod #pod # Welcome to part two of the Test::Routine demo. This is showing how you can #pod # write quick one-off tests without having to write a bunch of .pm files or #pod # (worse?) embed packages in bare blocks in the odious way that 01-demo.t did. #pod # #pod # First off, we use Test::Routine. As it did before, this turns the current #pod # package (main!) into a Test::Routine role. It also has the pleasant #pod # side-effect of turning on strict and warnings. #pod use Test::Routine; #pod #pod # Then we bring in the utils, because we'll want to run_tests later. #pod use Test::Routine::Util; #pod #pod # And, finally, we bring in Test::More so that we can use test assertions, and #pod # namespace::autoclean to clean up after us. #pod use Test::More; #pod use namespace::autoclean; #pod #pod # We're going to give our tests some state. It's nothing special. #pod has counter => ( #pod is => 'rw', #pod isa => 'Int', #pod default => 0, #pod ); #pod #pod # Then another boring but useful hunk of code: a method for our test routine. #pod sub counter_is_even { #pod my ($self) = @_; #pod return $self->counter % 2 == 0; #pod } #pod #pod # Then we can write some tests, just like we did before. Here, we're writing #pod # several tests, and they will be run in the order in which they were defined. #pod # You can see that they rely on the state being maintained. #pod test 'start even' => sub { #pod my ($self) = @_; #pod ok($self->counter_is_even, "we start with an even counter"); #pod #pod $self->counter( $self->counter + 1); #pod }; #pod #pod test 'terminate odd' => sub { #pod my ($self) = @_; #pod #pod ok(! $self->counter_is_even, "the counter is odd, so state was preserved"); #pod pass("for your information, the counter is " . $self->counter); #pod }; #pod #pod # Now we can run these tests just by saying "run_me" -- rather than expecting a #pod # class or role name, it uses the caller. In this case, the calling package #pod # (main!) is a Test::Routine, so the runner composes it with Moose::Object, #pod # instantiating it, and running the tests on the instance. #pod run_me; #pod #pod # Since each test run gets its own instance, we can run the test suite again, #pod # possibly to verify that the test suite is not destructive of some external #pod # state. #pod run_me("second run"); #pod #pod # And we can pass in args to use when constructing the object to be tested. #pod # Given the tests above, we can pick any starting value for "counter" that is #pod # even. #pod run_me({ counter => 192 }); #pod #pod # ...and we're done! #pod done_testing; #pod #pod # More Test::Routine behavior is demonstrated in t/03-advice.t and t/04-misc.t #pod # Go have a look at those! #pod #pod #pod =head2 t/demo/03-advice.t #pod #pod use Test::Routine; #pod use Test::Routine::Util; #pod use Test::More; #pod #pod use namespace::autoclean; #pod #pod # xUnit style testing has the idea of setup and teardown that happens around #pod # each test. With Test::Routine, we assume that you will do most of this sort #pod # of thing in your BUILD, DEMOLISH, and attribute management. Still, you can #pod # easily do setup and teardown by applying method modifiers to the "run_test" #pod # method, which your Test::Routine uses to run each test. Here's a simple #pod # example. #pod #pod # We have the same boring state that we saw before. It's just an integer that #pod # is carried over between tests. #pod has counter => ( #pod is => 'rw', #pod isa => 'Int', #pod lazy => 1, #pod default => 0, #pod clearer => 'clear_counter', #pod ); #pod #pod # The first test changes the counter's value and leaves it changed. #pod test test_0 => sub { #pod my ($self) = @_; #pod #pod is($self->counter, 0, 'start with counter = 0'); #pod $self->counter( $self->counter + 1); #pod is($self->counter, 1, 'end with counter = 1'); #pod }; #pod #pod # The second test assumes that the value is the default, again. We want to #pod # make sure that before each test, the counter is reset, but we don't want to #pod # tear down and recreate the whole object, because it may have other, more #pod # expensive resources built. #pod test test_1 => sub { #pod my ($self) = @_; #pod #pod is($self->counter, 0, 'counter is reset between tests'); #pod }; #pod #pod # ...so we apply a "before" modifier to each test run, calling the clearer on #pod # the counter. When next accessed, it will re-initialize to zero. We could #pod # call any other code we want here, and we can compose numerous modifiers #pod # together onto run_test. #pod # #pod # If you want to clear *all* the object state between each test... you probably #pod # want to refactor. #pod before run_test => sub { $_[0]->clear_counter }; #pod #pod run_me; #pod done_testing; #pod #pod #pod =head2 t/demo/04-misc.t #pod #pod use Test::Routine; #pod use Test::Routine::Util; #pod use Test::More; #pod #pod use namespace::autoclean; #pod #pod # One thing that the previous examples didn't show was how to mark tests as #pod # "skipped" or "todo." Test::Routine makes -no- provisions for these #pod # directives. Instead, it assumes you will use the entirely usable mechanisms #pod # provided by Test::More. #pod #pod # This is a normal test. It is neither skipped nor todo. #pod test boring_ordinary_tests => sub { #pod pass("This is a plain old boring test that always passes."); #pod pass("It's here just to remind you what they look like."); #pod }; #pod #pod # To skip a test, we just add a "skip_all" plan. Because test methods get run #pod # in subtests, this skips the whole subtest, but nothing else. #pod test sample_skip_test => sub { #pod plan skip_all => "these tests don't pass, for some reason"; #pod #pod is(6, 9, "I don't mind."); #pod }; #pod #pod # To mark a test todo, we just set our local $TODO variable. Because the test #pod # is its own block, this works just like it would in any other Test::More test. #pod test sample_todo_test => sub { #pod local $TODO = 'demo of todo'; #pod #pod is(2 + 2, 5, "we can bend the fabric of reality"); #pod }; #pod #pod run_me; #pod done_testing; #pod #pod #pod =head2 t/demo/05-multiple.t #pod #pod #!/bin/env perl #pod use strict; #pod use warnings; #pod #pod use Test::Routine::Util; #pod use Test::More; #pod #pod # One of the benefits of building our sets of tests into roles instead of #pod # classes is that we can re-use them in whatever combination we want. We can #pod # break down sets of tests into bits that can be re-used in different cases. #pod # With classes, this would lead to multiple inheritance or other monstrosities. #pod #pod # Here's a first Test::Routine. We use it to make sure that one of our #pod # fixture's attributes is a numeric id. #pod { #pod package Test::ThingHasID; #pod use Test::Routine; #pod use Test::More; #pod #pod requires 'id'; #pod #pod test thing_has_numeric_id => sub { #pod my ($self) = @_; #pod #pod my $id = $self->id; #pod like($id, qr/\A[0-9]+\z/, "the thing's id is a string of ascii digits"); #pod }; #pod } #pod #pod # A second one ensures that the thing has an associated directory that #pod # looks like a unix path. #pod { #pod package Test::HasDirectory; #pod use Test::Routine; #pod use Test::More; #pod #pod requires 'dir'; #pod #pod test thing_has_unix_dir => sub { #pod my ($self) = @_; #pod #pod my $dir = $self->dir; #pod like($dir, qr{\A(?:/\w+)+/?\z}, "thing has a unix-like directory"); #pod }; #pod } #pod #pod # We might have one class that is only expected to pass one test: #pod { #pod package JustHasID; #pod use Moose; #pod #pod has id => ( #pod is => 'ro', #pod default => sub { #pod my ($self) = @_; #pod return Scalar::Util::refaddr($self); #pod }, #pod ); #pod } #pod #pod # ...and another class that should pass both: #pod { #pod package UnixUser; #pod use Moose; #pod #pod has id => (is => 'ro', default => 501); #pod has dir => (is => 'ro', default => '/home/users/rjbs'); #pod } #pod #pod # So far, none of this is new, it's just a slightly different way of factoring #pod # things we've seen before. In t/01-demo.t, we wrote distinct test roles and #pod # classes, and we made our class compose the role explicitly. This can be #pod # a useful way to put these pieces together, but we also might want to write #pod # all these classes and roles as unconnected components and compose them only #pod # when we're ready to run our tests. When we do that, we can tell run_tests #pod # what to put together. #pod # #pod # Here, we tell it that we can test JustHasID with Test::ThingHasID: #pod run_tests( #pod "our JustHasID objects have ids", #pod [ 'JustHasID', 'Test::ThingHasID' ], #pod ); #pod #pod # ...but we can run two test routines against our UnixUser class #pod run_tests( #pod "unix users have dirs and ids", #pod [ 'UnixUser', 'Test::ThingHasID', 'Test::HasDirectory' ], #pod ); #pod #pod #pod # We can still use the "attributes to initialize an object," and when doing #pod # that it may be that we don't care to run all the otherwise applicable tests, #pod # because they're not interesting in the scenario we're creating. For #pod # example... #pod run_tests( #pod "a trailing slash is okay in a directory", #pod [ 'UnixUser', 'Test::HasDirectory' ], #pod { dir => '/home/meebo/' }, #pod ); #pod #pod # ...and we're done! #pod done_testing; #pod #pod #pod #pod #pod =cut 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Manual::Demo - a walkthrough, in code, of Test::Routine =head1 VERSION version 0.027 =head1 The Demo =head2 t/demo/01-demo.t #!/bin/env perl use strict; use warnings; # This test is both a test and an example of how Test::Routine works! Welcome # to t/01-demo.t, I will be your guide, rjbs. { # This block defines the HashTester package. It's a Test::Routine, meaning # it's a role. We define state that the test will need to keep and any # requirements we might have. # # Before we can run this test, we'll need to compose the role into a class so # that we can make an instance. package HashTester; use Test::Routine; # We import stuff from Test::More because, well, who wants to re-write all # those really useful test routines that exist out there? Maybe somebody, # but not me. use Test::More; # ...but then we use namespace::autoclean to get rid of the routines once # we've bound to them. This is just standard Moose practice, anyway, right? use namespace::autoclean; # Finally, some state! Every test will get called as method on an instance, # and it will have this attribute. Here are some points of interest: # # - We're giving this attribute a builder, so it will try to get built with a # call to $self->build_hash_to_test -- so each class that composes this # role can provide means for these attributes (fixtures) to be generated as # needed. # # - We are not adding "requires 'build_hash_to_test'", because then we can # apply this role to Moose::Object and instantiate it with a given value # in the constructor. There will be an example of this below. This lets # us re-use these tests in many variations without having to write class # after class. # # - We don't use lazy_build because it would create a clearer. If someone # then cleared our lazy_build fixture, it could not be re-built in the # event that we'd gotten it explicitly from the constructor! # # Using Moose attributes for our state and fixtures allows us to get all of # their powerful behaviors like types, delegation, traits, and so on, and # allows us to decompose shared behavior into roles. # has hash_to_test => ( is => 'ro', isa => 'HashRef', builder => 'build_hash_to_test', ); # Here, we're just declaring an actual test that we will run. This sub will # get installed as a method with a name that won't get clobbered easily. The # method will be found later by run_tests so we can find and execute all # tests on an instance. # # There is nothing magical about this method! Calling this method is # performed in a Test::More subtest block. A TAP plan can be issued with # "plan", and we can issue TODO or SKIP directives the same way. There is # none of the return-to-skip magic that we find in Test::Class. # # The string after "test" is used as the method name -- which means we're # getting a method name with spaces in it. This can be slightly problematic # if you try to use, say, ::, in a method name. For the most part, it works # quite well -- but look at the next test for an example of how to give an # explicit description. test "only one key in hash" => sub { my ($self) = @_; my $hash = $self->hash_to_test; is(keys %$hash, 1, "we have one key in our test hash"); is(2+2, 4, "universe still okay"); }; # The only thing of note here is that we're passing a hashref of extra args # to the test method constructor. "desc" lets us set the test's description, # which is used in the test output, so we can avoid weird method names being # installed. Also note that we order tests more or less by order of # definition, not by name or description. test second_test => { desc => "Test::Routine demo!" } => sub { pass("We're running this test second"); pass("...notice that the subtest's label is the 'desc' above"); pass("...and not the method name!"); }; } { # This package is one fixture against which we can run the HashTester # routine. It has the only thing it needs: a build_hash_to_test method. # Obviously real examples would have more to them than this. package ProcessHash; use Moose; with 'HashTester'; use namespace::autoclean; sub build_hash_to_test { return { $$ => $^T } } } # Now we're into the body of the test program: where tests actually get run. # We use Test::Routine::Util to get its "run_tests" routine, which runs the # tests on an instance, building it if needed. use Test::Routine::Util; # We use Test::More to get done_testing. We don't assume that run_tests is the # entire test, because that way we can (as we do here) run multiple test # instances, and can intersperse other kinds of sanity checks amongst the # Test::Routine-style tests. use Test::More; is(2+2, 4, "universe still makes sense") or BAIL_OUT("PANIC!"); # The first arg is a description for the subtest that will be run. The second, # here, is a class that will be instantiated and tested. run_tests('ProcessHash class' => 'ProcessHash'); # Here, the second argument is an instance of a class to test. run_tests('ProcessHash obj' => ProcessHash->new({ hash_to_test => { 1 => 0 }})); # We could also just supply a class name and a set of args to pass to new. # The below is very nearly equivalent to the above: run_tests('ProcessHash new' => ProcessHash => { hash_to_test => { 1 => 0 }}); # ...and here, the second arg is not a class or instance at all, but the # Test::Routine role (by name). Since we know we can't instantiate a role, # run_tests will try to compose it with Moose::Object. Then the args are used # as the args to ->new on the new class, as above. This lets us write # Test::Routines that can be tested with the right state to start with, or # Test::Routines that need to be composed with testing fixture classes. run_tests( 'HashTester with given state', HashTester => { hash_to_test => { a => 1 }, }, ); # There's one more interesting way to run out tests, but it's demonstrated in # 02-simple.t instead of here. Go check that out. # ...and we're done! done_testing; =head2 t/demo/02-simple.t # Welcome to part two of the Test::Routine demo. This is showing how you can # write quick one-off tests without having to write a bunch of .pm files or # (worse?) embed packages in bare blocks in the odious way that 01-demo.t did. # # First off, we use Test::Routine. As it did before, this turns the current # package (main!) into a Test::Routine role. It also has the pleasant # side-effect of turning on strict and warnings. use Test::Routine; # Then we bring in the utils, because we'll want to run_tests later. use Test::Routine::Util; # And, finally, we bring in Test::More so that we can use test assertions, and # namespace::autoclean to clean up after us. use Test::More; use namespace::autoclean; # We're going to give our tests some state. It's nothing special. has counter => ( is => 'rw', isa => 'Int', default => 0, ); # Then another boring but useful hunk of code: a method for our test routine. sub counter_is_even { my ($self) = @_; return $self->counter % 2 == 0; } # Then we can write some tests, just like we did before. Here, we're writing # several tests, and they will be run in the order in which they were defined. # You can see that they rely on the state being maintained. test 'start even' => sub { my ($self) = @_; ok($self->counter_is_even, "we start with an even counter"); $self->counter( $self->counter + 1); }; test 'terminate odd' => sub { my ($self) = @_; ok(! $self->counter_is_even, "the counter is odd, so state was preserved"); pass("for your information, the counter is " . $self->counter); }; # Now we can run these tests just by saying "run_me" -- rather than expecting a # class or role name, it uses the caller. In this case, the calling package # (main!) is a Test::Routine, so the runner composes it with Moose::Object, # instantiating it, and running the tests on the instance. run_me; # Since each test run gets its own instance, we can run the test suite again, # possibly to verify that the test suite is not destructive of some external # state. run_me("second run"); # And we can pass in args to use when constructing the object to be tested. # Given the tests above, we can pick any starting value for "counter" that is # even. run_me({ counter => 192 }); # ...and we're done! done_testing; # More Test::Routine behavior is demonstrated in t/03-advice.t and t/04-misc.t # Go have a look at those! =head2 t/demo/03-advice.t use Test::Routine; use Test::Routine::Util; use Test::More; use namespace::autoclean; # xUnit style testing has the idea of setup and teardown that happens around # each test. With Test::Routine, we assume that you will do most of this sort # of thing in your BUILD, DEMOLISH, and attribute management. Still, you can # easily do setup and teardown by applying method modifiers to the "run_test" # method, which your Test::Routine uses to run each test. Here's a simple # example. # We have the same boring state that we saw before. It's just an integer that # is carried over between tests. has counter => ( is => 'rw', isa => 'Int', lazy => 1, default => 0, clearer => 'clear_counter', ); # The first test changes the counter's value and leaves it changed. test test_0 => sub { my ($self) = @_; is($self->counter, 0, 'start with counter = 0'); $self->counter( $self->counter + 1); is($self->counter, 1, 'end with counter = 1'); }; # The second test assumes that the value is the default, again. We want to # make sure that before each test, the counter is reset, but we don't want to # tear down and recreate the whole object, because it may have other, more # expensive resources built. test test_1 => sub { my ($self) = @_; is($self->counter, 0, 'counter is reset between tests'); }; # ...so we apply a "before" modifier to each test run, calling the clearer on # the counter. When next accessed, it will re-initialize to zero. We could # call any other code we want here, and we can compose numerous modifiers # together onto run_test. # # If you want to clear *all* the object state between each test... you probably # want to refactor. before run_test => sub { $_[0]->clear_counter }; run_me; done_testing; =head2 t/demo/04-misc.t use Test::Routine; use Test::Routine::Util; use Test::More; use namespace::autoclean; # One thing that the previous examples didn't show was how to mark tests as # "skipped" or "todo." Test::Routine makes -no- provisions for these # directives. Instead, it assumes you will use the entirely usable mechanisms # provided by Test::More. # This is a normal test. It is neither skipped nor todo. test boring_ordinary_tests => sub { pass("This is a plain old boring test that always passes."); pass("It's here just to remind you what they look like."); }; # To skip a test, we just add a "skip_all" plan. Because test methods get run # in subtests, this skips the whole subtest, but nothing else. test sample_skip_test => sub { plan skip_all => "these tests don't pass, for some reason"; is(6, 9, "I don't mind."); }; # To mark a test todo, we just set our local $TODO variable. Because the test # is its own block, this works just like it would in any other Test::More test. test sample_todo_test => sub { local $TODO = 'demo of todo'; is(2 + 2, 5, "we can bend the fabric of reality"); }; run_me; done_testing; =head2 t/demo/05-multiple.t #!/bin/env perl use strict; use warnings; use Test::Routine::Util; use Test::More; # One of the benefits of building our sets of tests into roles instead of # classes is that we can re-use them in whatever combination we want. We can # break down sets of tests into bits that can be re-used in different cases. # With classes, this would lead to multiple inheritance or other monstrosities. # Here's a first Test::Routine. We use it to make sure that one of our # fixture's attributes is a numeric id. { package Test::ThingHasID; use Test::Routine; use Test::More; requires 'id'; test thing_has_numeric_id => sub { my ($self) = @_; my $id = $self->id; like($id, qr/\A[0-9]+\z/, "the thing's id is a string of ascii digits"); }; } # A second one ensures that the thing has an associated directory that # looks like a unix path. { package Test::HasDirectory; use Test::Routine; use Test::More; requires 'dir'; test thing_has_unix_dir => sub { my ($self) = @_; my $dir = $self->dir; like($dir, qr{\A(?:/\w+)+/?\z}, "thing has a unix-like directory"); }; } # We might have one class that is only expected to pass one test: { package JustHasID; use Moose; has id => ( is => 'ro', default => sub { my ($self) = @_; return Scalar::Util::refaddr($self); }, ); } # ...and another class that should pass both: { package UnixUser; use Moose; has id => (is => 'ro', default => 501); has dir => (is => 'ro', default => '/home/users/rjbs'); } # So far, none of this is new, it's just a slightly different way of factoring # things we've seen before. In t/01-demo.t, we wrote distinct test roles and # classes, and we made our class compose the role explicitly. This can be # a useful way to put these pieces together, but we also might want to write # all these classes and roles as unconnected components and compose them only # when we're ready to run our tests. When we do that, we can tell run_tests # what to put together. # # Here, we tell it that we can test JustHasID with Test::ThingHasID: run_tests( "our JustHasID objects have ids", [ 'JustHasID', 'Test::ThingHasID' ], ); # ...but we can run two test routines against our UnixUser class run_tests( "unix users have dirs and ids", [ 'UnixUser', 'Test::ThingHasID', 'Test::HasDirectory' ], ); # We can still use the "attributes to initialize an object," and when doing # that it may be that we don't care to run all the otherwise applicable tests, # because they're not interesting in the scenario we're creating. For # example... run_tests( "a trailing slash is okay in a directory", [ 'UnixUser', 'Test::HasDirectory' ], { dir => '/home/meebo/' }, ); # ...and we're done! done_testing; =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Test-Routine-0.027/lib/Test/Routine/Test/Role.pm000644 000767 000024 00000001414 13340653227 021466 0ustar00rjbsstaff000000 000000 package Test::Routine::Test::Role; # ABSTRACT: role providing test attributes $Test::Routine::Test::Role::VERSION = '0.027'; use Moose::Role; has description => ( is => 'ro', isa => 'Str', lazy => 1, default => sub { $_[0]->name }, ); has _origin => ( is => 'ro', isa => 'HashRef', required => 1, ); sub skip_reason { return } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Test::Role - role providing test attributes =head1 VERSION version 0.027 =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Test-Routine-0.027/xt/author/000755 000767 000024 00000000000 13340653227 016133 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/xt/release/000755 000767 000024 00000000000 13340653227 016251 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/xt/release/changes_has_content.t000644 000767 000024 00000002101 13340653227 022425 0ustar00rjbsstaff000000 000000 use Test::More tests => 2; note 'Checking Changes'; my $changes_file = 'Changes'; my $newver = '0.027'; my $trial_token = '-TRIAL'; my $encoding = 'UTF-8'; SKIP: { ok(-e $changes_file, "$changes_file file exists") or skip 'Changes is missing', 1; ok(_get_changes($newver), "$changes_file has content for $newver"); } done_testing; sub _get_changes { my $newver = shift; # parse changelog to find commit message open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!"; my $changelog = join('', <$fh>); if ($encoding) { require Encode; $changelog = Encode::decode($encoding, $changelog, Encode::FB_CROAK()); } close $fh; my @content = grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented split /\n/, $changelog; shift @content; # drop the version line # drop unindented last line and trailing blank lines pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); # return number of non-blank lines return scalar @content; } Test-Routine-0.027/xt/author/pod-syntax.t000644 000767 000024 00000000252 13340653227 020425 0ustar00rjbsstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Test-Routine-0.027/t/demo/000755 000767 000024 00000000000 13340653227 015365 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/t/mxms.t000644 000767 000024 00000003421 13340653227 015612 0ustar00rjbsstaff000000 000000 #!perl use strict; use warnings; use Test::More; use Test::Moose; use Test::Fatal; use Test::Builder::Tester; BEGIN { eval { require MooseX::Method::Signatures; 1 } || plan skip_all => "This test requires MooseX::Method::Signatures"; } my $TBV = Test::Builder->VERSION; { package Test::Foo; use Test::Routine; use Test::Routine::Util; use MooseX::Method::Signatures; ::is(::exception { test 'foo bar' => method { ::does_ok($self, 'Test::Foo'); }; }, undef, "can create tests with methods"); if ($TBV >= 0.9805 && $TBV < 1.002) { ::test_out(" # tests work"); ::test_out(" # foo bar"); } elsif ($TBV > 1.002) { ::test_out("# tests work"); ::test_out(" # foo bar"); } ::test_out(" ok 1 - The object does Test::Foo"); ::test_out(" 1..1"); ::test_out(" ok 1 - foo bar"); ::test_out(" 1..1"); ::test_out("ok 1 - tests work"); run_me('tests work'); ::test_test(); } { package Test::Bar; use Test::Routine; use Test::Routine::Util; use MooseX::Method::Signatures; ::is(::exception { test 'foo bar' => { description => 'foobar' } => method { ::does_ok($self, 'Test::Bar'); }; }, undef, "can create tests with methods"); if ($TBV >= 0.9805 && $TBV < 1.002) { ::test_out(" # tests work"); ::test_out(" # foobar"); } elsif ($TBV > 1.002) { ::test_out("# tests work"); ::test_out(" # foobar"); } ::test_out(" ok 1 - The object does Test::Bar"); ::test_out(" 1..1"); ::test_out(" ok 1 - foobar"); ::test_out(" 1..1"); ::test_out("ok 1 - tests work"); run_me('tests work'); ::test_test(); } done_testing; Test-Routine-0.027/t/test-traits.t000644 000767 000024 00000002465 13340653227 017120 0ustar00rjbsstaff000000 000000 #!/bin/env perl use strict; use warnings; use lib 't/lib'; use Test::More; use Test::Routine; use Test::Routine::Util; use namespace::autoclean; { package Test::Routine::Role::TestWithFlavor; use Moose::Role; has flavor => ( is => 'ro', isa => 'Str', default => sub { 'vanilla' }, ); around skip_reason => sub { my ($orig, $self, $test_instance) = @_; return unless $test_instance->can('only_flavor'); return unless $test_instance->only_flavor; return if $test_instance->only_flavor eq $self->flavor; return sprintf "only running %s tests, but test is %s flavor", $test_instance->only_flavor, $self->flavor; return $self->$orig($test_instance); }; no Moose::Role; } { package Test::Routine::TestsHaveFlavor; use Moose::Role; sub test_routine_test_traits { return 'Test::Routine::Role::TestWithFlavor'; } no Moose::Role; } with 'Test::Routine::TestsHaveFlavor'; has only_flavor => ( is => 'ro', isa => 'Str', ); test "I like bananas" => sub { my ($self) = @_; ok(1); }; test "Do you like bananas" => sub { my ($self) = @_; ok(1); }; test "No, cucumbers are best" => { flavor => 'cuke' } => sub { my ($self) = @_; ok(1); }; run_me; run_me({ only_flavor => 'vanilla' }); run_me({ only_flavor => 'cuke' }); done_testing; Test-Routine-0.027/t/unsafe-name.t000644 000767 000024 00000000264 13340653227 017027 0ustar00rjbsstaff000000 000000 use Test::Routine; use Test::Routine::Util; use Test::More; test "this isn't any problem" => sub { pass }; test "we are testing My::Code" => sub { pass }; run_me; done_testing; Test-Routine-0.027/t/dupe.t000644 000767 000024 00000000641 13340653227 015564 0ustar00rjbsstaff000000 000000 use strict; use warnings; use Test::More; use Test::Fatal; use lib 't/lib'; { my $err = exception { require NoGood }; like( $err, qr/with the same name/, "having two tests with the same name is disallowed", ); } { my $err = exception { require NoGood2 }; like( $err, qr/there's already a subroutine named/, "a test/subroutine name mismatch is not allowed", ); } done_testing; Test-Routine-0.027/t/method-filter.t000644 000767 000024 00000002170 13340653227 017371 0ustar00rjbsstaff000000 000000 use Test::Routine; use Test::Routine::Util; use Test::More; use Test::Fatal; my %ran; my %expected = ( map { $_ => 1 } just => 1..3 ); foreach my $num (1..3) { test "this must run $num" => sub { pass "must $num"; $ran{$num}++ }; } test "just this" => sub { pass "just this"; $ran{just}++ }; subtest 'empty TEST_METHOD' => sub { local $ENV{TEST_METHOD} = ''; run_me 'empty TEST_METHOD'; is_deeply \%ran, \%expected, 'ran all tests'; }; subtest 'TEST_METHOD set' => sub { test "not to run" => sub { fail }; %ran = (); { local $ENV{TEST_METHOD} = 'just this'; run_me 'literal'; } { local $ENV{TEST_METHOD} = '.*must.*'; run_me 'regex'; } is_deeply \%ran, \%expected, "ran each test once"; }; { # the whole subtest must be TODO, or it fails with "no tests run" for # the subtest created by run_me() local $TODO = "Exception gets swallowed somewhere"; subtest 'invalid regex' => sub { local $ENV{TEST_METHOD} = 'invalid++'; like exception { run_me 'invalid' }, qr/\A\QTEST_METHOD (invalid++) is not a valid regular expression/, "invalid regex throws"; }; } done_testing; Test-Routine-0.027/t/todo/000755 000767 000024 00000000000 13340653227 015406 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/t/00-report-prereqs.t000644 000767 000024 00000013426 13340653227 020043 0ustar00rjbsstaff000000 000000 #!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.027 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do './t/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; my $cpan_meta_error; if ( $source && $HAS_CPAN_META && (my $meta = eval { CPAN::Meta->load_file($source) } ) ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } else { $cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source) $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( $cpan_meta_error || @dep_errors ) { diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n"; } if ( $cpan_meta_error ) { my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n"; } if ( @dep_errors ) { diag join("\n", "\nThe following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass; # vim: ts=4 sts=4 sw=4 et: Test-Routine-0.027/t/lib/000755 000767 000024 00000000000 13340653227 015207 5ustar00rjbsstaff000000 000000 Test-Routine-0.027/t/00-report-prereqs.dd000644 000767 000024 00000005400 13340653227 020160 0ustar00rjbsstaff000000 000000 do { my $x = { 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '0' }, 'suggests' => { 'JSON::PP' => '2.27300' } }, 'develop' => { 'requires' => { 'Encode' => '0', 'Test::More' => '0', 'Test::Pod' => '1.41' } }, 'runtime' => { 'requires' => { 'Carp' => '0', 'Class::Load' => '0', 'Moose' => '0', 'Moose::Exporter' => '0', 'Moose::Meta::Class' => '0', 'Moose::Meta::Method' => '0', 'Moose::Role' => '0', 'Moose::Util' => '0', 'Moose::Util::TypeConstraints' => '0', 'Params::Util' => '0', 'Scalar::Util' => '0', 'Sub::Exporter' => '0', 'Sub::Exporter::Util' => '0', 'Test2::API' => '1.302045', 'Test::Abortable' => '0.002', 'Test::More' => '0.96', 'Try::Tiny' => '0', 'namespace::autoclean' => '0', 'namespace::clean' => '0', 'strict' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'ExtUtils::MakeMaker' => '0', 'File::Spec' => '0', 'Math::Trig' => '0', 'Test::Builder::Tester' => '0', 'Test::Fatal' => '0', 'Test::Moose' => '0', 'Test::More' => '0.96', 'lib' => '0' } } }; $x; }Test-Routine-0.027/t/abort.t000644 000767 000024 00000005107 13340653227 015740 0ustar00rjbsstaff000000 000000 use strict; use warnings; use Test2::API qw(intercept); use Test::More; use Test::Routine::Util; { package Abort::Test; sub throw { my $self = bless $_[1], $_[0]; die $self; } sub as_test_abort_events { my @diag = @{ $_[0]{diagnostics} || [] }; return [ [ Ok => (pass => $_[0]{pass} || 0, name => $_[0]{description}) ], map {; [ Diag => (message => $_) ] } @diag, ]; } } { package Abortive; use Test::Routine; use Test::More; use namespace::autoclean; test "this test will abort" => sub { my ($self) = @_; pass("one"); pass("two"); Abort::Test->throw({ description => "just give up", }); pass("three"); pass("four"); pass("five"); }; test "this will run just fine" => sub { pass("everything is just fine"); }; test "I like fine wines and cheeses" => sub { pass("wine wine wine wine cheese"); Abort::Test->throw({ pass => 1, description => "that was enough wine and cheese", diagnostics => [ "Fine wine", "Fine cheese" ], }); fail("feeling gross"); }; } my $events = intercept { run_tests("test run with aborts", 'Abortive'); }; my @top = grep {; $_->isa('Test2::Event::Subtest') } @$events; is(@top, 1, "we have only the one top-level subtest for Routine"); my @subtests = grep {; $_->isa('Test2::Event::Subtest') } @{ $top[0]->subevents }; is(@subtests, 3, "we ran three subtests (the three test methods)"); subtest "first subtest" => sub { my @oks = grep {; $_->isa('Test2::Event::Ok') } @{ $subtests[0]->subevents }; is(@oks, 3, "three pass/fail events"); ok($oks[0]->pass, "first passed"); ok($oks[1]->pass, "second passed"); ok(! $oks[2]->pass, "third failed"); is($oks[2]->name, "just give up", "the final Ok test looks like our abort"); isa_ok($oks[2]->get_meta('test_abort_object'), 'Abort::Test', 'test_abort_object'); }; subtest "third subtest" => sub { my @oks = grep {; $_->isa('Test2::Event::Ok') } @{ $subtests[2]->subevents }; is(@oks, 2, "two pass/fail events"); ok($oks[0]->pass, "first passed"); ok($oks[1]->pass, "second passed"); is( $oks[1]->name, "that was enough wine and cheese", "the final Ok test looks like our abort" ); isa_ok($oks[1]->get_meta('test_abort_object'), 'Abort::Test', 'test_abort_object'); my @diags = grep {; $_->isa('Test2::Event::Diag') } @{ $subtests[2]->subevents }; is(@diags, 2, "we have two diagnostics"); is_deeply( [ map {; $_->message } @diags ], [ "Fine wine", "Fine cheese", ], "...which we expected", ); }; done_testing; Test-Routine-0.027/t/lib/NoGood.pm000644 000767 000024 00000000247 13340653227 016735 0ustar00rjbsstaff000000 000000 package NoGood; use Test::Routine; test "this will be duplicated" => sub { die 'Unimplemented' }; test "this will be duplicated" => sub { die 'Unimplemented' }; 1; Test-Routine-0.027/t/lib/NoGood2.pm000644 000767 000024 00000000135 13340653227 017013 0ustar00rjbsstaff000000 000000 package NoGood2; use Test::Routine; use Math::Trig qw(acos); test "acos" => sub { 1 }; 1; Test-Routine-0.027/t/todo/mxrp.t000644 000767 000024 00000001532 13340653227 016562 0ustar00rjbsstaff000000 000000 #!/bin/env perl use strict; use warnings; use Test::Routine::Util; use Test::More; BEGIN { plan skip_all => 'Test::Routine and MXRP not yet compatible'; } { package Test::ThingHasID; use MooseX::Role::Parameterized; use Test::Routine; use Test::More; parameter id_method => ( is => 'ro', isa => 'Str', default => 'id', ); role { my $p = shift; my $id_method = $p->id_method; requires $id_method; test thing_has_numeric_id => sub { my ($self) = @_; my $id = $self->$id_method; like($id, qr/\A[0-9]+\z/, "the thing's id is a string of ascii digits"); }; } } { package HasIdentifier; use Moose; with 'Test::ThingHasID' => { id_method => 'identifier' }; sub identifier { return 123 } } run_tests( "we can use mxrp", 'HasIdentifier', ); # ...and we're done! done_testing; Test-Routine-0.027/t/demo/01-demo.t000644 000767 000024 00000013603 13340653227 016717 0ustar00rjbsstaff000000 000000 #!/bin/env perl use strict; use warnings; # This test is both a test and an example of how Test::Routine works! Welcome # to t/01-demo.t, I will be your guide, rjbs. { # This block defines the HashTester package. It's a Test::Routine, meaning # it's a role. We define state that the test will need to keep and any # requirements we might have. # # Before we can run this test, we'll need to compose the role into a class so # that we can make an instance. package HashTester; use Test::Routine; # We import stuff from Test::More because, well, who wants to re-write all # those really useful test routines that exist out there? Maybe somebody, # but not me. use Test::More; # ...but then we use namespace::autoclean to get rid of the routines once # we've bound to them. This is just standard Moose practice, anyway, right? use namespace::autoclean; # Finally, some state! Every test will get called as method on an instance, # and it will have this attribute. Here are some points of interest: # # - We're giving this attribute a builder, so it will try to get built with a # call to $self->build_hash_to_test -- so each class that composes this # role can provide means for these attributes (fixtures) to be generated as # needed. # # - We are not adding "requires 'build_hash_to_test'", because then we can # apply this role to Moose::Object and instantiate it with a given value # in the constructor. There will be an example of this below. This lets # us re-use these tests in many variations without having to write class # after class. # # - We don't use lazy_build because it would create a clearer. If someone # then cleared our lazy_build fixture, it could not be re-built in the # event that we'd gotten it explicitly from the constructor! # # Using Moose attributes for our state and fixtures allows us to get all of # their powerful behaviors like types, delegation, traits, and so on, and # allows us to decompose shared behavior into roles. # has hash_to_test => ( is => 'ro', isa => 'HashRef', builder => 'build_hash_to_test', ); # Here, we're just declaring an actual test that we will run. This sub will # get installed as a method with a name that won't get clobbered easily. The # method will be found later by run_tests so we can find and execute all # tests on an instance. # # There is nothing magical about this method! Calling this method is # performed in a Test::More subtest block. A TAP plan can be issued with # "plan", and we can issue TODO or SKIP directives the same way. There is # none of the return-to-skip magic that we find in Test::Class. # # The string after "test" is used as the method name -- which means we're # getting a method name with spaces in it. This can be slightly problematic # if you try to use, say, ::, in a method name. For the most part, it works # quite well -- but look at the next test for an example of how to give an # explicit description. test "only one key in hash" => sub { my ($self) = @_; my $hash = $self->hash_to_test; is(keys %$hash, 1, "we have one key in our test hash"); is(2+2, 4, "universe still okay"); }; # The only thing of note here is that we're passing a hashref of extra args # to the test method constructor. "desc" lets us set the test's description, # which is used in the test output, so we can avoid weird method names being # installed. Also note that we order tests more or less by order of # definition, not by name or description. test second_test => { desc => "Test::Routine demo!" } => sub { pass("We're running this test second"); pass("...notice that the subtest's label is the 'desc' above"); pass("...and not the method name!"); }; } { # This package is one fixture against which we can run the HashTester # routine. It has the only thing it needs: a build_hash_to_test method. # Obviously real examples would have more to them than this. package ProcessHash; use Moose; with 'HashTester'; use namespace::autoclean; sub build_hash_to_test { return { $$ => $^T } } } # Now we're into the body of the test program: where tests actually get run. # We use Test::Routine::Util to get its "run_tests" routine, which runs the # tests on an instance, building it if needed. use Test::Routine::Util; # We use Test::More to get done_testing. We don't assume that run_tests is the # entire test, because that way we can (as we do here) run multiple test # instances, and can intersperse other kinds of sanity checks amongst the # Test::Routine-style tests. use Test::More; is(2+2, 4, "universe still makes sense") or BAIL_OUT("PANIC!"); # The first arg is a description for the subtest that will be run. The second, # here, is a class that will be instantiated and tested. run_tests('ProcessHash class' => 'ProcessHash'); # Here, the second argument is an instance of a class to test. run_tests('ProcessHash obj' => ProcessHash->new({ hash_to_test => { 1 => 0 }})); # We could also just supply a class name and a set of args to pass to new. # The below is very nearly equivalent to the above: run_tests('ProcessHash new' => ProcessHash => { hash_to_test => { 1 => 0 }}); # ...and here, the second arg is not a class or instance at all, but the # Test::Routine role (by name). Since we know we can't instantiate a role, # run_tests will try to compose it with Moose::Object. Then the args are used # as the args to ->new on the new class, as above. This lets us write # Test::Routines that can be tested with the right state to start with, or # Test::Routines that need to be composed with testing fixture classes. run_tests( 'HashTester with given state', HashTester => { hash_to_test => { a => 1 }, }, ); # There's one more interesting way to run out tests, but it's demonstrated in # 02-simple.t instead of here. Go check that out. # ...and we're done! done_testing; Test-Routine-0.027/t/demo/05-multiple.t000644 000767 000024 00000005317 13340653227 017635 0ustar00rjbsstaff000000 000000 #!/bin/env perl use strict; use warnings; use Test::Routine::Util; use Test::More; # One of the benefits of building our sets of tests into roles instead of # classes is that we can re-use them in whatever combination we want. We can # break down sets of tests into bits that can be re-used in different cases. # With classes, this would lead to multiple inheritance or other monstrosities. # Here's a first Test::Routine. We use it to make sure that one of our # fixture's attributes is a numeric id. { package Test::ThingHasID; use Test::Routine; use Test::More; requires 'id'; test thing_has_numeric_id => sub { my ($self) = @_; my $id = $self->id; like($id, qr/\A[0-9]+\z/, "the thing's id is a string of ascii digits"); }; } # A second one ensures that the thing has an associated directory that # looks like a unix path. { package Test::HasDirectory; use Test::Routine; use Test::More; requires 'dir'; test thing_has_unix_dir => sub { my ($self) = @_; my $dir = $self->dir; like($dir, qr{\A(?:/\w+)+/?\z}, "thing has a unix-like directory"); }; } # We might have one class that is only expected to pass one test: { package JustHasID; use Moose; has id => ( is => 'ro', default => sub { my ($self) = @_; return Scalar::Util::refaddr($self); }, ); } # ...and another class that should pass both: { package UnixUser; use Moose; has id => (is => 'ro', default => 501); has dir => (is => 'ro', default => '/home/users/rjbs'); } # So far, none of this is new, it's just a slightly different way of factoring # things we've seen before. In t/01-demo.t, we wrote distinct test roles and # classes, and we made our class compose the role explicitly. This can be # a useful way to put these pieces together, but we also might want to write # all these classes and roles as unconnected components and compose them only # when we're ready to run our tests. When we do that, we can tell run_tests # what to put together. # # Here, we tell it that we can test JustHasID with Test::ThingHasID: run_tests( "our JustHasID objects have ids", [ 'JustHasID', 'Test::ThingHasID' ], ); # ...but we can run two test routines against our UnixUser class run_tests( "unix users have dirs and ids", [ 'UnixUser', 'Test::ThingHasID', 'Test::HasDirectory' ], ); # We can still use the "attributes to initialize an object," and when doing # that it may be that we don't care to run all the otherwise applicable tests, # because they're not interesting in the scenario we're creating. For # example... run_tests( "a trailing slash is okay in a directory", [ 'UnixUser', 'Test::HasDirectory' ], { dir => '/home/meebo/' }, ); # ...and we're done! done_testing; Test-Routine-0.027/t/demo/03-advice.t000644 000767 000024 00000003333 13340653227 017227 0ustar00rjbsstaff000000 000000 use Test::Routine; use Test::Routine::Util; use Test::More; use namespace::autoclean; # xUnit style testing has the idea of setup and teardown that happens around # each test. With Test::Routine, we assume that you will do most of this sort # of thing in your BUILD, DEMOLISH, and attribute management. Still, you can # easily do setup and teardown by applying method modifiers to the "run_test" # method, which your Test::Routine uses to run each test. Here's a simple # example. # We have the same boring state that we saw before. It's just an integer that # is carried over between tests. has counter => ( is => 'rw', isa => 'Int', lazy => 1, default => 0, clearer => 'clear_counter', ); # The first test changes the counter's value and leaves it changed. test test_0 => sub { my ($self) = @_; is($self->counter, 0, 'start with counter = 0'); $self->counter( $self->counter + 1); is($self->counter, 1, 'end with counter = 1'); }; # The second test assumes that the value is the default, again. We want to # make sure that before each test, the counter is reset, but we don't want to # tear down and recreate the whole object, because it may have other, more # expensive resources built. test test_1 => sub { my ($self) = @_; is($self->counter, 0, 'counter is reset between tests'); }; # ...so we apply a "before" modifier to each test run, calling the clearer on # the counter. When next accessed, it will re-initialize to zero. We could # call any other code we want here, and we can compose numerous modifiers # together onto run_test. # # If you want to clear *all* the object state between each test... you probably # want to refactor. before run_test => sub { $_[0]->clear_counter }; run_me; done_testing; Test-Routine-0.027/t/demo/02-simple.t000644 000767 000024 00000004532 13340653227 017266 0ustar00rjbsstaff000000 000000 # Welcome to part two of the Test::Routine demo. This is showing how you can # write quick one-off tests without having to write a bunch of .pm files or # (worse?) embed packages in bare blocks in the odious way that 01-demo.t did. # # First off, we use Test::Routine. As it did before, this turns the current # package (main!) into a Test::Routine role. It also has the pleasant # side-effect of turning on strict and warnings. use Test::Routine; # Then we bring in the utils, because we'll want to run_tests later. use Test::Routine::Util; # And, finally, we bring in Test::More so that we can use test assertions, and # namespace::autoclean to clean up after us. use Test::More; use namespace::autoclean; # We're going to give our tests some state. It's nothing special. has counter => ( is => 'rw', isa => 'Int', default => 0, ); # Then another boring but useful hunk of code: a method for our test routine. sub counter_is_even { my ($self) = @_; return $self->counter % 2 == 0; } # Then we can write some tests, just like we did before. Here, we're writing # several tests, and they will be run in the order in which they were defined. # You can see that they rely on the state being maintained. test 'start even' => sub { my ($self) = @_; ok($self->counter_is_even, "we start with an even counter"); $self->counter( $self->counter + 1); }; test 'terminate odd' => sub { my ($self) = @_; ok(! $self->counter_is_even, "the counter is odd, so state was preserved"); pass("for your information, the counter is " . $self->counter); }; # Now we can run these tests just by saying "run_me" -- rather than expecting a # class or role name, it uses the caller. In this case, the calling package # (main!) is a Test::Routine, so the runner composes it with Moose::Object, # instantiating it, and running the tests on the instance. run_me; # Since each test run gets its own instance, we can run the test suite again, # possibly to verify that the test suite is not destructive of some external # state. run_me("second run"); # And we can pass in args to use when constructing the object to be tested. # Given the tests above, we can pick any starting value for "counter" that is # even. run_me({ counter => 192 }); # ...and we're done! done_testing; # More Test::Routine behavior is demonstrated in t/03-advice.t and t/04-misc.t # Go have a look at those! Test-Routine-0.027/t/demo/04-misc.t000644 000767 000024 00000002155 13340653227 016731 0ustar00rjbsstaff000000 000000 use Test::Routine; use Test::Routine::Util; use Test::More; use namespace::autoclean; # One thing that the previous examples didn't show was how to mark tests as # "skipped" or "todo." Test::Routine makes -no- provisions for these # directives. Instead, it assumes you will use the entirely usable mechanisms # provided by Test::More. # This is a normal test. It is neither skipped nor todo. test boring_ordinary_tests => sub { pass("This is a plain old boring test that always passes."); pass("It's here just to remind you what they look like."); }; # To skip a test, we just add a "skip_all" plan. Because test methods get run # in subtests, this skips the whole subtest, but nothing else. test sample_skip_test => sub { plan skip_all => "these tests don't pass, for some reason"; is(6, 9, "I don't mind."); }; # To mark a test todo, we just set our local $TODO variable. Because the test # is its own block, this works just like it would in any other Test::More test. test sample_todo_test => sub { local $TODO = 'demo of todo'; is(2 + 2, 5, "we can bend the fabric of reality"); }; run_me; done_testing;