Test-Routine-0.018000755000766000024 012264313723 13314 5ustar00rjbsstaff000000000000README100644000766000024 56012264313723 14236 0ustar00rjbsstaff000000000000Test-Routine-0.018 This archive contains the distribution Test-Routine, version 0.018: 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 v5.010. Changes100644000766000024 514212264313723 14672 0ustar00rjbsstaff000000000000Test-Routine-0.018Revision history for Test-Routine 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 LICENSE100644000766000024 4366112264313723 14434 0ustar00rjbsstaff000000000000Test-Routine-0.018This 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, Suite 500, Boston, MA 02110-1335 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 dist.ini100644000766000024 71612264313723 15025 0ustar00rjbsstaff000000000000Test-Routine-0.018name = Test-Routine author = Ricardo Signes license = Perl_5 copyright_holder = Ricardo Signes copyright_year = 2010 [@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 [=inc::BuildDemo] [PruneFiles] filename = inc/BuildDemo.pm t000755000766000024 012264313723 13500 5ustar00rjbsstaff000000000000Test-Routine-0.018dupe.t100644000766000024 33612264313723 14744 0ustar00rjbsstaff000000000000Test-Routine-0.018/tuse strict; use warnings; use Test::More; use Test::Fatal; my $err = exception { require t::lib::NoGood }; like( $err, qr/with the same name/, "having two tests with the same name is disallowed", ); done_testing; mxms.t100644000766000024 314112264313723 15010 0ustar00rjbsstaff000000000000Test-Routine-0.018/t#!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"; } { 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 (eval { Test::Builder->VERSION(0.9805) }) { ::test_out(" # Subtest: tests work"); ::test_out(" # Subtest: 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 (eval { Test::Builder->VERSION(0.9805) }) { ::test_out(" # Subtest: tests work"); ::test_out(" # Subtest: 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; META.yml100644000766000024 2150112264313723 14665 0ustar00rjbsstaff000000000000Test-Routine-0.018--- abstract: 'composable units of assertion' author: - 'Ricardo Signes ' build_requires: Test::Builder::Tester: 0 Test::Fatal: 0 Test::Moose: 0 Test::More: 0.96 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 5.010, CPAN::Meta::Converter version 2.133380' 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 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.018 x_Dist_Zilla: perl: version: 5.018002 plugins: - class: Dist::Zilla::Plugin::Git::GatherDir name: '@Filter/Git::GatherDir' version: 2.019 - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@Filter/CheckPrereqsIndexed' version: 0.010 - class: Dist::Zilla::Plugin::CheckExtraTests name: '@Filter/CheckExtraTests' version: 0.016 - 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 skip: [] name: '@Filter/RJBS-Outdated' version: 0.015 - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: 1 check_all_prereqs: 0 modules: [] phase: release skip: [] name: '@Filter/CPAN-Outdated' version: 0.015 - class: Dist::Zilla::Plugin::PruneCruft name: '@Filter/@Filter/PruneCruft' version: 5.010 - class: Dist::Zilla::Plugin::ManifestSkip name: '@Filter/@Filter/ManifestSkip' version: 5.010 - class: Dist::Zilla::Plugin::MetaYAML name: '@Filter/@Filter/MetaYAML' version: 5.010 - class: Dist::Zilla::Plugin::License name: '@Filter/@Filter/License' version: 5.010 - class: Dist::Zilla::Plugin::Readme name: '@Filter/@Filter/Readme' version: 5.010 - class: Dist::Zilla::Plugin::ExecDir name: '@Filter/@Filter/ExecDir' version: 5.010 - class: Dist::Zilla::Plugin::ShareDir name: '@Filter/@Filter/ShareDir' version: 5.010 - class: Dist::Zilla::Plugin::MakeMaker name: '@Filter/@Filter/MakeMaker' version: 5.010 - class: Dist::Zilla::Plugin::Manifest name: '@Filter/@Filter/Manifest' version: 5.010 - class: Dist::Zilla::Plugin::TestRelease name: '@Filter/@Filter/TestRelease' version: 5.010 - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Filter/@Filter/ConfirmRelease' version: 5.010 - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Filter/@Filter/UploadToCPAN' version: 5.010 - class: Dist::Zilla::Plugin::Git::NextVersion name: '@Filter/Git::NextVersion' version: 2.019 - class: Dist::Zilla::Plugin::PkgVersion name: '@Filter/PkgVersion' version: 5.010 - class: Dist::Zilla::Plugin::MetaConfig name: '@Filter/MetaConfig' version: 5.010 - class: Dist::Zilla::Plugin::MetaJSON name: '@Filter/MetaJSON' version: 5.010 - class: Dist::Zilla::Plugin::NextRelease name: '@Filter/NextRelease' version: 5.010 - class: Dist::Zilla::Plugin::Test::ChangesHasContent name: '@Filter/Test::ChangesHasContent' version: 0.006 - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Filter/PodSyntaxTests' version: 5.010 - class: Dist::Zilla::Plugin::ReportVersions::Tiny name: '@Filter/ReportVersions::Tiny' version: 1.10 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@Filter/TestMoreWithSubtests' version: 5.010 - 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.006 - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: 4.006 - class: Pod::Weaver::Plugin::SingleEncoding name: '@RJBS/SingleEncoding' version: 4.006 - class: Pod::Weaver::Section::Name name: '@RJBS/Name' version: 4.006 - class: Pod::Weaver::Section::Version name: '@RJBS/Version' version: 4.006 - class: Pod::Weaver::Section::Region name: '@RJBS/Prelude' version: 4.006 - class: Pod::Weaver::Section::Generic name: '@RJBS/Synopsis' version: 4.006 - class: Pod::Weaver::Section::Generic name: '@RJBS/Description' version: 4.006 - class: Pod::Weaver::Section::Generic name: '@RJBS/Overview' version: 4.006 - class: Pod::Weaver::Section::Generic name: '@RJBS/Stability' version: 4.006 - class: Pod::Weaver::Section::Collect name: Attributes version: 4.006 - class: Pod::Weaver::Section::Collect name: Methods version: 4.006 - class: Pod::Weaver::Section::Collect name: Functions version: 4.006 - class: Pod::Weaver::Section::Leftovers name: '@RJBS/Leftovers' version: 4.006 - class: Pod::Weaver::Section::Region name: '@RJBS/postlude' version: 4.006 - class: Pod::Weaver::Section::Authors name: '@RJBS/Authors' version: 4.006 - class: Pod::Weaver::Section::Legal name: '@RJBS/Legal' version: 4.006 - class: Pod::Weaver::Plugin::Transformer name: '@RJBS/List' version: 4.006 name: '@Filter/PodWeaver' version: 4.005 - class: Dist::Zilla::Plugin::GithubMeta name: '@Filter/GithubMeta' version: 0.42 - class: Dist::Zilla::Plugin::Git::Check name: '@Filter/@Git/Check' version: 2.019 - class: Dist::Zilla::Plugin::Git::Commit name: '@Filter/@Git/Commit' version: 2.019 - class: Dist::Zilla::Plugin::Git::Tag name: '@Filter/@Git/Tag' version: 2.019 - class: Dist::Zilla::Plugin::Git::Push name: '@Filter/@Git/Push' version: 2.019 - class: Dist::Zilla::Plugin::AutoPrereqs name: AutoPrereqs version: 5.010 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: 5.010 - class: inc::BuildDemo name: '=inc::BuildDemo' version: ~ - class: Dist::Zilla::Plugin::PruneFiles name: PruneFiles version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: 5.010 - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: 5.010 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: 5.010 MANIFEST100644000766000024 116712264313723 14533 0ustar00rjbsstaff000000000000Test-Routine-0.018# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.010. 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/000-report-versions-tiny.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/method-filter.t t/mxms.t t/todo/mxrp.t t/unsafe-name.t xt/release/changes_has_content.t xt/release/pod-syntax.t META.json100644000766000024 3404212264313723 15041 0ustar00rjbsstaff000000000000Test-Routine-0.018{ "abstract" : "composable units of assertion", "author" : [ "Ricardo Signes " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.010, CPAN::Meta::Converter version 2.133380", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Test-Routine", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Test::Pod" : "1.41", "version" : "0.9901" } }, "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", "Test::More" : "0.96", "Try::Tiny" : "0", "namespace::autoclean" : "0", "namespace::clean" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Test::Builder::Tester" : "0", "Test::Fatal" : "0", "Test::Moose" : "0", "Test::More" : "0.96" } } }, "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.018", "x_Dist_Zilla" : { "perl" : { "version" : "5.018002" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "name" : "@Filter/Git::GatherDir", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@Filter/CheckPrereqsIndexed", "version" : "0.010" }, { "class" : "Dist::Zilla::Plugin::CheckExtraTests", "name" : "@Filter/CheckExtraTests", "version" : "0.016" }, { "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", "skip" : [] } }, "name" : "@Filter/RJBS-Outdated", "version" : "0.015" }, { "class" : "Dist::Zilla::Plugin::PromptIfStale", "config" : { "Dist::Zilla::Plugin::PromptIfStale" : { "check_all_plugins" : "1", "check_all_prereqs" : 0, "modules" : [], "phase" : "release", "skip" : [] } }, "name" : "@Filter/CPAN-Outdated", "version" : "0.015" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Filter/@Filter/PruneCruft", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Filter/@Filter/ManifestSkip", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Filter/@Filter/MetaYAML", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Filter/@Filter/License", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@Filter/@Filter/Readme", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Filter/@Filter/ExecDir", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Filter/@Filter/ShareDir", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "name" : "@Filter/@Filter/MakeMaker", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Filter/@Filter/Manifest", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Filter/@Filter/TestRelease", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Filter/@Filter/ConfirmRelease", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Filter/@Filter/UploadToCPAN", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::Git::NextVersion", "name" : "@Filter/Git::NextVersion", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@Filter/PkgVersion", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Filter/MetaConfig", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Filter/MetaJSON", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@Filter/NextRelease", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::Test::ChangesHasContent", "name" : "@Filter/Test::ChangesHasContent", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Filter/PodSyntaxTests", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::ReportVersions::Tiny", "name" : "@Filter/ReportVersions::Tiny", "version" : "1.10" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@Filter/TestMoreWithSubtests", "version" : "5.010" }, { "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.006" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.006" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@RJBS/SingleEncoding", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@RJBS/Name", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@RJBS/Version", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@RJBS/Prelude", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Synopsis", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Description", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Overview", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Stability", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Attributes", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Methods", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Functions", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@RJBS/Leftovers", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@RJBS/postlude", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@RJBS/Authors", "version" : "4.006" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@RJBS/Legal", "version" : "4.006" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@RJBS/List", "version" : "4.006" } ] } }, "name" : "@Filter/PodWeaver", "version" : "4.005" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "@Filter/GithubMeta", "version" : "0.42" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "name" : "@Filter/@Git/Check", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "name" : "@Filter/@Git/Commit", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "name" : "@Filter/@Git/Tag", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "name" : "@Filter/@Git/Push", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "AutoPrereqs", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "5.010" }, { "class" : "inc::BuildDemo", "name" : "=inc::BuildDemo", "version" : null }, { "class" : "Dist::Zilla::Plugin::PruneFiles", "name" : "PruneFiles", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "5.010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "5.010" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "5.010" } } } Makefile.PL100644000766000024 412112264313723 15345 0ustar00rjbsstaff000000000000Test-Routine-0.018 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.010. use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "composable units of assertion", "AUTHOR" => "Ricardo Signes ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Test-Routine", "EXE_FILES" => [], "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, "Test::More" => "0.96", "Try::Tiny" => 0, "namespace::autoclean" => 0, "namespace::clean" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Test::Builder::Tester" => 0, "Test::Fatal" => 0, "Test::Moose" => 0, "Test::More" => "0.96" }, "VERSION" => "0.018", "test" => { "TESTS" => "t/*.t t/demo/*.t t/todo/*.t" } ); my %FallbackPrereqs = ( "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, "Test::Builder::Tester" => 0, "Test::Fatal" => 0, "Test::Moose" => 0, "Test::More" => "0.96", "Try::Tiny" => 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); todo000755000766000024 012264313723 14445 5ustar00rjbsstaff000000000000Test-Routine-0.018/tmxrp.t100644000766000024 153212264313723 15761 0ustar00rjbsstaff000000000000Test-Routine-0.018/t/todo#!/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; lib000755000766000024 012264313723 14246 5ustar00rjbsstaff000000000000Test-Routine-0.018/tNoGood.pm100644000766000024 25712264313723 16115 0ustar00rjbsstaff000000000000Test-Routine-0.018/t/libpackage t::lib::NoGood; use Test::Routine; test "this will be duplicated" => sub { die 'Unimplemented' }; test "this will be duplicated" => sub { die 'Unimplemented' }; 1; unsafe-name.t100644000766000024 26412264313723 16206 0ustar00rjbsstaff000000000000Test-Routine-0.018/tuse 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; demo000755000766000024 012264313723 14424 5ustar00rjbsstaff000000000000Test-Routine-0.018/t01-demo.t100644000766000024 1360312264313723 16136 0ustar00rjbsstaff000000000000Test-Routine-0.018/t/demo#!/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; 04-misc.t100644000766000024 215512264313723 16130 0ustar00rjbsstaff000000000000Test-Routine-0.018/t/demouse 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; method-filter.t100644000766000024 217012264313723 16570 0ustar00rjbsstaff000000000000Test-Routine-0.018/tuse 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; 02-simple.t100644000766000024 453212264313723 16465 0ustar00rjbsstaff000000000000Test-Routine-0.018/t/demo# 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! 03-advice.t100644000766000024 333312264313723 16426 0ustar00rjbsstaff000000000000Test-Routine-0.018/t/demouse 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; Test000755000766000024 012264313723 14722 5ustar00rjbsstaff000000000000Test-Routine-0.018/libRoutine.pm100644000766000024 2264212264313723 17073 0ustar00rjbsstaff000000000000Test-Routine-0.018/lib/Testuse strict; use warnings; package Test::Routine; { $Test::Routine::VERSION = '0.018'; } # ABSTRACT: composable units of assertion 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( with_caller => [ 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 = shift; 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' ); $method = $method_metaclass->meta->rebless_instance( $body, %$arg, name => $name, package_name => $caller, _origin => \%origin, ); } else { $method = Test::Routine::Test->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 "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.018 =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 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 05-multiple.t100644000766000024 532012264313723 17026 0ustar00rjbsstaff000000000000Test-Routine-0.018/t/demo#!/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; release000755000766000024 012264313723 15310 5ustar00rjbsstaff000000000000Test-Routine-0.018/xtpod-syntax.t100644000766000024 33212264313723 17721 0ustar00rjbsstaff000000000000Test-Routine-0.018/xt/release#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); Routine000755000766000024 012264313723 16347 5ustar00rjbsstaff000000000000Test-Routine-0.018/lib/TestTest.pm100644000766000024 151712264313723 17770 0ustar00rjbsstaff000000000000Test-Routine-0.018/lib/Test/Routinepackage Test::Routine::Test; { $Test::Routine::Test::VERSION = '0.018'; } use Moose; extends 'Moose::Meta::Method'; # ABSTRACT: a test method in a Test::Routine role with 'Test::Routine::Test::Role'; 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Test - a test method in a Test::Routine role =head1 VERSION version 0.018 =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 Util.pm100644000766000024 446412264313723 17772 0ustar00rjbsstaff000000000000Test-Routine-0.018/lib/Test/Routineuse strict; use warnings; package Test::Routine::Util; { $Test::Routine::Util::VERSION = '0.018'; } # ABSTRACT: helpful exports for dealing with test routines 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.018 =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 Common.pm100644000766000024 163512264313723 20302 0ustar00rjbsstaff000000000000Test-Routine-0.018/lib/Test/Routinepackage Test::Routine::Common; { $Test::Routine::Common::VERSION = '0.018'; } use Moose::Role; # ABSTRACT: a role composed by all Test::Routine roles use Test::More (); use namespace::autoclean; sub run_test { my ($self, $test) = @_; my $name = $test->name; Test::More::subtest($test->description, sub { $self->$name }); } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Common - a role composed by all Test::Routine roles =head1 VERSION version 0.018 =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 Runner.pm100644000766000024 701512264313723 20321 0ustar00rjbsstaff000000000000Test-Routine-0.018/lib/Test/Routinepackage Test::Routine::Runner; { $Test::Routine::Runner::VERSION = '0.018'; } use Moose; # ABSTRACT: tools for running Test::Routine tests use Carp qw(confess croak); use Scalar::Util qw(reftype); use Test::More (); 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 test_instance => ( is => 'ro', does => 'Test::Routine::Common', init_arg => undef, lazy_build => 1, ); 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, ); has fresh_instance => ( is => 'ro', isa => 'Bool', default => 0, ); sub run { my ($self) = @_; my $thing = $self->test_instance; my @tests = grep { Moose::Util::does_role($_, 'Test::Routine::Test::Role') } $thing->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; Test::More::subtest($self->description, sub { for my $test (@ordered_tests) { $self->test_instance->run_test( $test ); $self->clear_test_instance if $self->fresh_instance; } }); } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Runner - tools for running Test::Routine tests =head1 VERSION version 0.018 =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, descibed 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 000-report-versions-tiny.t100644000766000024 602612264313723 20470 0ustar00rjbsstaff000000000000Test-Routine-0.018/tuse strict; use warnings; use Test::More 0.88; # This is a relatively nice way to avoid Test::NoWarnings breaking our # expectations by adding extra tests, without using no_plan. It also helps # avoid any other test module that feels introducing random tests, or even # test plans, is a nice idea. our $success = 0; END { $success && done_testing; } # List our own version used to generate this my $v = "\nGenerated by Dist::Zilla::Plugin::ReportVersions::Tiny v1.10\n"; eval { # no excuses! # report our Perl details my $want = "any version"; $v .= "perl: $] (wanted $want) on $^O from $^X\n\n"; }; defined($@) and diag("$@"); # Now, our module version dependencies: sub pmver { my ($module, $wanted) = @_; $wanted = " (want $wanted)"; my $pmver; eval "require $module;"; if ($@) { if ($@ =~ m/Can't locate .* in \@INC/) { $pmver = 'module not found.'; } else { diag("${module}: $@"); $pmver = 'died during require.'; } } else { my $version; eval { $version = $module->VERSION; }; if ($@) { diag("${module}: $@"); $pmver = 'died during VERSION check.'; } elsif (defined $version) { $pmver = "$version"; } else { $pmver = ''; } } # So, we should be good, right? return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n"); } eval { $v .= pmver('Carp','any version') }; eval { $v .= pmver('Class::Load','any version') }; eval { $v .= pmver('ExtUtils::MakeMaker','6.30') }; eval { $v .= pmver('Moose','any version') }; eval { $v .= pmver('Moose::Exporter','any version') }; eval { $v .= pmver('Moose::Meta::Class','any version') }; eval { $v .= pmver('Moose::Meta::Method','any version') }; eval { $v .= pmver('Moose::Role','any version') }; eval { $v .= pmver('Moose::Util','any version') }; eval { $v .= pmver('Moose::Util::TypeConstraints','any version') }; eval { $v .= pmver('Params::Util','any version') }; eval { $v .= pmver('Scalar::Util','any version') }; eval { $v .= pmver('Sub::Exporter','any version') }; eval { $v .= pmver('Sub::Exporter::Util','any version') }; eval { $v .= pmver('Test::Builder::Tester','any version') }; eval { $v .= pmver('Test::Fatal','any version') }; eval { $v .= pmver('Test::Moose','any version') }; eval { $v .= pmver('Test::More','0.96') }; eval { $v .= pmver('Try::Tiny','any version') }; eval { $v .= pmver('namespace::autoclean','any version') }; eval { $v .= pmver('namespace::clean','any version') }; eval { $v .= pmver('strict','any version') }; eval { $v .= pmver('warnings','any version') }; # All done. $v .= <<'EOT'; Thanks for using my code. I hope it works for you. If not, please try and include this output in the bug report. That will help me reproduce the issue and solve your problem. EOT diag($v); ok(1, "we really didn't test anything, just reporting data"); $success = 1; # Work around another nasty module on CPAN. :/ no warnings 'once'; $Template::Test::NO_FLUSH = 1; exit 0; Test000755000766000024 012264313723 17266 5ustar00rjbsstaff000000000000Test-Routine-0.018/lib/Test/RoutineRole.pm100644000766000024 136612264313723 20673 0ustar00rjbsstaff000000000000Test-Routine-0.018/lib/Test/Routine/Testpackage Test::Routine::Test::Role; { $Test::Routine::Test::Role::VERSION = '0.018'; } # ABSTRACT: role providing test attributes use Moose::Role; has description => ( is => 'ro', isa => 'Str', lazy => 1, default => sub { $_[0]->name }, ); has _origin => ( is => 'ro', isa => 'HashRef', required => 1, ); no Moose::Role; 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Test::Role - role providing test attributes =head1 VERSION version 0.018 =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 Compositor.pm100644000766000024 416412264313723 21210 0ustar00rjbsstaff000000000000Test-Routine-0.018/lib/Test/Routineuse strict; use warnings; package Test::Routine::Compositor; { $Test::Routine::Compositor::VERSION = '0.018'; } # ABSTRACT: the tool for turning test routines into runnable classes 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.018 =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 Manual000755000766000024 012264313723 17564 5ustar00rjbsstaff000000000000Test-Routine-0.018/lib/Test/RoutineDemo.pm100644000766000024 3643312264313723 21177 0ustar00rjbsstaff000000000000Test-Routine-0.018/lib/Test/Routine/Manualuse strict; use warnings; package Test::Routine::Manual::Demo; { $Test::Routine::Manual::Demo::VERSION = '0.018'; } # ABSTRACT: a walkthrough, in code, of Test::Routine 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Routine::Manual::Demo - a walkthrough, in code, of Test::Routine =head1 VERSION version 0.018 =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 changes_has_content.t100644000766000024 201112264313723 21624 0ustar00rjbsstaff000000000000Test-Routine-0.018/xt/release#!perl use Test::More tests => 2; note 'Checking Changes'; my $changes_file = 'Changes'; my $newver = '0.018'; my $trial_token = '-TRIAL'; 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; # _get_changes copied and adapted from Dist::Zilla::Plugin::Git::Commit # by Jerome Quelin 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>); 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; }