MooseX-NonMoose-0.27/000755 000000 000000 00000000000 14735654751 014406 5ustar00rootroot000000 000000 MooseX-NonMoose-0.27/Changes000644 000000 000000 00000007655 14735654751 015716 0ustar00rootroot000000 000000 Revision history for MooseX-NonMoose 0.27 2025-01-02 20:30:46 -0700 - Drop dependency on List::MoreUtils - New maintainer and repository: https://github.com/uperl/MooseX-NonMoose 0.26 2014-02-25 - fix dependency specification for Try::Tiny (Gareth Harper, https://github.com/doy/moosex-nonmoose/pull/9) 0.25 2014-02-06 - fix for Module::Runtime 0.014 0.24 2013-09-07 - added missing lib include (Karen Etheridge) 0.23 2013-09-04 - stop using old and deprecated (or soon to be deprecated) functions from Class::MOP 0.22 2011-05-09 - Fix issues where the metaclass gets reinitialized after the call to 'extends' but before 'make_immutable'. This could happen if a role used an extension which provided an application_to_class metarole, since the role application would then apply a metarole to the class, and metarole application currently causes metaclass reinitialization in Moose. (ugh.) 0.21 2011-04-29 - Allow this module to work with constructors with names other than 'new'. If you're extending a class with a constructor named something other than 'new', you should declare this when calling extends, as in: extends 'Foo' => { -constructor_name => 'create' }; This will ensure that calling 'create' will also call Moose's constructor. 0.20 2011-03-22 - fix warning when passing inline_constructor => 0 with no superclass new method (rafl). 0.19 2011-03-02 - don't die if superclass doesn't have a 'new' method 0.18 2011-02-09 - forward compat for Moose 2.0 0.17 2010-11-08 - convert to Test::Fatal, and dep on it 0.16 2010-10-05 - Make it work with Moose 1.15 (Dave Rolsky). 0.15 2010-08-20 - Fix the fallback constructor call for hashref parameters (ribasushi, t0m, castaway). 0.14 2010-07-19 - Avoid warnings from Moose 1.09, part 2 (Dave Rolsky). 0.13 2010-07-18 - Also avoid warnings in MooseX::NonMoose::InsideOut. 0.12 2010-07-18 - Avoid warnings from Moose 1.09 (Dave Rolsky). 0.11 2010-06-30 - Actually use the right test. 0.10 2010-06-30 - Don't break if someone specifies a version to extends. 0.09 2010-06-15 - Fix several issues relating to picking the correct constructor to call from the constructor that we build. 0.08 2010-05-20 - Fix inheriting from classes which don't bless their instances into the correct class when subclassing (jhallock). - Update for things fixed in latest Moose. 0.07 2009-09-27 - Start adding support for non-Moose destructors. Destructor inlining isn't supported yet, since Moose isn't quite flexible enough there for it to be more than an annoying hack, but this should still work with immutable classes anyway. 0.06 2009-09-27 - defining a custom constructor in a class using mx-nonmoose now works - use a less broken test for whether or not a superclass has an inlined constructor (fixes issue uncovered by fixes to Moose's metaclass compatibility fixing) 0.05 2009-06-24 - gaaaaah, packaging is so stupid (remove stray test.pl file) 0.04 2009-06-23 - Add tests and official support for alternate instance metaclasses, such as MooseX::GlobRef and MooseX::InsideOut - including supplying a custom exporter MooseX::NonMoose::InsideOut which should work in all possible cases, when just using the same hash that the nonmoose class is using would break - Fix a couple issues with inheriting from MooseX::NonMoose classes - make sure FOREIGNBUILDARGS is only called once, and fix some issues with immutability 0.03 2009-05-06 - Add a FOREIGNBUILDARGS method to support modifying the argument list passed to the non-Moose constructor 0.02 2009-04-29 - A few minor doc fixes 0.01 2009-04-20 - Initial release MooseX-NonMoose-0.27/INSTALL000644 000000 000000 00000004600 14735654751 015437 0ustar00rootroot000000 000000 This is the Perl distribution MooseX-NonMoose. Installing MooseX-NonMoose is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm MooseX::NonMoose If it does not have permission to install modules to the current perl, cpanm will automatically set up and install to a local::lib in your home directory. See the local::lib documentation (https://metacpan.org/pod/local::lib) for details on enabling it in your environment. ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan MooseX::NonMoose ## Manual installation As a last resort, you can manually install it. If you have not already downloaded the release tarball, you can find the download link on the module's MetaCPAN page: https://metacpan.org/pod/MooseX::NonMoose Untar the tarball, install configure prerequisites (see below), then build it: % perl Makefile.PL % make && make test Then install it: % make install On Windows platforms, you should use `dmake` or `nmake`, instead of `make`. If your perl is system-managed, you can create a local::lib in your home directory to install modules to. For details, see the local::lib documentation: https://metacpan.org/pod/local::lib The prerequisites of this distribution will also have to be installed manually. The prerequisites are listed in one of the files: `MYMETA.yml` or `MYMETA.json` generated by running the manual build process described above. ## Configure Prerequisites This distribution requires other modules to be installed before this distribution's installer can be run. They can be found under the "configure_requires" key of META.yml or the "{prereqs}{configure}{requires}" key of META.json. ## Other Prerequisites This distribution may require additional modules to be installed after running Makefile.PL. Look for prerequisites in the following phases: * to run make, PHASE = build * to use the module code itself, PHASE = runtime * to run tests, PHASE = test They can all be found in the "PHASE_requires" key of MYMETA.yml or the "{prereqs}{PHASE}{requires}" key of MYMETA.json. ## Documentation MooseX-NonMoose documentation is available as POD. You can run `perldoc` from a shell to read the documentation: % perldoc MooseX::NonMoose For more information on installing Perl modules via CPAN, please see: https://www.cpan.org/modules/INSTALL.html MooseX-NonMoose-0.27/LICENSE000644 000000 000000 00000046446 14735654751 015431 0ustar00rootroot000000 000000 This software is copyright (c) 2009-2025 by Jesse Luehrs. 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) 2009-2025 by Jesse Luehrs. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Perl Artistic License 1.0 --- This software is Copyright (c) 2009-2025 by Jesse Luehrs. This is free software, licensed under: The Perl 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 as specified below. "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 uunet.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) give non-standard executables non-standard names, and clearly document 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. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 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 whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End MooseX-NonMoose-0.27/MANIFEST000644 000000 000000 00000002001 14735654751 015530 0ustar00rootroot000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.032. Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README author.yml dist.ini lib/MooseX/NonMoose.pm lib/MooseX/NonMoose/InsideOut.pm lib/MooseX/NonMoose/Meta/Role/Class.pm lib/MooseX/NonMoose/Meta/Role/Constructor.pm perlcriticrc t/00_diag.t t/BUILD.t t/BUILDARGS.t t/FOREIGNBUILDARGS.t t/attrs.t t/basic.t t/buggy-constructor-inlining.t t/buggy-constructors.t t/constructor-method-calls.t t/constructor-name.t t/destructor.t t/disable.t t/extends-moose-object.t t/extends-version.t t/hashref-constructor.t t/immutable.t t/methods.t t/moose-exporter.t t/moose.t t/moosex-globref.t t/moosex-insideout.t t/multi-level.t t/no-new-constructor-error.t t/nonmoose-moose-nonmoose.t t/only-metaclass-trait.t t/reinitialize.t t/replaced-constructor.t xt/author/critic.t xt/author/eol.t xt/author/no_tabs.t xt/author/pod.t xt/author/pod_coverage.t xt/author/pod_spelling_common.t xt/author/version.t xt/release/changes.t xt/release/fixme.t MooseX-NonMoose-0.27/META.json000644 000000 000000 00000016666 14735654751 016046 0ustar00rootroot000000 000000 { "abstract" : "easy subclassing of non-Moose classes", "author" : [ "Jesse Luehrs " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "MooseX-NonMoose", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0", "perl" : "5.006" } }, "develop" : { "recommends" : { "Dist::Zilla::Plugin::Author::Plicease::Thanks" : "0", "Dist::Zilla::Plugin::Author::Plicease::Upload" : "0", "Dist::Zilla::Plugin::ContributorsFromGit" : "0", "Dist::Zilla::Plugin::Prereqs" : "0", "Dist::Zilla::Plugin::PruneFiles" : "0", "Dist::Zilla::Plugin::RemovePrereqs" : "0", "Dist::Zilla::PluginBundle::Author::Plicease" : "2.79", "Perl::Critic::Policy::BuiltinFunctions::ProhibitBooleanGrep" : "0", "Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval" : "0", "Perl::Critic::Policy::BuiltinFunctions::ProhibitStringySplit" : "0", "Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep" : "0", "Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap" : "0", "Perl::Critic::Policy::ClassHierarchies::ProhibitExplicitISA" : "0", "Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless" : "0", "Perl::Critic::Policy::CodeLayout::ProhibitHardTabs" : "0", "Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace" : "0", "Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines" : "0", "Perl::Critic::Policy::Community::ArrayAssignAref" : "0", "Perl::Critic::Policy::Community::BarewordFilehandles" : "0", "Perl::Critic::Policy::Community::ConditionalDeclarations" : "0", "Perl::Critic::Policy::Community::ConditionalImplicitReturn" : "0", "Perl::Critic::Policy::Community::DeprecatedFeatures" : "0", "Perl::Critic::Policy::Community::DiscouragedModules" : "0", "Perl::Critic::Policy::Community::DollarAB" : "0", "Perl::Critic::Policy::Community::Each" : "0", "Perl::Critic::Policy::Community::EmptyReturn" : "0", "Perl::Critic::Policy::Community::IndirectObjectNotation" : "0", "Perl::Critic::Policy::Community::LexicalForeachIterator" : "0", "Perl::Critic::Policy::Community::LoopOnHash" : "0", "Perl::Critic::Policy::Community::ModPerl" : "0", "Perl::Critic::Policy::Community::OpenArgs" : "0", "Perl::Critic::Policy::Community::OverloadOptions" : "0", "Perl::Critic::Policy::Community::POSIXImports" : "0", "Perl::Critic::Policy::Community::PackageMatchesFilename" : "0", "Perl::Critic::Policy::Community::PreferredAlternatives" : "0", "Perl::Critic::Policy::Community::StrictWarnings" : "0", "Perl::Critic::Policy::Community::Threads" : "0", "Perl::Critic::Policy::Community::Wantarray" : "0", "Perl::Critic::Policy::Community::WarningsSwitch" : "0", "Perl::Critic::Policy::Community::WhileDiamondDefaultAssignment" : "0", "Perl::Critic::Policy::ControlStructures::ProhibitLabelsWithSpecialBlockNames" : "0", "Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions" : "0", "Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode" : "0", "Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles" : "0", "Perl::Critic::Policy::InputOutput::ProhibitJoinedReadline" : "0", "Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen" : "0", "Perl::Critic::Policy::Miscellanea::ProhibitFormats" : "0", "Perl::Critic::Policy::Miscellanea::ProhibitUselessNoCritic" : "0", "Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements" : "0", "Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish" : "0", "Perl::Critic::Policy::Objects::ProhibitIndirectSyntax" : "0", "Perl::Critic::Policy::RegularExpressions::ProhibitUselessTopic" : "0", "Perl::Critic::Policy::Subroutines::ProhibitNestedSubs" : "0", "Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros" : "0", "Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators" : "0", "Perl::Critic::Policy::ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator" : "0", "Perl::Critic::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTerminator" : "0", "Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames" : "0", "Perl::Critic::Policy::Variables::ProhibitUnusedVariables" : "0", "Software::License::Perl_5" : "0" }, "requires" : { "File::Spec" : "0", "FindBin" : "0", "MooseX::GlobRef" : "0", "MooseX::InsideOut" : "0", "Perl::Critic" : "0", "Test2::Require::Module" : "0.000121", "Test2::Tools::PerlCritic" : "0", "Test2::V0" : "0.000121", "Test::CPAN::Changes" : "0", "Test::EOL" : "0", "Test::Fixme" : "0.07", "Test::More" : "0.98", "Test::NoTabs" : "0", "Test::Pod" : "0", "Test::Pod::Coverage" : "0", "Test::Pod::Spelling::CommonMistakes" : "0", "YAML" : "0" } }, "runtime" : { "requires" : { "List::Util" : "1.33", "Module::Runtime" : "0", "Moose::Exporter" : "0", "Moose::Role" : "2.0000", "Moose::Util" : "0", "Scalar::Util" : "0", "Try::Tiny" : "0", "perl" : "5.008" } }, "test" : { "requires" : { "Moose" : "0", "Test2::Require::Module" : "0.000121", "Test::Fatal" : "0", "Test::Moose" : "0", "Test::More" : "0.98", "base" : "0", "perl" : "5.008" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/uperl/MooseX-NonMoose/issues" }, "homepage" : "https://metacpan.org/pod/MooseX::NonMoose", "repository" : { "type" : "git", "url" : "git://github.com/uperl/MooseX-NonMoose.git", "web" : "https://github.com/uperl/MooseX-NonMoose" } }, "version" : "0.27", "x_contributors" : [ "Brian Phillips ", "Dave Rolsky ", "Florian Ragwitz ", "Gareth Harper ", "Graham Knop ", "Graham Ollis ", "Hans Dieter Pearcey ", "Jason May ", "Karen Etheridge ", "Larry Leszczynski ", "fschlich ", "Jesse Luehrs " ], "x_generated_by_perl" : "v5.38.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.39", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later", "x_use_unsafe_inc" : 0 } MooseX-NonMoose-0.27/META.yml000644 000000 000000 00000003045 14735654751 015661 0ustar00rootroot000000 000000 --- abstract: 'easy subclassing of non-Moose classes' author: - 'Jesse Luehrs ' build_requires: Moose: '0' Test2::Require::Module: '0.000121' Test::Fatal: '0' Test::Moose: '0' Test::More: '0.98' base: '0' perl: '5.008' configure_requires: ExtUtils::MakeMaker: '0' perl: '5.006' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: MooseX-NonMoose requires: List::Util: '1.33' Module::Runtime: '0' Moose::Exporter: '0' Moose::Role: '2.0000' Moose::Util: '0' Scalar::Util: '0' Try::Tiny: '0' perl: '5.008' resources: bugtracker: https://github.com/uperl/MooseX-NonMoose/issues homepage: https://metacpan.org/pod/MooseX::NonMoose repository: git://github.com/uperl/MooseX-NonMoose.git version: '0.27' x_contributors: - 'Brian Phillips ' - 'Dave Rolsky ' - 'Florian Ragwitz ' - 'Gareth Harper ' - 'Graham Knop ' - 'Graham Ollis ' - 'Hans Dieter Pearcey ' - 'Jason May ' - 'Karen Etheridge ' - 'Larry Leszczynski ' - 'fschlich ' - 'Jesse Luehrs ' x_generated_by_perl: v5.38.0 x_serialization_backend: 'YAML::Tiny version 1.76' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' x_use_unsafe_inc: 0 MooseX-NonMoose-0.27/Makefile.PL000644 000000 000000 00000003312 14735654751 016357 0ustar00rootroot000000 000000 BEGIN { use strict; use warnings; unless(eval q{ use 5.008; 1}) { print "Perl 5.008 or better required\n"; exit; } } # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.032. use strict; use warnings; use 5.008; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "easy subclassing of non-Moose classes", "AUTHOR" => "Jesse Luehrs ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "MooseX-NonMoose", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.008", "NAME" => "MooseX::NonMoose", "PREREQ_PM" => { "List::Util" => "1.33", "Module::Runtime" => 0, "Moose::Exporter" => 0, "Moose::Role" => "2.0000", "Moose::Util" => 0, "Scalar::Util" => 0, "Try::Tiny" => 0 }, "TEST_REQUIRES" => { "Moose" => 0, "Test2::Require::Module" => "0.000121", "Test::Fatal" => 0, "Test::Moose" => 0, "Test::More" => "0.98", "base" => 0 }, "VERSION" => "0.27", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "List::Util" => "1.33", "Module::Runtime" => 0, "Moose" => 0, "Moose::Exporter" => 0, "Moose::Role" => "2.0000", "Moose::Util" => 0, "Scalar::Util" => 0, "Test2::Require::Module" => "0.000121", "Test::Fatal" => 0, "Test::Moose" => 0, "Test::More" => "0.98", "Try::Tiny" => 0, "base" => 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); MooseX-NonMoose-0.27/README000644 000000 000000 00000012554 14735654751 015275 0ustar00rootroot000000 000000 NAME MooseX::NonMoose - easy subclassing of non-Moose classes VERSION version 0.27 SYNOPSIS package Term::VT102::NBased; use Moose; use MooseX::NonMoose; extends 'Term::VT102'; has [qw/x_base y_base/] => ( is => 'ro', isa => 'Int', default => 1, ); around x => sub { my $orig = shift; my $self = shift; $self->$orig(@_) + $self->x_base - 1; }; # ... (wrap other methods) no Moose; # no need to fiddle with inline_constructor here __PACKAGE__->meta->make_immutable; my $vt = Term::VT102::NBased->new(x_base => 0, y_base => 0); DESCRIPTION MooseX::NonMoose allows for easily subclassing non-Moose classes with Moose, taking care of the annoying details connected with doing this, such as setting up proper inheritance from Moose::Object and installing (and inlining, at make_immutable time) a constructor that makes sure things like BUILD methods are called. It tries to be as non-intrusive as possible - when this module is used, inheriting from non-Moose classes and inheriting from Moose classes should work identically, aside from the few caveats mentioned below. One of the goals of this module is that including it in a Moose::Exporter-based package used across an entire application should be possible, without interfering with classes that only inherit from Moose modules, or even classes that don't inherit from anything at all. There are several ways to use this module. The most straightforward is to just use MooseX::NonMoose; in your class; this should set up everything necessary for extending non-Moose modules. MooseX::NonMoose::Meta::Role::Class and MooseX::NonMoose::Meta::Role::Constructor can also be applied to your metaclasses manually, either by passing a -traits option to your use Moose; line, or by applying them using Moose::Util::MetaRole in a Moose::Exporter-based package. MooseX::NonMoose::Meta::Role::Class is the part that provides the main functionality of this module; if you don't care about inlining, this is all you need to worry about. Applying MooseX::NonMoose::Meta::Role::Constructor as well will provide an inlined constructor when you immutabilize your class. MooseX::NonMoose allows you to manipulate the argument list that gets passed to the superclass constructor by defining a FOREIGNBUILDARGS method. This is called with the same argument list as the BUILDARGS method, but should return a list of arguments to pass to the superclass constructor. This allows MooseX::NonMoose to support superclasses whose constructors would get confused by the extra arguments that Moose requires (for attributes, etc.) Not all non-Moose classes use new as the name of their constructor. This module allows you to extend these classes by explicitly stating which method is the constructor, during the call to extends. The syntax looks like this: extends 'Foo' => { -constructor_name => 'create' }; similar to how you can already pass -version in the extends call in a similar way. BUGS/CAVEATS * The reference that the non-Moose class uses as its instance type must match the instance type that Moose is using. Moose's default instance type is a hashref, but other modules exist to make Moose use other instance types. MooseX::InsideOut is the most general solution - it should work with any class. For globref-based classes in particular, MooseX::GlobRef will also allow Moose to work. For more information, see the 032-moosex-insideout and 033-moosex-globref tests bundled with this dist. * Modifying your class' @ISA after an initial extends call will potentially cause problems if any of those new entries in the @ISA override the constructor. MooseX::NonMoose wraps the nearest new() method at the time extends is called and will not see any other new() methods in the @ISA hierarchy. * Completely overriding the constructor in a class using MooseX::NonMoose (i.e. using sub new { ... }) currently doesn't work, although using method modifiers on the constructor should work identically to normal Moose classes. Please report any bugs to GitHub Issues at https://github.com/uperl/moosex-nonmoose/issues. SEE ALSO * "How do I make non-Moose constructors work with Moose?" in Moose::Manual::FAQ * MooseX::Alien serves the same purpose, but with a radically different (and far more hackish) implementation. SUPPORT You can find this documentation for this module with the perldoc command. perldoc MooseX::NonMoose You can also look for information at: * MetaCPAN https://metacpan.org/release/MooseX-NonMoose * Github https://github.com/uperl/moosex-nonmoose * RT: CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-NonMoose AUTHOR Original author: Jesse Luehrs Current maintainer: Graham Ollis COPYRIGHT AND LICENSE This software is copyright (c) 2009-2025 by Jesse Luehrs. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. MooseX-NonMoose-0.27/author.yml000644 000000 000000 00000000222 14735654751 016427 0ustar00rootroot000000 000000 --- pod_coverage: skip: 0 # format is "Class#method" or "Class", regex allowed # for either Class or method. private: - .*#init_meta MooseX-NonMoose-0.27/dist.ini000644 000000 000000 00000001632 14735654751 016054 0ustar00rootroot000000 000000 name = MooseX-NonMoose author = Jesse Luehrs autgor = Graham Ollis license = Perl_5 copyright_holder = Jesse Luehrs copyright_year = 2009-2025 version = 0.27 [@Author::Plicease] :version = 2.79 release_tests = 1 installer = MakeMaker github_user = uperl diag = +MooseX::GlobRef diag = +MooseX::InsideOut workflow = static workflow = linux [Author::Plicease::Upload] cpan = 1 [PruneFiles] filename = xt/author/pod_spelling_system.t filename = xt/author/strict.t [ContributorsFromGit] [Prereqs / TestRequires] Test::More = 0.88 [RemovePrereqs] remove = strict remove = warnings remove = MooseX::GlobRef remove = MooseX::InsideOut remove = IO::File remove = IO::Handle [Prereqs / DevelopRequires] MooseX::GlobRef = 0 MooseX::InsideOut = 0 [Author::Plicease::Thanks] original = Jesse Luehrs current = Graham Ollis MooseX-NonMoose-0.27/lib/000755 000000 000000 00000000000 14735654751 015154 5ustar00rootroot000000 000000 MooseX-NonMoose-0.27/lib/MooseX/000755 000000 000000 00000000000 14735654751 016366 5ustar00rootroot000000 000000 MooseX-NonMoose-0.27/lib/MooseX/NonMoose.pm000644 000000 000000 00000013711 14735654751 020464 0ustar00rootroot000000 000000 package MooseX::NonMoose; use Moose::Exporter; use Moose::Util; # ABSTRACT: easy subclassing of non-Moose classes our $VERSION = '0.27'; # VERSION my ($import, $unimport, $init_meta) = Moose::Exporter->build_import_methods( class_metaroles => { class => ['MooseX::NonMoose::Meta::Role::Class'], constructor => ['MooseX::NonMoose::Meta::Role::Constructor'], }, install => [qw(import unimport)], ); sub init_meta { my $package = shift; my %options = @_; my $meta = Moose::Util::find_meta($options{for_class}); Carp::cluck('Roles have no use for MooseX::NonMoose') if $meta && $meta->isa('Moose::Meta::Role'); $package->$init_meta(@_); } 1; __END__ =pod =encoding UTF-8 =head1 NAME MooseX::NonMoose - easy subclassing of non-Moose classes =head1 VERSION version 0.27 =head1 SYNOPSIS package Term::VT102::NBased; use Moose; use MooseX::NonMoose; extends 'Term::VT102'; has [qw/x_base y_base/] => ( is => 'ro', isa => 'Int', default => 1, ); around x => sub { my $orig = shift; my $self = shift; $self->$orig(@_) + $self->x_base - 1; }; # ... (wrap other methods) no Moose; # no need to fiddle with inline_constructor here __PACKAGE__->meta->make_immutable; my $vt = Term::VT102::NBased->new(x_base => 0, y_base => 0); =head1 DESCRIPTION C allows for easily subclassing non-Moose classes with Moose, taking care of the annoying details connected with doing this, such as setting up proper inheritance from L and installing (and inlining, at C time) a constructor that makes sure things like C methods are called. It tries to be as non-intrusive as possible - when this module is used, inheriting from non-Moose classes and inheriting from Moose classes should work identically, aside from the few caveats mentioned below. One of the goals of this module is that including it in a L-based package used across an entire application should be possible, without interfering with classes that only inherit from Moose modules, or even classes that don't inherit from anything at all. There are several ways to use this module. The most straightforward is to just C in your class; this should set up everything necessary for extending non-Moose modules. L and L can also be applied to your metaclasses manually, either by passing a C<-traits> option to your C line, or by applying them using L in a L-based package. L is the part that provides the main functionality of this module; if you don't care about inlining, this is all you need to worry about. Applying L as well will provide an inlined constructor when you immutabilize your class. C allows you to manipulate the argument list that gets passed to the superclass constructor by defining a C method. This is called with the same argument list as the C method, but should return a list of arguments to pass to the superclass constructor. This allows C to support superclasses whose constructors would get confused by the extra arguments that Moose requires (for attributes, etc.) Not all non-Moose classes use C as the name of their constructor. This module allows you to extend these classes by explicitly stating which method is the constructor, during the call to C. The syntax looks like this: extends 'Foo' => { -constructor_name => 'create' }; similar to how you can already pass C<-version> in the C call in a similar way. =head1 BUGS/CAVEATS =over 4 =item * The reference that the non-Moose class uses as its instance type B match the instance type that Moose is using. Moose's default instance type is a hashref, but other modules exist to make Moose use other instance types. L is the most general solution - it should work with any class. For globref-based classes in particular, L will also allow Moose to work. For more information, see the C<032-moosex-insideout> and C<033-moosex-globref> tests bundled with this dist. =item * Modifying your class' C<@ISA> after an initial C call will potentially cause problems if any of those new entries in the C<@ISA> override the constructor. C wraps the nearest C method at the time C is called and will not see any other C methods in the @ISA hierarchy. =item * Completely overriding the constructor in a class using C (i.e. using C) currently doesn't work, although using method modifiers on the constructor should work identically to normal Moose classes. =back Please report any bugs to GitHub Issues at L. =head1 SEE ALSO =over 4 =item * L =item * L serves the same purpose, but with a radically different (and far more hackish) implementation. =back =head1 SUPPORT You can find this documentation for this module with the perldoc command. perldoc MooseX::NonMoose You can also look for information at: =over 4 =item * MetaCPAN L =item * Github L =item * RT: CPAN's request tracker L =back =for Pod::Coverage init_meta =head1 AUTHOR Original author: Jesse Luehrs Edoy@tozt.netE Current maintainer: Graham Ollis Eplicease@cpan.orgE =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2009-2025 by Jesse Luehrs. 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 MooseX-NonMoose-0.27/lib/MooseX/NonMoose/000755 000000 000000 00000000000 14735654751 020123 5ustar00rootroot000000 000000 MooseX-NonMoose-0.27/lib/MooseX/NonMoose/InsideOut.pm000644 000000 000000 00000003542 14735654751 022370 0ustar00rootroot000000 000000 package MooseX::NonMoose::InsideOut; use Moose::Exporter; # ABSTRACT: easy subclassing of non-Moose non-hashref classes our $VERSION = '0.27'; # VERSION my ($import, $unimport, $init_meta) = Moose::Exporter->build_import_methods( class_metaroles => { class => ['MooseX::NonMoose::Meta::Role::Class'], constructor => ['MooseX::NonMoose::Meta::Role::Constructor'], instance => ['MooseX::InsideOut::Role::Meta::Instance'], }, install => [qw(import unimport)], ); sub init_meta { my $package = shift; my %options = @_; my $meta = Moose::Util::find_meta($options{for_class}); Carp::cluck('Roles have no use for MooseX::NonMoose') if $meta && $meta->isa('Moose::Meta::Role'); $package->$init_meta(@_); } 1; __END__ =pod =encoding UTF-8 =head1 NAME MooseX::NonMoose::InsideOut - easy subclassing of non-Moose non-hashref classes =head1 VERSION version 0.27 =head1 SYNOPSIS package Term::VT102::NBased; use Moose; use MooseX::NonMoose::InsideOut; extends 'Term::VT102'; has [qw/x_base y_base/] => ( is => 'ro', isa => 'Int', default => 1, ); around x => sub { my $orig = shift; my $self = shift; $self->$orig(@_) + $self->x_base - 1; }; # ... (wrap other methods) no Moose; # no need to fiddle with inline_constructor here __PACKAGE__->meta->make_immutable; my $vt = Term::VT102::NBased->new(x_base => 0, y_base => 0); =head1 DESCRIPTION =for Pod::Coverage init_meta =head1 AUTHOR Original author: Jesse Luehrs Edoy@tozt.netE Current maintainer: Graham Ollis Eplicease@cpan.orgE =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2009-2025 by Jesse Luehrs. 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 MooseX-NonMoose-0.27/lib/MooseX/NonMoose/Meta/000755 000000 000000 00000000000 14735654751 021011 5ustar00rootroot000000 000000 MooseX-NonMoose-0.27/lib/MooseX/NonMoose/Meta/Role/000755 000000 000000 00000000000 14735654751 021712 5ustar00rootroot000000 000000 MooseX-NonMoose-0.27/lib/MooseX/NonMoose/Meta/Role/Class.pm000644 000000 000000 00000033240 14735654751 023317 0ustar00rootroot000000 000000 package MooseX::NonMoose::Meta::Role::Class; use Moose::Role; use List::Util 1.33 qw(any); use Module::Runtime qw(use_package_optimistically); use Try::Tiny; use List::Util qw( any ); use Scalar::Util 'blessed'; # ABSTRACT: metaclass trait for L our $VERSION = '0.27'; # VERSION has has_nonmoose_constructor => ( is => 'rw', isa => 'Bool', default => 0, ); has has_nonmoose_destructor => ( is => 'rw', isa => 'Bool', default => 0, ); # overrides the constructor_name attr that already exists has constructor_name => ( is => 'rw', isa => 'Str', lazy => 1, default => sub { shift->throw_error("No constructor name has been set") }, ); # XXX ugh, really need to fix this in moose around reinitialize => sub { my $orig = shift; my $class = shift; my ($pkg) = @_; my $meta = blessed($pkg) ? $pkg : Moose::Util::find_meta($pkg); $class->$orig( @_, (map { $_->init_arg => $_->get_value($meta) } grep { $_->has_value($meta) } map { $meta->meta->find_attribute_by_name($_) } qw(has_nonmoose_constructor has_nonmoose_destructor constructor_name)), ); }; sub _determine_constructor_options { my $self = shift; my @options = @_; # if we're using just the metaclass trait, but not the constructor trait, # then suppress the warning about not inlining a constructor my $cc_meta = Moose::Util::find_meta($self->constructor_class); return (@options, inline_constructor => 0) unless $cc_meta->can('does_role') && $cc_meta->does_role('MooseX::NonMoose::Meta::Role::Constructor'); # do nothing if we explicitly ask for the constructor to not be inlined my %options = @options; return @options if !$options{inline_constructor}; my $constructor_name = $self->constructor_name; my $local_constructor = $self->get_method($constructor_name); if (!defined($local_constructor)) { warn "Not inlining a constructor for " . $self->name . " since " . "its parent " . ($self->superclasses)[0] . " doesn't contain a " . "constructor named '$constructor_name'. " . "If you are certain you don't need to inline your" . " constructor, specify inline_constructor => 0 in your" . " call to " . $self->name . "->meta->make_immutable\n"; return @options; } # do nothing if extends was called, but we then added a method modifier to # the constructor (this will warn, but that's okay) # XXX: this is a fairly big hack, but it should cover most of the cases # that actually show up in practice... it would be nice to do this properly # though return @options if $local_constructor->isa('Class::MOP::Method::Wrapped'); # otherwise, explicitly ask for the constructor to be replaced (to suppress # the warning message), since this is the expected usage, and shouldn't # cause a warning return (replace_constructor => 1, @options); } sub _determine_destructor_options { my $self = shift; my @options = @_; return (@options, inline_destructor => 0); } around _immutable_options => sub { my $orig = shift; my $self = shift; my @options = $self->$orig(@_); # do nothing if extends was never called return @options if !$self->has_nonmoose_constructor && !$self->has_nonmoose_destructor; @options = $self->_determine_constructor_options(@options); @options = $self->_determine_destructor_options(@options); return @options; }; sub _check_superclass_constructor { my $self = shift; # if the current class defined a custom new method (since subs happen at # BEGIN time), don't try to override it return if $self->has_method($self->constructor_name); # we need to get the non-moose constructor from the superclass # of the class where this method actually exists, regardless of what class # we're calling it on my $super_new = $self->find_next_method_by_name($self->constructor_name); # if we're trying to extend a (non-immutable) moose class, just do nothing return if $super_new->package_name eq 'Moose::Object'; if ($super_new->associated_metaclass->can('constructor_class')) { my $constructor_class_meta = Class::MOP::Class->initialize( $super_new->associated_metaclass->constructor_class ); # if the constructor we're inheriting is already one of ours, there's # no reason to install a new one return if $constructor_class_meta->can('does_role') && $constructor_class_meta->does_role('MooseX::NonMoose::Meta::Role::Constructor'); # if the constructor we're inheriting is an inlined version of the # default moose constructor, don't do anything either return if any { $_->isa($constructor_class_meta->name) } $super_new->associated_metaclass->_inlined_methods; } $self->add_method($self->constructor_name => sub { my $class = shift; my $params = $class->BUILDARGS(@_); my @foreign_params = $class->can('FOREIGNBUILDARGS') ? $class->FOREIGNBUILDARGS(@_) : @_; my $instance = $super_new->execute($class, @foreign_params); if (!blessed($instance)) { confess "The constructor for " . $super_new->associated_metaclass->name . " did not return a blessed instance"; } elsif (!$instance->isa($class)) { if (!$class->isa(blessed($instance))) { confess "The constructor for " . $super_new->associated_metaclass->name . " returned an object whose class is not a parent of " . $class; } else { bless $instance, $class; } } return Class::MOP::Class->initialize($class)->new_object( __INSTANCE__ => $instance, %$params, ); }); $self->has_nonmoose_constructor(1); } sub _check_superclass_destructor { my $self = shift; # if the current class defined a custom DESTROY method (since subs happen # at BEGIN time), don't try to override it return if $self->has_method('DESTROY'); # we need to get the non-moose destructor from the superclass # of the class where this method actually exists, regardless of what class # we're calling it on my $super_DESTROY = $self->find_next_method_by_name('DESTROY'); # if we're trying to extend a (non-immutable) moose class, just do nothing return if $super_DESTROY->package_name eq 'Moose::Object'; if ($super_DESTROY->associated_metaclass->can('destructor_class') && $super_DESTROY->associated_metaclass->destructor_class) { my $destructor_class_meta = Class::MOP::Class->initialize( $super_DESTROY->associated_metaclass->destructor_class ); # if the destructor we're inheriting is an inlined version of the # default moose destructor, don't do anything return if any { $_->isa($destructor_class_meta->name) } $super_DESTROY->associated_metaclass->_inlined_methods; } $self->add_method(DESTROY => sub { my $self = shift; local $?; Try::Tiny::try { $super_DESTROY->execute($self) if defined $super_DESTROY; $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction); } Try::Tiny::catch { # Without this, Perl will warn "\t(in cleanup)$@" because of some # bizarre fucked-up logic deep in the internals. no warnings 'misc'; die $_; }; return; }); $self->has_nonmoose_destructor(1); } around superclasses => sub { my $orig = shift; my $self = shift; return $self->$orig unless @_; # XXX lots of duplication between here and MMC::superclasses my ($constructor_name, $constructor_class); for my $super (@{ Data::OptList::mkopt(\@_) }) { my ($name, $opts) = @{ $super }; my $cur_constructor_name = delete $opts->{'-constructor_name'}; if (defined($constructor_name) && defined($cur_constructor_name)) { $self->throw_error( "You have already specified " . "${constructor_class}::${constructor_name} as the parent " . "constructor; ${name}::${cur_constructor_name} cannot also be " . "the constructor" ); } if ($opts && exists($opts->{-version})) { use_package_optimistically($name, $opts->{-version}); } else { use_package_optimistically($name); } if (defined($cur_constructor_name)) { my $meta = Moose::Util::find_meta($name); $self->throw_error( "You specified '$cur_constructor_name' as the constructor for " . "$name, but $name has no method by that name" ) unless $meta ? $meta->find_method_by_name($cur_constructor_name) : $name->can($cur_constructor_name); } if (!defined($constructor_name)) { $constructor_name = $cur_constructor_name; $constructor_class = $name; } delete $opts->{'-constructor_name'}; } $self->constructor_name( defined($constructor_name) ? $constructor_name : 'new' ); my @superclasses = @_; push @superclasses, 'Moose::Object' unless any { !ref($_) && $_->isa('Moose::Object') } @superclasses; my @ret = $self->$orig(@superclasses); $self->_check_superclass_constructor; $self->_check_superclass_destructor; return @ret; }; sub _generate_fallback_constructor { my $self = shift; my ($class_var) = @_; my $new = $self->constructor_name; my $super_new_class = $self->_find_next_nonmoose_constructor_package; my $arglist = $self->find_method_by_name('FOREIGNBUILDARGS') ? "${class_var}->FOREIGNBUILDARGS(\@_)" : '@_'; my $instance = "${class_var}->${super_new_class}::$new($arglist)"; # XXX: the "my $__DUMMY = " part is because "return do" triggers a weird # bug in pre-5.12 perls (it ends up returning undef) return '(my $__DUMMY = do { ' . 'if (ref($_[0]) eq \'HASH\') { ' . '$_[0]->{__INSTANCE__} = ' . $instance . ' ' . 'unless exists $_[0]->{__INSTANCE__}; ' . '} ' . 'else { ' . 'unshift @_, __INSTANCE__ => ' . $instance . '; ' . '} ' . $class_var . '->Moose::Object::new(@_); ' . '})'; } sub _inline_generate_instance { my $self = shift; my ($var, $class_var) = @_; my $new = $self->constructor_name; my $super_new_class = $self->_find_next_nonmoose_constructor_package; my $arglist = $self->find_method_by_name('FOREIGNBUILDARGS') ? "${class_var}->FOREIGNBUILDARGS(\@_)" : '@_'; my $instance = "${class_var}->${super_new_class}::$new($arglist)"; return ( 'my ' . $var . ' = ' . $instance . ';', 'if (!Scalar::Util::blessed(' . $var . ')) {', $self->_inline_throw_error( '"The constructor for ' . $super_new_class . ' did not return a blessed instance"', ) . ';', '}', 'elsif (!' . $var . '->isa(' . $class_var . ')) {', 'if (!' . $class_var . '->isa(Scalar::Util::blessed(' . $var . '))) {', $self->_inline_throw_error( '"The constructor for ' . $super_new_class . ' returned an object whose class is not a parent of ' . $class_var . '"', ) . ';', '}', 'else {', $self->_inline_rebless_instance($var, $class_var) . ';', '}', '}', ); } sub _find_next_nonmoose_constructor_package { my $self = shift; my $new = $self->constructor_name; for my $method (map { $_->{code} } $self->find_all_methods_by_name($new)) { next if $method->associated_metaclass->meta->can('does_role') && $method->associated_metaclass->meta->does_role('MooseX::NonMoose::Meta::Role::Class'); return $method->package_name; } # this should never happen (it should find Moose::Object at least) $self->throw_error("Couldn't find a non-Moose constructor for " . $self->name); } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =head1 NAME MooseX::NonMoose::Meta::Role::Class - metaclass trait for L =head1 VERSION version 0.27 =head1 SYNOPSIS package Foo; use Moose -traits => 'MooseX::NonMoose::Meta::Role::Class'; # or package My::Moose; use Moose (); use Moose::Exporter; Moose::Exporter->setup_import_methods; sub init_meta { shift; my %options = @_; Moose->init_meta(%options); Moose::Util::MetaRole::apply_metaclass_roles( for_class => $options{for_class}, metaclass_roles => ['MooseX::NonMoose::Meta::Role::Class'], ); return Moose::Util::find_meta($options{for_class}); } =head1 DESCRIPTION This trait implements everything involved with extending non-Moose classes, other than doing the actual inlining at C time. See L for more details. =head1 AUTHOR Original author: Jesse Luehrs Edoy@tozt.netE Current maintainer: Graham Ollis Eplicease@cpan.orgE =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2009-2025 by Jesse Luehrs. 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 MooseX-NonMoose-0.27/lib/MooseX/NonMoose/Meta/Role/Constructor.pm000644 000000 000000 00000003737 14735654751 024607 0ustar00rootroot000000 000000 package MooseX::NonMoose::Meta::Role::Constructor; use Moose::Role 2.0000; # ABSTRACT: constructor method trait for L our $VERSION = '0.27'; # VERSION around can_be_inlined => sub { my $orig = shift; my $self = shift; my $meta = $self->associated_metaclass; my $super_new = $meta->find_method_by_name($self->name); my $super_meta = $super_new->associated_metaclass; if (Moose::Util::find_meta($super_meta)->can('does_role') && Moose::Util::find_meta($super_meta)->does_role('MooseX::NonMoose::Meta::Role::Class')) { return 1; } return $self->$orig(@_); }; no Moose::Role; 1; __END__ =pod =encoding UTF-8 =head1 NAME MooseX::NonMoose::Meta::Role::Constructor - constructor method trait for L =head1 VERSION version 0.27 =head1 SYNOPSIS package My::Moose; use Moose (); use Moose::Exporter; Moose::Exporter->setup_import_methods; sub init_meta { shift; my %options = @_; Moose->init_meta(%options); Moose::Util::MetaRole::apply_metaclass_roles( for_class => $options{for_class}, metaclass_roles => ['MooseX::NonMoose::Meta::Role::Class'], constructor_class_roles => ['MooseX::NonMoose::Meta::Role::Constructor'], ); return Moose::Util::find_meta($options{for_class}); } =head1 DESCRIPTION This trait implements inlining of the constructor for classes using the L metaclass trait; it has no effect unless that trait is also used. See those docs and the docs for L for more information. =head1 AUTHOR Original author: Jesse Luehrs Edoy@tozt.netE Current maintainer: Graham Ollis Eplicease@cpan.orgE =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2009-2025 by Jesse Luehrs. 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 MooseX-NonMoose-0.27/perlcriticrc000644 000000 000000 00000003720 14735654751 017020 0ustar00rootroot000000 000000 severity = 1 only = 1 [Community::ArrayAssignAref] [Community::BarewordFilehandles] [Community::ConditionalDeclarations] [Community::ConditionalImplicitReturn] [Community::DeprecatedFeatures] [Community::DiscouragedModules] [Community::DollarAB] [Community::Each] [Community::EmptyReturn] [Community::IndirectObjectNotation] [Community::LexicalForeachIterator] [Community::LoopOnHash] [Community::ModPerl] [Community::OpenArgs] [Community::OverloadOptions] [Community::POSIXImports] [Community::PackageMatchesFilename] [Community::PreferredAlternatives] [Community::StrictWarnings] extra_importers = Test2::V0 [Community::Threads] [Community::Wantarray] [Community::WarningsSwitch] [Community::WhileDiamondDefaultAssignment] [BuiltinFunctions::ProhibitBooleanGrep] [BuiltinFunctions::ProhibitStringyEval] [BuiltinFunctions::ProhibitStringySplit] [BuiltinFunctions::ProhibitVoidGrep] [BuiltinFunctions::ProhibitVoidMap] [ClassHierarchies::ProhibitExplicitISA] [ClassHierarchies::ProhibitOneArgBless] [CodeLayout::ProhibitHardTabs] allow_leading_tabs = 0 [CodeLayout::ProhibitTrailingWhitespace] [CodeLayout::RequireConsistentNewlines] [ControlStructures::ProhibitLabelsWithSpecialBlockNames] [ControlStructures::ProhibitMutatingListFunctions] [ControlStructures::ProhibitUnreachableCode] [InputOutput::ProhibitBarewordFileHandles] [InputOutput::ProhibitJoinedReadline] [InputOutput::ProhibitTwoArgOpen] [Miscellanea::ProhibitFormats] [Miscellanea::ProhibitUselessNoCritic] [Modules::ProhibitConditionalUseStatements] ;[Modules::RequireEndWithOne] [Modules::RequireNoMatchVarsWithUseEnglish] [Objects::ProhibitIndirectSyntax] [RegularExpressions::ProhibitUselessTopic] [Subroutines::ProhibitNestedSubs] [ValuesAndExpressions::ProhibitLeadingZeros] [ValuesAndExpressions::ProhibitMixedBooleanOperators] [ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator] [ValuesAndExpressions::RequireUpperCaseHeredocTerminator] [Variables::ProhibitPerl4PackageNames] [Variables::ProhibitUnusedVariables] MooseX-NonMoose-0.27/t/000755 000000 000000 00000000000 14735654751 014651 5ustar00rootroot000000 000000 MooseX-NonMoose-0.27/t/00_diag.t000644 000000 000000 00000002652 14735654751 016246 0ustar00rootroot000000 000000 use strict; use warnings; use Config; use Test::More tests => 1; # This .t file is generated. # make changes instead to dist.ini my %modules; my $post_diag; $modules{$_} = $_ for qw( ExtUtils::MakeMaker List::Util Module::Runtime Moose Moose::Exporter Moose::Role Moose::Util MooseX::GlobRef MooseX::InsideOut Scalar::Util Test2::Require::Module Test::Fatal Test::Moose Test::More Try::Tiny ); my @modules = sort keys %modules; sub spacer () { diag ''; diag ''; diag ''; } pass 'okay'; my $max = 1; $max = $_ > $max ? $_ : $max for map { length $_ } @modules; our $format = "%-${max}s %s"; spacer; my @keys = sort grep /(MOJO|PERL|\A(LC|HARNESS)_|\A(SHELL|LANG)\Z)/i, keys %ENV; if(@keys > 0) { diag "$_=$ENV{$_}" for @keys; if($ENV{PERL5LIB}) { spacer; diag "PERL5LIB path"; diag $_ for split $Config{path_sep}, $ENV{PERL5LIB}; } elsif($ENV{PERLLIB}) { spacer; diag "PERLLIB path"; diag $_ for split $Config{path_sep}, $ENV{PERLLIB}; } spacer; } diag sprintf $format, 'perl', "$] $^O $Config{archname}"; foreach my $module (@modules) { my $pm = "$module.pm"; $pm =~ s{::}{/}g; if(eval { require $pm; 1 }) { my $ver = eval { $module->VERSION }; $ver = 'undef' unless defined $ver; diag sprintf $format, $module, $ver; } else { diag sprintf $format, $module, '-'; } } if($post_diag) { spacer; $post_diag->(); } spacer; MooseX-NonMoose-0.27/t/BUILD.t000644 000000 000000 00000002065 14735654751 015700 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; sub new { my $class = shift; bless { foo => 'FOO' }, $class; } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; has class => ( is => 'rw', ); has accum => ( is => 'rw', isa => 'Str', default => '', ); sub BUILD { my $self = shift; $self->class(ref $self); $self->accum($self->accum . 'a'); } package Foo::Moose::Sub; use Moose; extends 'Foo::Moose'; has bar => ( is => 'rw', ); sub BUILD { my $self = shift; $self->bar('BAR'); $self->accum($self->accum . 'b'); } package main; my $foo_moose = Foo::Moose->new; is($foo_moose->class, 'Foo::Moose', 'BUILD method called properly'); is($foo_moose->accum, 'a', 'BUILD method called properly'); my $foo_moose_sub = Foo::Moose::Sub->new; is($foo_moose_sub->class, 'Foo::Moose::Sub', 'parent BUILD method called'); is($foo_moose_sub->bar, 'BAR', 'child BUILD method called'); is($foo_moose_sub->accum, 'ab', 'BUILD methods called in the correct order'); done_testing; MooseX-NonMoose-0.27/t/BUILDARGS.t000644 000000 000000 00000001332 14735654751 016351 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Moose; package Foo; sub new { my $class = shift; bless { name => $_[0] }, $class; } sub name { shift->{name} } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; has foo => ( is => 'rw', ); sub BUILDARGS { my $class = shift; # remove the argument that's only for passing to the superclass constructor shift; return $class->SUPER::BUILDARGS(@_); } package main; with_immutable { my $foo = Foo::Moose->new('bar', foo => 'baz'); is($foo->name, 'bar', 'superclass constructor gets the right args'); is($foo->foo, 'baz', 'subclass constructor gets the right args'); } 'Foo::Moose'; done_testing; MooseX-NonMoose-0.27/t/FOREIGNBUILDARGS.t000644 000000 000000 00000002671 14735654751 017372 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Moose; package Foo; sub new { my $class = shift; bless { foo_base => $_[0] }, $class; } sub foo_base { shift->{foo_base} } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; has foo => ( is => 'rw', ); sub FOREIGNBUILDARGS { my $class = shift; my %args = @_; return "$args{foo}_base"; } package Bar::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; has bar => ( is => 'rw', ); sub FOREIGNBUILDARGS { my $class = shift; return "$_[0]_base"; } sub BUILDARGS { my $class = shift; return { bar => shift }; } package Baz::Moose; use Moose; extends 'Bar::Moose'; has baz => ( is => 'rw', ); package main; with_immutable { my $foo = Foo::Moose->new(foo => 'bar'); is($foo->foo, 'bar', 'subclass constructor gets the right args'); is($foo->foo_base, 'bar_base', 'subclass constructor gets the right args'); my $bar = Bar::Moose->new('baz'); is($bar->bar, 'baz', 'subclass constructor gets the right args'); is($bar->foo_base, 'baz_base', 'subclass constructor gets the right args'); my $baz = Baz::Moose->new('bazbaz'); is($baz->bar, 'bazbaz', 'extensions of extensions of the nonmoose class respect BUILDARGS'); is($baz->foo_base, 'bazbaz_base', 'extensions of extensions of the nonmoose class respect FOREIGNBUILDARGS'); } qw(Foo::Moose Bar::Moose Baz::Moose); done_testing; MooseX-NonMoose-0.27/t/attrs.t000644 000000 000000 00000001260 14735654751 016172 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; sub new { my $class = shift; bless { @_ }, $class; } sub foo { my $self = shift; return $self->{foo} unless @_; $self->{foo} = shift; } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; has bar => ( is => 'rw', ); package main; my $foo_moose = Foo::Moose->new(foo => 'FOO', bar => 'BAR'); is($foo_moose->foo, 'FOO', 'foo set in constructor'); is($foo_moose->bar, 'BAR', 'bar set in constructor'); $foo_moose->foo('BAZ'); $foo_moose->bar('QUUX'); is($foo_moose->foo, 'BAZ', 'foo set by accessor'); is($foo_moose->bar, 'QUUX', 'bar set by accessor'); done_testing; MooseX-NonMoose-0.27/t/basic.t000644 000000 000000 00000001546 14735654751 016125 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; sub new { my $class = shift; bless { _class => $class }, $class; } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; package main; my $foo = Foo->new; my $foo_moose = Foo::Moose->new; isa_ok($foo, 'Foo'); is($foo->{_class}, 'Foo', 'Foo gets the correct class'); isa_ok($foo_moose, 'Foo::Moose'); isa_ok($foo_moose, 'Foo'); isa_ok($foo_moose, 'Moose::Object'); is($foo_moose->{_class}, 'Foo::Moose', 'Foo::Moose gets the correct class'); my $meta = Foo::Moose->meta; ok($meta->has_method('new'), 'Foo::Moose has its own constructor'); my $cc_meta = $meta->constructor_class->meta; isa_ok($cc_meta, 'Moose::Meta::Class'); ok($cc_meta->does_role('MooseX::NonMoose::Meta::Role::Constructor'), 'Foo::Moose gets its constructor from MooseX::NonMoose'); done_testing; MooseX-NonMoose-0.27/t/buggy-constructor-inlining.t000644 000000 000000 00000001153 14735654751 022343 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Moose; my ($Foo, $Bar, $Baz); { package Foo; sub new { $Foo++; bless {}, shift } } { package Bar; use Moose; use MooseX::NonMoose; extends 'Foo'; sub BUILD { $Bar++ } __PACKAGE__->meta->make_immutable; } { package Baz; use Moose; extends 'Bar'; sub BUILD { $Baz++ } } with_immutable { ($Foo, $Bar, $Baz) = (0, 0, 0); Baz->new; is($Foo, 1, "Foo->new is called once"); is($Bar, 1, "Bar->BUILD is called once"); is($Baz, 1, "Baz->BUILD is called once"); } 'Baz'; done_testing; MooseX-NonMoose-0.27/t/buggy-constructors.t000644 000000 000000 00000003364 14735654751 020727 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; use Test::Moose; { package Foo; sub new { bless {}, shift } } { package Foo::Sub; use Moose; use MooseX::NonMoose; extends 'Foo'; } with_immutable { my $foo; is(exception { $foo = Foo::Sub->new }, undef, "subclassing nonmoose classes with correct constructors works"); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Sub'); } 'Foo::Sub'; { package BadFoo; sub new { bless {} } ## no critic (ClassHierarchies::ProhibitOneArgBless) } { package BadFoo::Sub; use Moose; use MooseX::NonMoose; extends 'BadFoo'; } with_immutable { my $foo; is(exception { $foo = BadFoo::Sub->new }, undef, "subclassing nonmoose classes with incorrect constructors works"); isa_ok($foo, 'BadFoo'); isa_ok($foo, 'BadFoo::Sub'); } 'BadFoo::Sub'; { package BadFoo2; sub new { {} } } { package BadFoo2::Sub; use Moose; use MooseX::NonMoose; extends 'BadFoo2'; } with_immutable { my $foo; like(exception { $foo = BadFoo2::Sub->new; }, qr/\QThe constructor for BadFoo2 did not return a blessed instance/, "subclassing nonmoose classes with incorrect constructors dies properly"); } 'BadFoo2::Sub'; { package BadFoo3; sub new { bless {}, 'Something::Else::Entirely' } } { package BadFoo3::Sub; use Moose; use MooseX::NonMoose; extends 'BadFoo3'; } with_immutable { my $foo; like(exception { $foo = BadFoo3::Sub->new }, qr/\QThe constructor for BadFoo3 returned an object whose class is not a parent of BadFoo3::Sub/, "subclassing nonmoose classes with incorrect constructors dies properly"); } 'BadFoo3::Sub'; done_testing; MooseX-NonMoose-0.27/t/constructor-method-calls.t000644 000000 000000 00000001245 14735654751 021777 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Moose; my ($foo, $foosub); { package Foo; sub new { my $class = shift; my $obj = bless {}, $class; $obj->init; $obj; } sub init { $foo++ } } { package Foo::Sub; use base 'Foo'; sub init { $foosub++; shift->SUPER::init; } } { package Foo::Sub::Sub; use Moose; use MooseX::NonMoose; extends 'Foo::Sub'; } with_immutable { ($foo, $foosub) = (0, 0); Foo::Sub::Sub->new; is($foo, 1, "Foo::init called"); is($foosub, 1, "Foo::Sub::init called"); } 'Foo::Sub::Sub'; done_testing; MooseX-NonMoose-0.27/t/constructor-name.t000644 000000 000000 00000004216 14735654751 020344 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; use Test::Moose; { package Foo; sub create { my $class = shift; my %params = @_; bless { foo => ($params{foo} || 'FOO') }, $class; } sub foo { shift->{foo} } } { package Foo::Sub; use Moose; use MooseX::NonMoose; extends 'Foo' => { -constructor_name => 'create' }; has bar => ( is => 'ro', isa => 'Str', default => 'BAR', ); } with_immutable { my $foo = Foo::Sub->create; is($foo->foo, 'FOO', "nonmoose constructor called"); is($foo->bar, 'BAR', "moose constructor called"); } 'Foo::Sub'; { package Foo::BadSub; use Moose; use MooseX::NonMoose; ::like( ::exception { extends 'Foo' => { -constructor_name => 'something_else' }; }, qr/You specified 'something_else' as the constructor for Foo, but Foo has no method by that name/, "specifying an incorrect constructor name dies" ); } { package Foo::Mixin; sub thing { return shift->foo . 'BAZ'; } } { package Foo::Sub2; use Moose; use MooseX::NonMoose; extends 'Foo::Mixin', 'Foo' => { -constructor_name => 'create' }; has bar => ( is => 'ro', isa => 'Str', default => 'BAR', ); } with_immutable { my $foo = Foo::Sub2->create; is($foo->foo, 'FOO', "nonmoose constructor called"); is($foo->bar, 'BAR', "moose constructor called"); is($foo->thing, 'FOOBAZ', "mixin still works"); } 'Foo::Sub2'; { package Bar; sub make { my $class = shift; my %params = @_; bless { baz => ($params{baz} || 'BAZ') }, $class; } } { package Foo::Bar::Sub; use Moose; use MooseX::NonMoose; ::like( ::exception { extends 'Bar' => { -constructor_name => 'make' }, 'Foo' => { -constructor_name => 'create' }; }, qr/You have already specified Bar::make as the parent constructor; Foo::create cannot also be the constructor/, "can't specify two parent constructors" ); } done_testing; MooseX-NonMoose-0.27/t/destructor.t000644 000000 000000 00000000776 14735654751 017246 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Moose; my ($destroyed, $demolished); package Foo; sub new { bless {}, shift } sub DESTROY { $destroyed++ } package Foo::Sub; use Moose; use MooseX::NonMoose; extends 'Foo'; sub DEMOLISH { $demolished++ } package main; with_immutable { ($destroyed, $demolished) = (0, 0); { Foo::Sub->new } is($destroyed, 1, "non-Moose destructor called"); is($demolished, 1, "Moose destructor called"); } 'Foo::Sub'; done_testing; MooseX-NonMoose-0.27/t/disable.t000644 000000 000000 00000001467 14735654751 016451 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; sub new { my $class = shift; bless {}, $class; } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; package Foo::Moose2; use Moose; use MooseX::NonMoose; extends 'Foo'; package main; ok(Foo::Moose->meta->has_method('new'), 'Foo::Moose has a constructor'); my $method = Foo::Moose->meta->get_method('new'); Foo::Moose->meta->make_immutable; isnt($method, Foo::Moose->meta->get_method('new'), 'make_immutable replaced the constructor with an inlined version'); my $method2 = Foo::Moose2->meta->get_method('new'); Foo::Moose2->meta->make_immutable(inline_constructor => 0); is($method2, Foo::Moose2->meta->get_method('new'), 'make_immutable doesn\'t replace the constructor if we ask it not to'); done_testing; MooseX-NonMoose-0.27/t/extends-moose-object.t000644 000000 000000 00000000753 14735654751 021101 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; { package Foo; sub new { bless {}, shift } } { package Foo::Sub; use Moose; use MooseX::NonMoose; extends 'Foo'; } { package Bar; use Moose; } { package Bar::Sub; use Moose; use MooseX::NonMoose; extends 'Bar'; } is_deeply(\@Foo::Sub::ISA, ['Foo', 'Moose::Object'], "Moose::Object was added"); is_deeply(\@Bar::Sub::ISA, ['Bar'], "Moose::Object wasn't added"); done_testing; MooseX-NonMoose-0.27/t/extends-version.t000644 000000 000000 00000000626 14735654751 020177 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; { $INC{'Foo.pm'} = __FILE__; package Foo; our $VERSION = '0.02'; sub new { bless {}, shift } } { package Bar; use Moose; use MooseX::NonMoose; ::is(::exception { extends 'Foo' => { -version => '0.02' } }, undef, "specifying arguments to superclasses doesn't break"); } done_testing; MooseX-NonMoose-0.27/t/hashref-constructor.t000644 000000 000000 00000002132 14735654751 021037 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; { package Foo; sub new { my $class = shift; bless { ref($_[0]) ? %{$_[0]} : @_ }, $class; } sub foo { my $self = shift; $self->{foo}; } } { package Bar; use Moose; use MooseX::NonMoose; extends 'Foo'; has _bar => ( init_arg => 'bar', reader => 'bar', ); __PACKAGE__->meta->make_immutable; } { package Baz; use Moose; extends 'Bar'; has _baz => ( init_arg => 'baz', reader => 'baz', ); } { my $baz; is(exception { $baz = Baz->new( foo => 1, bar => 2, baz => 3 ) }, undef, "constructor lives"); is($baz->foo, 1, "foo set"); is($baz->bar, 2, "bar set"); is($baz->baz, 3, "baz set"); } { my $baz; is(exception { $baz = Baz->new({foo => 1, bar => 2, baz => 3}) }, undef, "constructor lives (hashref)"); is($baz->foo, 1, "foo set (hashref)"); is($baz->bar, 2, "bar set (hashref)"); is($baz->baz, 3, "baz set (hashref)"); } done_testing; MooseX-NonMoose-0.27/t/immutable.t000644 000000 000000 00000001535 14735654751 017021 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; sub new { my $class = shift; bless { @_ }, $class; } sub foo { my $self = shift; return $self->{foo} unless @_; $self->{foo} = shift; } sub baz { 'Foo' } sub quux { ref(shift) } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; has bar => ( is => 'rw', ); __PACKAGE__->meta->make_immutable; package main; my $foo_moose = Foo::Moose->new(foo => 'FOO', bar => 'BAR'); is($foo_moose->foo, 'FOO', 'foo set in constructor'); is($foo_moose->bar, 'BAR', 'bar set in constructor'); $foo_moose->foo('BAZ'); $foo_moose->bar('QUUX'); is($foo_moose->foo, 'BAZ', 'foo set by accessor'); is($foo_moose->bar, 'QUUX', 'bar set by accessor'); is($foo_moose->baz, 'Foo', 'baz method'); is($foo_moose->quux, 'Foo::Moose', 'quux method'); done_testing; MooseX-NonMoose-0.27/t/methods.t000644 000000 000000 00000000736 14735654751 016507 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; sub new { bless {}, shift } sub foo { 'Foo' } sub bar { 'Foo' } sub baz { ref(shift) } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; sub bar { 'Foo::Moose' } package main; my $foo_moose = Foo::Moose->new; is($foo_moose->foo, 'Foo', 'Foo::Moose->foo'); is($foo_moose->bar, 'Foo::Moose', 'Foo::Moose->bar'); is($foo_moose->baz, 'Foo::Moose', 'Foo::Moose->baz'); done_testing; MooseX-NonMoose-0.27/t/moose-exporter.t000644 000000 000000 00000004301 14735654751 020024 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; BEGIN { require Moose; package Foo::Exporter::Class; use Moose::Exporter; Moose::Exporter->setup_import_methods(also => ['Moose']); sub init_meta { shift; my %options = @_; Moose->init_meta(%options); Moose::Util::MetaRole::apply_metaroles( for => $options{for_class}, class_metaroles => { class => ['MooseX::NonMoose::Meta::Role::Class'], }, ); return Moose::Util::find_meta($options{for_class}); } package Foo::Exporter::ClassAndConstructor; use Moose::Exporter; Moose::Exporter->setup_import_methods(also => ['Moose']); sub init_meta { shift; my %options = @_; Moose->init_meta(%options); Moose::Util::MetaRole::apply_metaroles( for => $options{for_class}, class_metaroles => { class => ['MooseX::NonMoose::Meta::Role::Class'], constructor => ['MooseX::NonMoose::Meta::Role::Constructor'], }, ); return Moose::Util::find_meta($options{for_class}); } } package Foo; sub new { bless {}, shift } package Foo::Moose; BEGIN { Foo::Exporter::Class->import } extends 'Foo'; package Foo::Moose2; BEGIN { Foo::Exporter::ClassAndConstructor->import } extends 'Foo'; package main; ok(Foo::Moose->meta->has_method('new'), 'using only the metaclass trait still installs the constructor'); isa_ok(Foo::Moose->new, 'Moose::Object'); isa_ok(Foo::Moose->new, 'Foo'); my $method = Foo::Moose->meta->get_method('new'); Foo::Moose->meta->make_immutable; is(Foo::Moose->meta->get_method('new'), $method, 'inlining doesn\'t happen when the constructor trait isn\'t used'); ok(Foo::Moose2->meta->has_method('new'), 'using only the metaclass trait still installs the constructor'); isa_ok(Foo::Moose2->new, 'Moose::Object'); isa_ok(Foo::Moose2->new, 'Foo'); my $method2 = Foo::Moose2->meta->get_method('new'); Foo::Moose2->meta->make_immutable; isnt(Foo::Moose2->meta->get_method('new'), $method2, 'inlining does happen when the constructor trait is used'); done_testing; MooseX-NonMoose-0.27/t/moose.t000644 000000 000000 00000002444 14735654751 016164 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; use Moose; has foo => ( is => 'ro', default => 'FOO', ); package Foo::Sub; use Moose; use MooseX::NonMoose; extends 'Foo'; package main; my $foo_sub = Foo::Sub->new; isa_ok($foo_sub, 'Foo'); is($foo_sub->foo, 'FOO', 'inheritance works'); ok(!Foo::Sub->meta->has_method('new'), 'Foo::Sub doesn\'t have its own new method'); $_->meta->make_immutable for qw(Foo Foo::Sub); $foo_sub = Foo::Sub->new; isa_ok($foo_sub, 'Foo'); is($foo_sub->foo, 'FOO', 'inheritance works (immutable)'); ok(Foo::Sub->meta->has_method('new'), 'Foo::Sub has its own new method (immutable)'); package Foo::OtherSub; use Moose; use MooseX::NonMoose; extends 'Foo'; package main; my $foo_othersub = Foo::OtherSub->new; isa_ok($foo_othersub, 'Foo'); is($foo_othersub->foo, 'FOO', 'inheritance works (immutable when extending)'); ok(!Foo::OtherSub->meta->has_method('new'), 'Foo::OtherSub doesn\'t have its own new method (immutable when extending)'); Foo::OtherSub->meta->make_immutable; $foo_othersub = Foo::OtherSub->new; isa_ok($foo_othersub, 'Foo'); is($foo_othersub->foo, 'FOO', 'inheritance works (all immutable)'); ok(Foo::OtherSub->meta->has_method('new'), 'Foo::OtherSub has its own new method (all immutable)'); done_testing; MooseX-NonMoose-0.27/t/moosex-globref.t000644 000000 000000 00000004126 14735654751 017771 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Moose; use Test2::Require::Module 'MooseX::GlobRef'; use MooseX::GlobRef; # XXX: the way the IO modules are loaded means we can't just rely on cmop to # load these properly/: use IO::Handle; use IO::File; BEGIN { require Moose; package Foo::Exporter; use Moose::Exporter; Moose::Exporter->setup_import_methods(also => ['Moose']); sub init_meta { shift; my %options = @_; Moose->init_meta(%options); Moose::Util::MetaRole::apply_metaroles( for => $options{for_class}, class_metaroles => { class => ['MooseX::NonMoose::Meta::Role::Class'], constructor => ['MooseX::NonMoose::Meta::Role::Constructor'], instance => ['MooseX::GlobRef::Role::Meta::Instance'], }, ); return Moose::Util::find_meta($options{for_class}); } } package IO::Handle::Moose; BEGIN { Foo::Exporter->import } extends 'IO::Handle'; has bar => ( is => 'rw', isa => 'Str', ); sub FOREIGNBUILDARGS { return } package IO::File::Moose; BEGIN { Foo::Exporter->import } extends 'IO::File'; has baz => ( is => 'rw', isa => 'Str', ); sub FOREIGNBUILDARGS { return } package main; with_immutable { my $handle = IO::Handle::Moose->new(bar => 'BAR'); is($handle->bar, 'BAR', 'moose accessor works properly'); $handle->bar('RAB'); is($handle->bar, 'RAB', 'moose accessor works properly (setting)'); } 'IO::Handle::Moose'; with_immutable { SKIP: { my $fh = IO::File::Moose->new(baz => 'BAZ'); open $fh, "+>", undef or skip "couldn't open a temporary file", 3; is($fh->baz, 'BAZ', "accessor works"); $fh->baz('ZAB'); is($fh->baz, 'ZAB', "accessor works (writing)"); $fh->print("foo\n"); print $fh "bar\n"; $fh->seek(0, 0); my $buf; $fh->read($buf, 8); is($buf, "foo\nbar\n", "filehandle still works as normal"); } } 'IO::File::Moose'; done_testing; MooseX-NonMoose-0.27/t/moosex-insideout.t000644 000000 000000 00000003457 14735654751 020362 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Moose; use Test2::Require::Module 'MooseX::InsideOut', '0.100'; use MooseX::InsideOut; BEGIN { require Moose; package Foo::Exporter; use Moose::Exporter; Moose::Exporter->setup_import_methods(also => ['Moose']); sub init_meta { shift; my %options = @_; Moose->init_meta(%options); Moose::Util::MetaRole::apply_metaroles( for => $options{for_class}, class_metaroles => { class => ['MooseX::NonMoose::Meta::Role::Class'], constructor => ['MooseX::NonMoose::Meta::Role::Constructor'], instance => ['MooseX::InsideOut::Role::Meta::Instance'], }, ); return Moose::Util::find_meta($options{for_class}); } } package Foo; sub new { my $class = shift; bless [$_[0]], $class; } sub foo { my $self = shift; $self->[0] = shift if @_; $self->[0]; } package Foo::Moose; BEGIN { Foo::Exporter->import } extends 'Foo'; has bar => ( is => 'rw', isa => 'Str', ); sub BUILDARGS { my $self = shift; shift; return $self->SUPER::BUILDARGS(@_); } package Foo::Moose::Sub; use base 'Foo::Moose'; package main; with_immutable { my $foo = Foo::Moose->new('FOO', bar => 'BAR'); is($foo->foo, 'FOO', 'base class accessor works'); is($foo->bar, 'BAR', 'subclass accessor works'); $foo->foo('OOF'); $foo->bar('RAB'); is($foo->foo, 'OOF', 'base class accessor works (setting)'); is($foo->bar, 'RAB', 'subclass accessor works (setting)'); my $sub_foo = eval { Foo::Moose::Sub->new(FOO => bar => 'AHOY') }; is(eval { $sub_foo->bar }, 'AHOY', 'subclass constructor works'); } 'Foo::Moose'; done_testing; MooseX-NonMoose-0.27/t/multi-level.t000644 000000 000000 00000002617 14735654751 017303 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; sub new { my $class = shift; bless { foo => 'FOO' }, $class; } sub foo { shift->{foo} } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; has bar => ( is => 'ro', default => 'BAR', ); package Foo::Moose::Sub; use Moose; extends 'Foo::Moose'; has baz => ( is => 'ro', default => 'BAZ', ); package main; my $foo_moose = Foo::Moose->new; is($foo_moose->foo, 'FOO', 'Foo::Moose::foo'); is($foo_moose->bar, 'BAR', 'Foo::Moose::bar'); isnt(Foo::Moose->meta->get_method('new'), undef, 'Foo::Moose gets its own constructor'); my $foo_moose_sub = Foo::Moose::Sub->new; is($foo_moose_sub->foo, 'FOO', 'Foo::Moose::Sub::foo'); is($foo_moose_sub->bar, 'BAR', 'Foo::Moose::Sub::bar'); is($foo_moose_sub->baz, 'BAZ', 'Foo::Moose::Sub::baz'); is(Foo::Moose::Sub->meta->get_method('new'), undef, 'Foo::Moose::Sub just uses the constructor for Foo::Moose'); Foo::Moose->meta->make_immutable; Foo::Moose::Sub->meta->make_immutable; $foo_moose_sub = Foo::Moose::Sub->new; is($foo_moose_sub->foo, 'FOO', 'Foo::Moose::Sub::foo (immutable)'); is($foo_moose_sub->bar, 'BAR', 'Foo::Moose::Sub::bar (immutable)'); is($foo_moose_sub->baz, 'BAZ', 'Foo::Moose::Sub::baz (immutable)'); isnt(Foo::Moose::Sub->meta->get_method('new'), undef, 'Foo::Moose::Sub has an inlined constructor'); done_testing; MooseX-NonMoose-0.27/t/no-new-constructor-error.t000644 000000 000000 00000001713 14735654751 021755 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; { package NonMoose; sub create { bless {}, shift } sub DESTROY { } } { package Child; use Moose; use MooseX::NonMoose; extends 'NonMoose'; { my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; __PACKAGE__->meta->make_immutable; ::like( $warning, qr/Not inlining.*doesn't contain a constructor named 'new'/, "warning when trying to make_immutable without a superclass 'new'" ); } } { package ChildTwo; use Moose; use MooseX::NonMoose; extends 'NonMoose'; { my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; __PACKAGE__->meta->make_immutable(inline_constructor => 0); ::is($warning, undef, "no warning when trying to make_immutable(inline_constructor => 0) without a superclass 'new'"); } } done_testing; MooseX-NonMoose-0.27/t/nonmoose-moose-nonmoose.t000644 000000 000000 00000003577 14735654751 021662 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Moose; package Foo; sub new { my $class = shift; bless {@_}, $class; } sub foo { shift->{name} } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; has foo2 => ( is => 'rw', isa => 'Str', ); package Foo::Moose::Sub; use base 'Foo::Moose'; package Bar; sub new { my $class = shift; bless {name => $_[0]}, $class; } sub bar { shift->{name} } package Bar::Moose; use Moose; use MooseX::NonMoose; extends 'Bar'; has bar2 => ( is => 'rw', isa => 'Str', ); sub FOREIGNBUILDARGS { my $class = shift; my %args = @_; return $args{name}; } package Bar::Moose::Sub; use base 'Bar::Moose'; package main; with_immutable { my $foo = Foo::Moose::Sub->new(name => 'foomoosesub', foo2 => 'FOO2'); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Moose'); is($foo->foo, 'foomoosesub', 'got name from nonmoose constructor'); is($foo->foo2, 'FOO2', 'got attribute value from moose constructor'); $foo = Foo::Moose->new(name => 'foomoosesub', foo2 => 'FOO2'); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Moose'); is($foo->foo, 'foomoosesub', 'got name from nonmoose constructor'); is($foo->foo2, 'FOO2', 'got attribute value from moose constructor'); } 'Foo::Moose'; with_immutable { my $bar = Bar::Moose::Sub->new(name => 'barmoosesub', bar2 => 'BAR2'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Bar::Moose'); is($bar->bar, 'barmoosesub', 'got name from nonmoose constructor'); is($bar->bar2, 'BAR2', 'got attribute value from moose constructor'); $bar = Bar::Moose->new(name => 'barmoosesub', bar2 => 'BAR2'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Bar::Moose'); is($bar->bar, 'barmoosesub', 'got name from nonmoose constructor'); is($bar->bar2, 'BAR2', 'got attribute value from moose constructor'); } 'Bar::Moose'; done_testing; MooseX-NonMoose-0.27/t/only-metaclass-trait.t000644 000000 000000 00000001152 14735654751 021111 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; sub new { bless {}, shift } package Foo::Moose; use Moose -traits => 'MooseX::NonMoose::Meta::Role::Class'; extends 'Foo'; package main; ok(Foo::Moose->meta->has_method('new'), 'using only the metaclass trait still installs the constructor'); isa_ok(Foo::Moose->new, 'Moose::Object'); isa_ok(Foo::Moose->new, 'Foo'); my $method = Foo::Moose->meta->get_method('new'); Foo::Moose->meta->make_immutable; is(Foo::Moose->meta->get_method('new'), $method, 'inlining doesn\'t happen when the constructor trait isn\'t used'); done_testing; MooseX-NonMoose-0.27/t/reinitialize.t000644 000000 000000 00000001075 14735654751 017531 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; { package Foo; sub new { bless {}, shift } } { package Foo::Meta::Role; use Moose::Role; } { package Foo::Sub; use Moose; use MooseX::NonMoose; extends 'Foo'; Moose::Util::MetaRole::apply_metaroles( for => __PACKAGE__, class_metaroles => { class => ['Foo::Meta::Role'], }, ); ::is(::exception { __PACKAGE__->meta->make_immutable }, undef, "can make_immutable after reinitialization"); } done_testing; MooseX-NonMoose-0.27/t/replaced-constructor.t000644 000000 000000 00000003160 14735654751 021200 0ustar00rootroot000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; our $foo_constructed = 0; package Foo; sub new { my $class = shift; bless {}, $class; } package Foo::Moose; use Moose; use MooseX::NonMoose; extends 'Foo'; after new => sub { $main::foo_constructed = 1; }; package Foo::Moose2; use Moose; use MooseX::NonMoose; extends 'Foo'; sub new { my $class = shift; $main::foo_constructed = 1; return $class->meta->new_object(@_); } package main; my $method = Foo::Moose->meta->get_method('new'); isa_ok($method, 'Class::MOP::Method::Wrapped'); my $foo = Foo::Moose->new; ok($foo_constructed, 'method modifier called for the constructor'); $foo_constructed = 0; { # we don't care about the warning that moose isn't going to inline our # constructor - this is the behavior we're testing local $SIG{__WARN__} = sub {}; Foo::Moose->meta->make_immutable; } is($method, Foo::Moose->meta->get_method('new'), 'make_immutable doesn\'t overwrite constructor with method modifiers'); $foo = Foo::Moose->new; ok($foo_constructed, 'method modifier called for the constructor (immutable)'); $foo_constructed = 0; $method = Foo::Moose2->meta->get_method('new'); $foo = Foo::Moose2->new; ok($foo_constructed, 'custom constructor called'); $foo_constructed = 0; # still need to specify inline_constructor => 0 when overriding new manually Foo::Moose2->meta->make_immutable(inline_constructor => 0); is($method, Foo::Moose2->meta->get_method('new'), 'make_immutable doesn\'t overwrite custom constructor'); $foo = Foo::Moose2->new; ok($foo_constructed, 'custom constructor called (immutable)'); done_testing; MooseX-NonMoose-0.27/xt/000755 000000 000000 00000000000 14735654751 015041 5ustar00rootroot000000 000000 MooseX-NonMoose-0.27/xt/author/000755 000000 000000 00000000000 14735654751 016343 5ustar00rootroot000000 000000 MooseX-NonMoose-0.27/xt/author/critic.t000644 000000 000000 00000000516 14735654751 020007 0ustar00rootroot000000 000000 use Test2::Require::Module 'Test2::Tools::PerlCritic'; use Test2::Require::Module 'Perl::Critic'; use Test2::Require::Module 'Perl::Critic::Community'; use Test2::V0; use Perl::Critic; use Test2::Tools::PerlCritic; my $critic = Perl::Critic->new( -profile => 'perlcriticrc', ); perl_critic_ok ['lib','t'], $critic; done_testing; MooseX-NonMoose-0.27/xt/author/eol.t000644 000000 000000 00000000510 14735654751 017303 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::EOL' unless eval q{ use Test::EOL; 1 }; }; use Test::EOL; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); all_perl_files_ok(grep { -e $_ } qw( bin lib t Makefile.PL )); MooseX-NonMoose-0.27/xt/author/no_tabs.t000644 000000 000000 00000000522 14735654751 020154 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::NoTabs' unless eval q{ use Test::NoTabs; 1 }; }; use Test::NoTabs; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); all_perl_files_ok( grep { -e $_ } qw( bin lib t Makefile.PL )); MooseX-NonMoose-0.27/xt/author/pod.t000644 000000 000000 00000000472 14735654751 017315 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Pod' unless eval q{ use Test::Pod; 1 }; }; use Test::Pod; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); all_pod_files_ok( grep { -e $_ } qw( bin lib )); MooseX-NonMoose-0.27/xt/author/pod_coverage.t000644 000000 000000 00000004001 14735654751 021160 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires 5.010 or better' unless $] >= 5.010; plan skip_all => 'test requires Test::Pod::Coverage' unless eval q{ use Test::Pod::Coverage; 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML; 1; }; plan skip_all => 'test does not always work in cip check' if defined $ENV{CIPSTATIC} && $ENV{CIPSTATIC} eq 'true'; }; use Test::Pod::Coverage; use YAML qw( LoadFile ); use FindBin; use File::Spec; my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; plan skip_all => 'disabled' if $config->{pod_coverage}->{skip}; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); my @private_classes; my %private_methods; push $config->{pod_coverage}->{private}->@*, 'Alien::.*::Install::Files#Inline'; foreach my $private ($config->{pod_coverage}->{private}->@*) { my($class,$method) = split /#/, $private; if(defined $class && $class ne '') { my $regex = eval 'qr{^' . $class . '$}'; if(defined $method && $method ne '') { push @private_classes, { regex => $regex, method => $method }; } else { push @private_classes, { regex => $regex, all => 1 }; } } elsif(defined $method && $method ne '') { $private_methods{$_} = 1 for split /,/, $method; } } my @classes = all_modules; plan tests => scalar @classes; foreach my $class (@classes) { SKIP: { my($is_private_class) = map { 1 } grep { $class =~ $_->{regex} && $_->{all} } @private_classes; skip "private class: $class", 1 if $is_private_class; my %methods = map {; $_ => 1 } map { split /,/, $_->{method} } grep { $class =~ $_->{regex} } @private_classes; $methods{$_} = 1 for keys %private_methods; my $also_private = eval 'qr{^' . join('|', keys %methods ) . '$}'; pod_coverage_ok $class, { also_private => [$also_private] }; }; } MooseX-NonMoose-0.27/xt/author/pod_spelling_common.t000644 000000 000000 00000001350 14735654751 022556 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Pod::Spelling::CommonMistakes' unless eval q{ use Test::Pod::Spelling::CommonMistakes; 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML qw( LoadFile ); 1 }; }; use Test::Pod::Spelling::CommonMistakes; use FindBin; use File::Spec; my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; plan skip_all => 'disabled' if $config->{pod_spelling_common}->{skip}; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); # TODO: test files in bin too. all_pod_files_ok; MooseX-NonMoose-0.27/xt/author/version.t000644 000000 000000 00000001473 14735654751 020222 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; use FindBin (); BEGIN { plan skip_all => "test requires Test::Version 2.00" unless eval q{ use Test::Version 2.00 qw( version_all_ok ), { has_version => 1, filename_match => sub { $_[0] !~ m{/(ConfigData|Install/Files)\.pm$} }, }; 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML; 1; }; } use YAML qw( LoadFile ); use FindBin; use File::Spec; my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; if($config->{version}->{dir}) { note "using dir " . $config->{version}->{dir} } version_all_ok($config->{version}->{dir} ? ($config->{version}->{dir}) : ()); done_testing; MooseX-NonMoose-0.27/xt/release/000755 000000 000000 00000000000 14735654751 016461 5ustar00rootroot000000 000000 MooseX-NonMoose-0.27/xt/release/changes.t000644 000000 000000 00000001113 14735654751 020252 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::CPAN::Changes' unless eval q{ use Test::CPAN::Changes; 1 }; }; use Test::CPAN::Changes; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); do { my $old = \&Test::Builder::carp; my $new = sub { my($self, @messages) = @_; return if $messages[0] =~ /^Date ".*" is not in the recommend format/; $old->($self, @messages); }; no warnings 'redefine'; *Test::Builder::carp = $new; }; changes_file_ok; done_testing; MooseX-NonMoose-0.27/xt/release/fixme.t000644 000000 000000 00000000616 14735654751 017761 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Fixme' unless eval q{ use Test::Fixme 0.14; 1 }; }; use Test::Fixme 0.07; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); run_tests( match => qr/FIXME/, where => [ grep { -e $_ } qw( bin lib t Makefile.PL Build.PL )], warn => 1, );