Build.PL100644000765000024 352312321613075 14751 0ustar00gfxstaff000000000000MouseX-Foreign-1.000# ========================================================================= # THIS FILE IS AUTOMATICALLY GENERATED BY MINILLA. # DO NOT EDIT DIRECTLY. # ========================================================================= use 5.008_001; use strict; use warnings; use utf8; use Module::Build; use File::Basename; use File::Spec; use CPAN::Meta; use CPAN::Meta::Prereqs; my %args = ( license => 'perl', dynamic_config => 0, configure_requires => { 'Module::Build' => 0.38, }, name => 'MouseX-Foreign', module_name => 'MouseX::Foreign', allow_pureperl => 0, script_files => [glob('script/*'), glob('bin/*')], c_source => [qw()], PL_files => {}, test_files => ((-d '.git' || $ENV{RELEASE_TESTING}) && -d 'xt') ? 't/ xt/' : 't/', recursive_test_files => 1, ); if (-d 'share') { $args{share_dir} = 'share'; } my $builder = Module::Build->subclass( class => 'MyBuilder', code => q{ sub ACTION_distmeta { die "Do not run distmeta. Install Minilla and `minil install` instead.\n"; } sub ACTION_installdeps { die "Do not run installdeps. Run `cpanm --installdeps .` instead.\n"; } } )->new(%args); $builder->create_build_script(); my $mbmeta = CPAN::Meta->load_file('MYMETA.json'); my $meta = CPAN::Meta->load_file('META.json'); my $prereqs_hash = CPAN::Meta::Prereqs->new( $meta->prereqs )->with_merged_prereqs( CPAN::Meta::Prereqs->new($mbmeta->prereqs) )->as_string_hash; my $mymeta = CPAN::Meta->new( { %{$meta->as_struct}, prereqs => $prereqs_hash } ); print "Merging cpanfile prereqs to MYMETA.yml\n"; $mymeta->save('MYMETA.yml', { version => 1.4 }); print "Merging cpanfile prereqs to MYMETA.json\n"; $mymeta->save('MYMETA.json', { version => 2 }); Changes100644000765000024 204212321613075 14743 0ustar00gfxstaff000000000000MouseX-Foreign-1.000Revision history for Perl extension MouseX::Foreign 1.000 2014-04-10T22:07:50Z [CHANGES] - BUILDARGS is now called before constructors (#4 by schwern) See https://github.com/gfx/p5-MouseX-Foreign/pull/4 for details 0.008 2014-02-11 23:08:12+0900 - Make Any::Moose test_requires; thanks to @acidlemon 0.007 2011-10-17 18:57:02 - Declare Any::Moose version (rsimoes) - Fix duplicated code in meta methods (rsimoes) 0.006 2011-10-13 10:47:07 - Add MouseX::NonMoose for drop-in compatibility with Any::Moose - Add test files for new module 0.005 2011-10-13 09:40:21 - No code changes - Fix module name in README, .gitignore, xt/podspell.t and Changes (this file) 0.004 2011-03-27 16:16:43 - Missing dependencies: Test::Exception 0.003 Wed Sep 29 23:24:01 2010 - Classes that use MouseX::Foreign were not treated as foreign classes. 0.002 Sun Sep 26 13:44:40 2010 - No code changes - Fix packaging issues 0.001 - original version; created by Module::Setup at Fri Feb 26 22:24:38 2010. LICENSE100644000765000024 4376212321613075 14513 0ustar00gfxstaff000000000000MouseX-Foreign-1.000This software is copyright (c) 2014 by Fuji, Goro (gfx) . 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) 2014 by Fuji, Goro (gfx) . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2014 by Fuji, Goro (gfx) . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End META.json100644000765000024 571212321613075 15100 0ustar00gfxstaff000000000000MouseX-Foreign-1.000{ "abstract" : "Extends non-Mouse classes as well as Mouse classes", "author" : [ "Fuji, Goro (gfx) " ], "dynamic_config" : 0, "generated_by" : "Minilla/v0.14.1", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "MouseX-Foreign", "no_index" : { "directory" : [ "t", "xt", "inc", "share", "eg", "examples", "author", "builder" ] }, "prereqs" : { "build" : { "requires" : { "Any::Moose" : "0.15", "Test::Exception" : "0", "Test::More" : "0.88", "Test::Requires" : "0" } }, "configure" : { "requires" : { "CPAN::Meta" : "0", "CPAN::Meta::Prereqs" : "0", "Module::Build" : "0.38" } }, "develop" : { "requires" : { "Test::CPAN::Meta" : "0", "Test::MinimumVersion::Fast" : "0.04", "Test::PAUSE::Permissions" : "0.04", "Test::Pod" : "1.41", "Test::Spellunker" : "v0.2.7" } }, "runtime" : { "requires" : { "Mouse" : "0.77", "perl" : "5.008001" } } }, "provides" : { "MouseX::Foreign" : { "file" : "lib/MouseX/Foreign.pm", "version" : "1.000" }, "MouseX::Foreign::Meta::Role::Class" : { "file" : "lib/MouseX/Foreign/Meta/Role/Class.pm" }, "MouseX::Foreign::Meta::Role::Method::Constructor" : { "file" : "lib/MouseX/Foreign/Meta/Role/Method/Constructor.pm" }, "MouseX::Foreign::Meta::Role::Method::Destructor" : { "file" : "lib/MouseX/Foreign/Meta/Role/Method/Destructor.pm" }, "MouseX::NonMoose" : { "file" : "lib/MouseX/NonMoose.pm", "version" : "1.000" }, "MouseX::NonMoose::Meta::Role::Class" : { "file" : "lib/MouseX/NonMoose/Meta/Role/Class.pm" }, "MouseX::NonMoose::Meta::Role::Method::Constructor" : { "file" : "lib/MouseX/NonMoose/Meta/Role/Method/Constructor.pm" }, "MouseX::NonMoose::Meta::Role::Method::Destructor" : { "file" : "lib/MouseX/NonMoose/Meta/Role/Method/Destructor.pm" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/gfx/p5-MouseX-Foreign/issues" }, "homepage" : "https://github.com/gfx/p5-MouseX-Foreign", "repository" : { "url" : "git://github.com/gfx/p5-MouseX-Foreign.git", "web" : "https://github.com/gfx/p5-MouseX-Foreign" } }, "version" : "1.000", "x_contributors" : [ "Richard Simões ", "Fuji Goro ", "Michael G. Schwern ", "Fuji, Goro (gfx) " ] } README.md100644000765000024 226212321613075 14733 0ustar00gfxstaff000000000000MouseX-Foreign-1.000# NAME MouseX::Foreign - Extends non-Mouse classes as well as Mouse classes # VERSION This document describes MouseX::Foreign version 1.000. # SYNOPSIS package MyInt; use Mouse; use MouseX::Foreign qw(Math::BigInt); has name => ( is => 'ro', isa => 'Str', ); # DESCRIPTION MouseX::Foreign provides an ability for Mouse classes to extend any classes, including non-Mouse classes, including Moose classes. # DEPENDENCIES Perl 5.8.1 or later. # BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. # ACKNOWLEDGEMENT This is a Mouse port of MooseX::NonMoose, although the name is different. # SEE ALSO [Mouse](https://metacpan.org/pod/Mouse) [Moose](https://metacpan.org/pod/Moose) [MooseX::NonMoose](https://metacpan.org/pod/MooseX::NonMoose) [MooseX::Alien](https://metacpan.org/pod/MooseX::Alien) # AUTHOR Fuji, Goro (gfx) # LICENSE AND COPYRIGHT Copyright (c) 2010, Fuji, Goro (gfx). All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. cpanfile100644000765000024 32212321613075 15133 0ustar00gfxstaff000000000000MouseX-Foreign-1.000requires 'Mouse', '0.77'; requires 'perl', '5.008001'; on build => sub { requires 'Any::Moose', '0.15'; requires 'Test::Exception'; requires 'Test::More', '0.88'; requires 'Test::Requires'; }; Foreign.pm100644000765000024 330712321613075 17372 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/lib/MouseXpackage MouseX::Foreign; use 5.008_001; use Mouse::Util; # turns on strict and warnings our $VERSION = '1.000'; use Mouse::Util::MetaRole; use Carp (); sub import { shift; my $caller = caller; if(!$caller->can('meta')){ Carp::croak( "$caller does not have the meta method" . " (did you use Mouse for $caller?)"); } Mouse::Util::MetaRole::apply_metaroles( for => $caller, class_metaroles => { class => ['MouseX::Foreign::Meta::Role::Class'], }, ); $caller->meta->superclasses(@_) if @_; return; } 1; __END__ =head1 NAME MouseX::Foreign - Extends non-Mouse classes as well as Mouse classes =head1 VERSION This document describes MouseX::Foreign version 1.000. =head1 SYNOPSIS package MyInt; use Mouse; use MouseX::Foreign qw(Math::BigInt); has name => ( is => 'ro', isa => 'Str', ); =head1 DESCRIPTION MouseX::Foreign provides an ability for Mouse classes to extend any classes, including non-Mouse classes, including Moose classes. =head1 DEPENDENCIES Perl 5.8.1 or later. =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 ACKNOWLEDGEMENT This is a Mouse port of MooseX::NonMoose, although the name is different. =head1 SEE ALSO L L L L =head1 AUTHOR Fuji, Goro (gfx) Egfuji(at)cpan.orgE =head1 LICENSE AND COPYRIGHT Copyright (c) 2010, Fuji, Goro (gfx). All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Class.pm100644000765000024 344512321613075 22231 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/lib/MouseX/Foreign/Meta/Rolepackage MouseX::Foreign::Meta::Role::Class; use Mouse::Role; use Mouse::Util::MetaRole; __PACKAGE__->meta->add_metaclass_accessor('foreign_superclass'); after superclasses => sub { my($self, @args) = @_; if(@args && !$self->name->isa('Mouse::Object')) { push @{$self->{superclasses}}, 'Mouse::Object'; } return; }; before verify_superclass => sub { my($self, $super, $super_meta) = @_; if(defined($super_meta) && $super_meta->does(__PACKAGE__)) { $self->inherit_from_foreign_class($super); } return; }; sub inherit_from_foreign_class { # override my($self, $super) = @_; if(defined $self->foreign_superclass) { $self->throw_error( "Multiple inheritance" . " from foreign classes ($super, " . $self->foreign_superclass . ") is forbidden"); } my %traits; if($super->can('new')) { $traits{constructor} = ['MouseX::Foreign::Meta::Role::Method::Constructor']; } if($super->can('DESTROY')) { $traits{destructor} = ['MouseX::Foreign::Meta::Role::Method::Destructor']; } if(%traits) { $self->foreign_superclass($super); $_[0] = $self = Mouse::Util::MetaRole::apply_metaroles( for => $self, class_metaroles => \%traits, ); # FIXME $self->add_method( new => $self->constructor_class->_generate_constructor($self), ); $self->add_method( DESTROY => $self->destructor_class->_generate_destructor($self), ); } return; } no Mouse::Role; 1; __END__ =head1 NAME MouseX::Foreign::Meta::Role::Class - The MouseX::Foreign meta class role =head1 DESCRIPTION This is the meta class role for MouseX::Foreign. =head1 SEE ALSO L =cut Constructor.pm100644000765000024 216312321613075 24725 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/lib/MouseX/Foreign/Meta/Role/Methodpackage MouseX::Foreign::Meta::Role::Method::Constructor; use Mouse::Role; around _generate_constructor => sub { my($next, undef, $meta, $option) = @_; # The foreign superlcass must have the new method my $foreign_buildargs = $meta->name->can('FOREIGNBUILDARGS'); my $foreign_superclass = $meta->foreign_superclass; my $super_new = $foreign_superclass->can('new'); my $needs_buildall = !$foreign_superclass->can('BUILDALL'); return sub { my $class = shift; my $args = $class->BUILDARGS(@_); my $object = $foreign_buildargs ? $class->$super_new($class->$foreign_buildargs(@_)) : $class->$super_new( @_ ); $object->meta->_initialize_object($object, $args); $object->BUILDALL($args) if $needs_buildall; return $object; }; }; no Mouse::Role; 1; __END__ =head1 NAME MouseX::Foreign::Meta::Role::Method::Constructor - The MouseX::Foreign meta method constructor role =head1 DESCRIPTION This is the meta method constructor role for MouseX::Foreign. =head1 SEE ALSO L =cut Destructor.pm100644000765000024 154112321613075 24535 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/lib/MouseX/Foreign/Meta/Role/Methodpackage MouseX::Foreign::Meta::Role::Method::Destructor; use Mouse::Role; around _generate_destructor => sub { my($next, undef, $meta) = @_; my $foreign_superclass = $meta->foreign_superclass; my $super_destroy; if(!$foreign_superclass->can('DEMOLISHALL')){ $super_destroy = $foreign_superclass->can('DESTROY'); } return sub { my($self) = @_; $self->DEMOLISHALL(); if(defined $super_destroy) { $self->$super_destroy(); } return; }; }; no Mouse::Role; 1; __END__ =head1 NAME MouseX::Foreign::Meta::Role::Method::Destructor - The MouseX::Foreign meta method destructor role =head1 VERSION This document describes MouseX::Foreign version 1.000. =head1 DESCRIPTION This is the meta method destructor role for MouseX::Foreign. =head1 SEE ALSO L =cut NonMoose.pm100644000765000024 154212321613075 17535 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/lib/MouseXpackage MouseX::NonMoose; use Mouse; extends 'MouseX::Foreign'; our $VERSION = '1.000'; 1; __END__ =head1 NAME MouseX::NonMoose - MouseX::Foreign plus drop-in compatibility with Any::Moose =head1 VERSION This document describes MouseX::Foreign version 1.000. =head1 SYNOPSIS package MyInt; use Any::Moose; use Any::Moose 'X::NonMoose'; extends 'Math::BigInt'; has name => ( is => 'ro', isa => 'Str', ); =head1 DESCRIPTION MouseX::NonMoose is a thin wrapper around L, so as to be used with L and L; =head1 AUTHOR Fuji, Goro (gfx) Egfuji(at)cpan.orgE =head1 LICENSE AND COPYRIGHT Copyright (c) 2011, Fuji, Goro (gfx). All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Class.pm100644000765000024 21212321613075 22342 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/lib/MouseX/NonMoose/Meta/Rolepackage MouseX::NonMoose::Meta::Role::Class; use Mouse::Role; use Mouse::Util::MetaRole; with 'MouseX::Foreign::Meta::Role::Class'; 1; Constructor.pm100644000765000024 23412321613075 25046 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/lib/MouseX/NonMoose/Meta/Role/Methodpackage MouseX::NonMoose::Meta::Role::Method::Constructor; use Mouse::Role; with 'MouseX::Foreign::Meta::Role::Method::Constructor'; no Mouse::Role; 1; Destructor.pm100644000765000024 23212321613075 24655 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/lib/MouseX/NonMoose/Meta/Role/Methodpackage MouseX::NonMoose::Meta::Role::Method::Destructor; use Mouse::Role; with 'MouseX::Foreign::Meta::Role::Method::Destructor'; no Mouse::Role; 1; 00_load.t100644000765000024 22512321613075 15277 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t#!perl -w use strict; use Test::More tests => 1; BEGIN { require_ok 'MouseX::Foreign' } diag "Testing MouseX::Foreign/$MouseX::Foreign::VERSION"; 01_basic.t100644000765000024 170612321613075 15467 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t#!perl -w use strict; use Test::More; use Test::Exception; use Test::Mouse; my $person_destroyed = 0; my $myperson_built = 0; BEGIN{ package Person; use Class::Struct; struct Person => { name => '$', age => '$', }; sub DESTROY { $person_destroyed++ } } { package MyPerson; use Mouse; use MouseX::Foreign qw(Person); has handle_name => ( is => 'rw', isa => 'Str', ); sub BUILD { $myperson_built++ } } with_immutable { my $p = MyPerson->new(name => 'Goro Fuji', age => 27, handle_name => 'gfx'); isa_ok $p, 'MyPerson'; isa_ok $p, 'Person'; is $p->name, 'Goro Fuji', 'from the base class'; is $p->age, 27, 'from the base class'; is $p->handle_name, 'gfx', 'from the derived class'; } qw(MyPerson); is $person_destroyed, 2, "the base class's destructor is called"; is $myperson_built, 2, 'BUILD is called'; done_testing; 02_moose.t100644000765000024 236312321613075 15531 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t#!perl -w use strict; use Test::Requires qw(Moose); use Test::More; use Test::Exception; use Test::Mouse; my $person_build = 0; my $person_demolish = 0; my $myperson_build = 0; my $myperson_demolish = 0; BEGIN{ package Person; use Moose; has name => (is => 'rw'); has age => (is => 'rw'); sub BUILD { $person_build++ } sub DEMOLISH { $person_demolish++ } __PACKAGE__->meta->make_immutable(); } { package MyPerson; use Mouse; use MouseX::Foreign qw(Person); has handle_name => ( is => 'rw', isa => 'Str', ); sub BUILD { $myperson_build++ } sub DEMOLISH { $myperson_demolish++ } } with_immutable { my $p = MyPerson->new(name => 'Goro Fuji', age => 27, handle_name => 'gfx'); isa_ok $p, 'MyPerson'; isa_ok $p, 'Person'; is $p->name, 'Goro Fuji', 'from the base class'; is $p->age, 27, 'from the base class'; is $p->handle_name, 'gfx', 'from the derived class'; } qw(MyPerson); is $person_build, 2, "the base class's BUILD is colled"; is $person_demolish, 2, "the base class's DEMOLISH is called"; is $myperson_build, 2, 'my BUILD is called'; is $myperson_demolish, 2, 'my DEMOLISH is called'; done_testing; 03_mybigint.t100644000765000024 217212321613075 16230 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t#!perl -w use strict; use Test::More; use Test::Exception; use Test::Mouse; my $built = 0; my $demolished = 0; { package MyBigInt; use Mouse; use MouseX::Foreign; extends qw(Math::BigInt); has name => ( is => 'rw', isa => 'Str', default => 'default name', ); sub FOREIGNBUILDARGS { my($class, $value) = @_; return $value; } sub BUILDARGS { my $class = shift; shift; # value return $class->SUPER::BUILDARGS(@_); } sub BUILD { $built++ } sub DEMOLISH{ $demolished++ } package MyBigInt2; use Mouse; extends qw(MyBigInt); } with_immutable { my $i = MyBigInt->new(100, { name => 'foo' }); isa_ok $i, 'Math::BigInt', isa_ok $i, 'MyBigInt'; is $i, 100; is $i->name, 'foo'; } qw(MyBigInt); is $built, 2; is $demolished, 2; $built = 0; $demolished = 0; with_immutable { my $i = MyBigInt2->new(42); isa_ok $i, 'Math::BigInt', isa_ok $i, 'MyBigInt'; is $i, 42; is $i->name, 'default name'; } qw(MyBigInt2); is $built, 2; is $demolished, 2; done_testing; 04_multpile.t100644000765000024 105312321613075 16237 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t#!perl -w use strict; use Test::More; { package Foo; sub new { bless {}, shift } } { package Bar; sub new { bless {}, shift } } package Baz; use Mouse; use MouseX::Foreign; eval { extends qw(Foo Bar) }; ::like $@, qr/Multiple inheritance from foreign classes /; package XFoo; use Mouse; use MouseX::Foreign qw(Foo); package XBar; use Mouse; use MouseX::Foreign qw(Bar); package Qux; use Mouse; use MouseX::Foreign; eval { extends qw(XFoo XBar) }; ::like $@, qr/Multiple inheritance from foreign classes /; package main; done_testing; 05_bless_new_args.t100644000765000024 71612321613075 17367 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t#!perl -w use strict; use Test::More; # A certain style of hand written constructor might bless its # arguments. Test we don't choke because the arguments are apparently # not a hash. { package Bless::Args; sub new { my($class, $args) = @_; $args ||= {}; return bless $args, $class; } } { package Foo; use Mouse; use MouseX::Foreign; extends 'Bless::Args'; } new_ok 'Foo', [{ foo => 23 }]; done_testing; 001-basic.t100644000765000024 133412321613075 20655 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; sub new { my $class = shift; bless { _class => $class }, $class; } package Foo::Mouse; use Mouse; use MouseX::Foreign qw(Foo); package main; my $foo = Foo->new; my $foo_moose = Foo::Mouse->new; isa_ok($foo, 'Foo'); is($foo->{_class}, 'Foo', 'Foo gets the correct class'); isa_ok($foo_moose, 'Foo::Mouse'); isa_ok($foo_moose, 'Foo'); isa_ok($foo_moose, 'Mouse::Object'); is($foo_moose->{_class}, 'Foo::Mouse', 'Foo::Mouse gets the correct class'); my $meta = Foo::Mouse->meta; ok($meta->has_method('new'), 'Foo::Mouse has its own constructor'); my $cc_meta = $meta->constructor_class->meta; isa_ok($cc_meta, 'Mouse::Meta::Class'); done_testing; 002-methods.t100644000765000024 73112321613075 21220 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 3; package Foo; sub new { bless {}, shift } sub foo { 'Foo' } sub bar { 'Foo' } sub baz { ref(shift) } package Foo::Mouse; use Mouse; use MouseX::Foreign; extends 'Foo'; sub bar { 'Foo::Mouse' } package main; my $foo_moose = Foo::Mouse->new; is($foo_moose->foo, 'Foo', 'Foo::Mouse->foo'); is($foo_moose->bar, 'Foo::Mouse', 'Foo::Mouse->bar'); is($foo_moose->baz, 'Foo::Mouse', 'Foo::Mouse->baz'); 003-attrs.t100644000765000024 125312321613075 20733 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 4; package Foo; sub new { my $class = shift; bless { @_ }, $class; } sub foo { my $self = shift; return $self->{foo} unless @_; $self->{foo} = shift; } package Foo::Mouse; use Mouse; use MouseX::Foreign; extends 'Foo'; has bar => ( is => 'rw', ); package main; my $foo_moose = Foo::Mouse->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'); 004-multi-level.t100644000765000024 261412321613075 22040 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 11; package Foo; sub new { my $class = shift; bless { foo => 'FOO' }, $class; } sub foo { shift->{foo} } package Foo::Mouse; use Mouse; use MouseX::Foreign; extends 'Foo'; has bar => ( is => 'ro', default => 'BAR', ); package Foo::Mouse::Sub; use Mouse; extends 'Foo::Mouse'; has baz => ( is => 'ro', default => 'BAZ', ); package main; my $foo_moose = Foo::Mouse->new; is($foo_moose->foo, 'FOO', 'Foo::Mouse::foo'); is($foo_moose->bar, 'BAR', 'Foo::Mouse::bar'); isnt(Foo::Mouse->meta->get_method('new'), undef, 'Foo::Mouse gets its own constructor'); my $foo_moose_sub = Foo::Mouse::Sub->new; is($foo_moose_sub->foo, 'FOO', 'Foo::Mouse::Sub::foo'); is($foo_moose_sub->bar, 'BAR', 'Foo::Mouse::Sub::bar'); is($foo_moose_sub->baz, 'BAZ', 'Foo::Mouse::Sub::baz'); is(Foo::Mouse::Sub->meta->get_method('new'), undef, 'Foo::Mouse::Sub just uses the constructor for Foo::Mouse'); Foo::Mouse->meta->make_immutable; Foo::Mouse::Sub->meta->make_immutable; $foo_moose_sub = Foo::Mouse::Sub->new; is($foo_moose_sub->foo, 'FOO', 'Foo::Mouse::Sub::foo (immutable)'); is($foo_moose_sub->bar, 'BAR', 'Foo::Mouse::Sub::bar (immutable)'); is($foo_moose_sub->baz, 'BAZ', 'Foo::Mouse::Sub::baz (immutable)'); isnt(Foo::Mouse::Sub->meta->get_method('new'), undef, 'Foo::Mouse::Sub has an inlined constructor'); 005-moose.t100644000765000024 243712321613075 20727 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 12; package Foo; use Mouse; has foo => ( is => 'ro', default => 'FOO', ); package Foo::Sub; use Mouse; use MouseX::Foreign; 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 Mouse; use MouseX::Foreign; 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)'); 006-disable.t100644000765000024 151212321613075 21202 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 3; package Foo; sub new { my $class = shift; bless {}, $class; } package Foo::Mouse; use Mouse; use MouseX::Foreign; extends 'Foo'; package Foo::Mouse2; use Mouse; use MouseX::Foreign; extends 'Foo'; package main; ok(Foo::Mouse->meta->has_method('new'), 'Foo::Mouse has a constructor'); my $method = Foo::Mouse->meta->get_method('new'); Foo::Mouse->meta->make_immutable; isnt($method->body, Foo::Mouse->meta->get_method('new')->body, 'make_immutable replaced the constructor with an inlined version'); my $method2 = Foo::Mouse2->meta->get_method('new'); Foo::Mouse2->meta->make_immutable(inline_constructor => 0); is($method2->body, Foo::Mouse2->meta->get_method('new')->body, 'make_immutable doesn\'t replace the constructor if we ask it not to'); 010-immutable.t100644000765000024 153012321613075 21551 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 6; 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::Mouse; use Mouse; use MouseX::Foreign; extends 'Foo'; has bar => ( is => 'rw', ); __PACKAGE__->meta->make_immutable; package main; my $foo_moose = Foo::Mouse->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::Mouse', 'quux method'); 020-BUILD.t100644000765000024 206012321613075 20431 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 5; package Foo; sub new { my $class = shift; bless { foo => 'FOO' }, $class; } package Foo::Mouse; use Mouse; use MouseX::Foreign; 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::Mouse::Sub; use Mouse; extends 'Foo::Mouse'; has bar => ( is => 'rw', ); sub BUILD { my $self = shift; $self->bar('BAR'); $self->accum($self->accum . 'b'); } package main; my $foo_moose = Foo::Mouse->new; is($foo_moose->class, 'Foo::Mouse', 'BUILD method called properly'); is($foo_moose->accum, 'a', 'BUILD method called properly'); my $foo_moose_sub = Foo::Mouse::Sub->new; is($foo_moose_sub->class, 'Foo::Mouse::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'); 021-BUILDARGS.t100644000765000024 160612321613075 21114 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 4; package Foo; sub new { my $class = shift; bless { name => $_[0] }, $class; } sub name { shift->{name} } package Foo::Mouse; use Mouse; use MouseX::Foreign; 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; my $foo = Foo::Mouse->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::Mouse->meta->make_immutable; $foo = Foo::Mouse->new('bar', foo => 'baz'); is($foo->name, 'bar', 'superclass constructor gets the right args (immutable)'); is($foo->foo, 'baz', 'subclass constructor gets the right args (immutable)'); 023-FOREIGNBUILDARGS.t100644000765000024 410412321613075 22124 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 12; package Foo; sub new { my $class = shift; bless { foo_base => $_[0] }, $class; } sub foo_base { shift->{foo_base} } package Foo::Mouse; use Mouse; use MouseX::Foreign; extends 'Foo'; has foo => ( is => 'rw', ); sub FOREIGNBUILDARGS { my $class = shift; my %args = @_; return "$args{foo}_base"; } package Bar::Mouse; use Mouse; use MouseX::Foreign; extends 'Foo'; has bar => ( is => 'rw', ); sub FOREIGNBUILDARGS { my $class = shift; return "$_[0]_base"; } sub BUILDARGS { my $class = shift; return { bar => shift }; } package Baz::Mouse; use Mouse; extends 'Bar::Mouse'; has baz => ( is => 'rw', ); package main; my $foo = Foo::Mouse->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::Mouse->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::Mouse->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'); Foo::Mouse->meta->make_immutable; Bar::Mouse->meta->make_immutable; Baz::Mouse->meta->make_immutable; $foo = Foo::Mouse->new(foo => 'bar'); is($foo->foo, 'bar', 'subclass constructor gets the right args (immutable)'); is($foo->foo_base, 'bar_base', 'subclass constructor gets the right args (immutable)'); $bar = Bar::Mouse->new('baz'); is($bar->bar, 'baz', 'subclass constructor gets the right args (immutable)'); is($bar->foo_base, 'baz_base', 'subclass constructor gets the right args (immutable)'); $baz = Baz::Mouse->new('bazbaz'); is($baz->bar, 'bazbaz', 'extensions of extensions of the nonmoose class respect BUILDARGS (immutable)'); is($baz->foo_base, 'bazbaz_base', 'extensions of extensions of the nonmoose class respect FOREIGNBUILDARGS (immutable)'); 024-nonmoose-moose-nonmoose.t100644000765000024 602212321613075 24410 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 32; package Foo; sub new { my $class = shift; bless {@_}, $class; } sub foo { shift->{name} } package Foo::Mouse; use Mouse; use MouseX::Foreign; extends 'Foo'; has foo2 => ( is => 'rw', isa => 'Str', ); package Foo::Mouse::Sub; use base 'Foo::Mouse'; package Bar; sub new { my $class = shift; bless {name => $_[0]}, $class; } sub bar { shift->{name} } package Bar::Mouse; use Mouse; use MouseX::Foreign; extends 'Bar'; has bar2 => ( is => 'rw', isa => 'Str', ); sub FOREIGNBUILDARGS { my $class = shift; my %args = @_; return $args{name}; } package Bar::Mouse::Sub; use base 'Bar::Mouse'; package main; my $foo = Foo::Mouse::Sub->new(name => 'foomoosesub', foo2 => 'FOO2'); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Mouse'); is($foo->foo, 'foomoosesub', 'got name from nonmoose constructor'); is($foo->foo2, 'FOO2', 'got attribute value from moose constructor'); $foo = Foo::Mouse->new(name => 'foomoosesub', foo2 => 'FOO2'); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Mouse'); is($foo->foo, 'foomoosesub', 'got name from nonmoose constructor'); is($foo->foo2, 'FOO2', 'got attribute value from moose constructor'); Foo::Mouse->meta->make_immutable; $foo = Foo::Mouse::Sub->new(name => 'foomoosesub', foo2 => 'FOO2'); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Mouse'); TODO: { local $TODO = 'nonmoose-moose-nonmoose inheritance doesn\'t quite work'; is($foo->foo, 'foomoosesub', 'got name from nonmoose constructor (immutable)'); } is($foo->foo2, 'FOO2', 'got attribute value from moose constructor (immutable)'); $foo = Foo::Mouse->new(name => 'foomoosesub', foo2 => 'FOO2'); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Mouse'); is($foo->foo, 'foomoosesub', 'got name from nonmoose constructor (immutable)'); is($foo->foo2, 'FOO2', 'got attribute value from moose constructor (immutable)'); my $bar = Bar::Mouse::Sub->new(name => 'barmoosesub', bar2 => 'BAR2'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Bar::Mouse'); is($bar->bar, 'barmoosesub', 'got name from nonmoose constructor'); is($bar->bar2, 'BAR2', 'got attribute value from moose constructor'); $bar = Bar::Mouse->new(name => 'barmoosesub', bar2 => 'BAR2'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Bar::Mouse'); is($bar->bar, 'barmoosesub', 'got name from nonmoose constructor'); is($bar->bar2, 'BAR2', 'got attribute value from moose constructor'); Bar::Mouse->meta->make_immutable; $bar = Bar::Mouse::Sub->new(name => 'barmoosesub', bar2 => 'BAR2'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Bar::Mouse'); TODO: { local $TODO = 'nonmoose-moose-nonmoose inheritance doesn\'t quite work'; is($bar->bar, 'barmoosesub', 'got name from nonmoose constructor (immutable)'); } is($bar->bar2, 'BAR2', 'got attribute value from moose constructor (immutable)'); $bar = Bar::Mouse->new(name => 'barmoosesub', bar2 => 'BAR2'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Bar::Mouse'); is($bar->bar, 'barmoosesub', 'got name from nonmoose constructor (immutable)'); is($bar->bar2, 'BAR2', 'got attribute value from moose constructor (immutable)'); 030-only-metaclass-trait.t100644000765000024 125412321613075 23653 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 4; package Foo; sub new { bless {}, shift } package Foo::Mouse; use Mouse -traits => 'MouseX::Foreign::Meta::Role::Class'; extends 'Foo'; package main; ok(Foo::Mouse->meta->has_method('new'), 'using only the metaclass trait still installs the constructor'); isa_ok(Foo::Mouse->new, 'Mouse::Object'); isa_ok(Foo::Mouse->new, 'Foo'); my $method = Foo::Mouse->meta->get_method('new'); Foo::Mouse->meta->make_immutable; { local $TODO = "method object semantics is different from Moose's"; is(Foo::Mouse->meta->get_method('new'), $method, 'inlining doesn\'t happen when the constructor trait isn\'t used'); } 031-moose-exporter.t100644000765000024 424212321613075 22570 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 8; BEGIN { require Mouse; require Mouse::Util::MetaRole; package Foo::Exporter::Class; use Mouse::Exporter; Mouse::Exporter->setup_import_methods(also => ['Mouse']); sub init_meta { shift; my %options = @_; Mouse->init_meta(%options); return Mouse::Util::MetaRole::apply_metaclass_roles( for_class => $options{for_class}, metaclass_roles => ['MouseX::Foreign::Meta::Role::Class'], ); } package Foo::Exporter::ClassAndConstructor; use Mouse::Exporter; Mouse::Exporter->setup_import_methods(also => ['Mouse']); sub init_meta { shift; my %options = @_; Mouse->init_meta(%options); return Mouse::Util::MetaRole::apply_metaclass_roles( for_class => $options{for_class}, metaclass_roles => ['MouseX::Foreign::Meta::Role::Class'], constructor_class_roles => ['MouseX::Foreign::Meta::Role::Method::Constructor'], ); } } package Foo; sub new { bless {}, shift } package Foo::Mouse; BEGIN { Foo::Exporter::Class->import } extends 'Foo'; package Foo::Mouse2; BEGIN { Foo::Exporter::ClassAndConstructor->import } extends 'Foo'; package main; ok(Foo::Mouse->meta->has_method('new'), 'using only the metaclass trait still installs the constructor'); isa_ok(Foo::Mouse->new, 'Mouse::Object'); isa_ok(Foo::Mouse->new, 'Foo'); my $method = Foo::Mouse->meta->get_method('new'); Foo::Mouse->meta->make_immutable; { local $TODO = "method objects has a different semantics from Moose's"; is(Foo::Mouse->meta->get_method('new'), $method, 'inlining doesn\'t happen when the constructor trait isn\'t used'); } ok(Foo::Mouse2->meta->has_method('new'), 'using only the metaclass trait still installs the constructor'); isa_ok(Foo::Mouse2->new, 'Mouse::Object'); isa_ok(Foo::Mouse2->new, 'Foo'); my $method2 = Foo::Mouse2->meta->get_method('new'); Foo::Mouse2->meta->make_immutable; isnt(Foo::Mouse2->meta->get_method('new'), $method2, 'inlining does happen when the constructor trait is used'); 040-destructor.t100644000765000024 115412321613075 21775 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/90-MooseX-NonMoose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 4; my $destroyed = 0; my $demolished = 0; package Foo; sub new { bless {}, shift } sub DESTROY { $destroyed++ } package Foo::Sub; use Mouse; use MouseX::Foreign; extends 'Foo'; sub DEMOLISH { $demolished++ } package main; { Foo::Sub->new } is($destroyed, 1, "non-Mouse destructor called"); is($demolished, 1, "Mouse destructor called"); Foo::Sub->meta->make_immutable; ($destroyed, $demolished) = (0, 0); { Foo::Sub->new } is($destroyed, 1, "non-Mouse destructor called (immutable)"); is($demolished, 1, "Mouse destructor called (immutable)"); 001-basic.t100644000765000024 135412321613075 20721 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More; package Foo; sub new { my $class = shift; bless { _class => $class }, $class; } package Foo::Mouse; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Foo'; package main; my $foo = Foo->new; my $foo_moose = Foo::Mouse->new; isa_ok($foo, 'Foo'); is($foo->{_class}, 'Foo', 'Foo gets the correct class'); isa_ok($foo_moose, 'Foo::Mouse'); isa_ok($foo_moose, 'Foo'); isa_ok($foo_moose, 'Mouse::Object'); is($foo_moose->{_class}, 'Foo::Mouse', 'Foo::Mouse gets the correct class'); my $meta = Foo::Mouse->meta; ok($meta->has_method('new'), 'Foo::Mouse has its own constructor'); my $cc_meta = $meta->constructor_class->meta; isa_ok($cc_meta, 'Mouse::Meta::Class'); done_testing; 002-methods.t100644000765000024 74212321613075 21264 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 3; package Foo; sub new { bless {}, shift } sub foo { 'Foo' } sub bar { 'Foo' } sub baz { ref(shift) } package Foo::Mouse; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Foo'; sub bar { 'Foo::Mouse' } package main; my $foo_moose = Foo::Mouse->new; is($foo_moose->foo, 'Foo', 'Foo::Mouse->foo'); is($foo_moose->bar, 'Foo::Mouse', 'Foo::Mouse->bar'); is($foo_moose->baz, 'Foo::Mouse', 'Foo::Mouse->baz'); 003-attrs.t100644000765000024 126412321613075 20777 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 4; package Foo; sub new { my $class = shift; bless { @_ }, $class; } sub foo { my $self = shift; return $self->{foo} unless @_; $self->{foo} = shift; } package Foo::Mouse; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Foo'; has bar => ( is => 'rw', ); package main; my $foo_moose = Foo::Mouse->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'); 004-multi-level.t100644000765000024 262512321613075 22104 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 11; package Foo; sub new { my $class = shift; bless { foo => 'FOO' }, $class; } sub foo { shift->{foo} } package Foo::Mouse; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Foo'; has bar => ( is => 'ro', default => 'BAR', ); package Foo::Mouse::Sub; use Mouse; extends 'Foo::Mouse'; has baz => ( is => 'ro', default => 'BAZ', ); package main; my $foo_moose = Foo::Mouse->new; is($foo_moose->foo, 'FOO', 'Foo::Mouse::foo'); is($foo_moose->bar, 'BAR', 'Foo::Mouse::bar'); isnt(Foo::Mouse->meta->get_method('new'), undef, 'Foo::Mouse gets its own constructor'); my $foo_moose_sub = Foo::Mouse::Sub->new; is($foo_moose_sub->foo, 'FOO', 'Foo::Mouse::Sub::foo'); is($foo_moose_sub->bar, 'BAR', 'Foo::Mouse::Sub::bar'); is($foo_moose_sub->baz, 'BAZ', 'Foo::Mouse::Sub::baz'); is(Foo::Mouse::Sub->meta->get_method('new'), undef, 'Foo::Mouse::Sub just uses the constructor for Foo::Mouse'); Foo::Mouse->meta->make_immutable; Foo::Mouse::Sub->meta->make_immutable; $foo_moose_sub = Foo::Mouse::Sub->new; is($foo_moose_sub->foo, 'FOO', 'Foo::Mouse::Sub::foo (immutable)'); is($foo_moose_sub->bar, 'BAR', 'Foo::Mouse::Sub::bar (immutable)'); is($foo_moose_sub->baz, 'BAZ', 'Foo::Mouse::Sub::baz (immutable)'); isnt(Foo::Mouse::Sub->meta->get_method('new'), undef, 'Foo::Mouse::Sub has an inlined constructor'); 005-moose.t100644000765000024 246112321613075 20766 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 12; package Foo; use Mouse; has foo => ( is => 'ro', default => 'FOO', ); package Foo::Sub; use Mouse; use Any::Moose 'X::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 Mouse; use Any::Moose 'X::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)'); 006-disable.t100644000765000024 153412321613075 21250 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 3; package Foo; sub new { my $class = shift; bless {}, $class; } package Foo::Mouse; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Foo'; package Foo::Mouse2; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Foo'; package main; ok(Foo::Mouse->meta->has_method('new'), 'Foo::Mouse has a constructor'); my $method = Foo::Mouse->meta->get_method('new'); Foo::Mouse->meta->make_immutable; isnt($method->body, Foo::Mouse->meta->get_method('new')->body, 'make_immutable replaced the constructor with an inlined version'); my $method2 = Foo::Mouse2->meta->get_method('new'); Foo::Mouse2->meta->make_immutable(inline_constructor => 0); is($method2->body, Foo::Mouse2->meta->get_method('new')->body, 'make_immutable doesn\'t replace the constructor if we ask it not to'); 010-immutable.t100644000765000024 154112321613075 21615 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 6; 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::Mouse; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Foo'; has bar => ( is => 'rw', ); __PACKAGE__->meta->make_immutable; package main; my $foo_moose = Foo::Mouse->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::Mouse', 'quux method'); 020-BUILD.t100644000765000024 207112321613075 20475 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 5; package Foo; sub new { my $class = shift; bless { foo => 'FOO' }, $class; } package Foo::Mouse; use Mouse; use Any::Moose 'X::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::Mouse::Sub; use Mouse; extends 'Foo::Mouse'; has bar => ( is => 'rw', ); sub BUILD { my $self = shift; $self->bar('BAR'); $self->accum($self->accum . 'b'); } package main; my $foo_moose = Foo::Mouse->new; is($foo_moose->class, 'Foo::Mouse', 'BUILD method called properly'); is($foo_moose->accum, 'a', 'BUILD method called properly'); my $foo_moose_sub = Foo::Mouse::Sub->new; is($foo_moose_sub->class, 'Foo::Mouse::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'); 021-BUILDARGS.t100644000765000024 161712321613075 21160 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 4; package Foo; sub new { my $class = shift; bless { name => $_[0] }, $class; } sub name { shift->{name} } package Foo::Mouse; use Mouse; use Any::Moose 'X::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; my $foo = Foo::Mouse->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::Mouse->meta->make_immutable; $foo = Foo::Mouse->new('bar', foo => 'baz'); is($foo->name, 'bar', 'superclass constructor gets the right args (immutable)'); is($foo->foo, 'baz', 'subclass constructor gets the right args (immutable)'); 023-FOREIGNBUILDARGS.t100644000765000024 412612321613075 22172 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 12; package Foo; sub new { my $class = shift; bless { foo_base => $_[0] }, $class; } sub foo_base { shift->{foo_base} } package Foo::Mouse; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Foo'; has foo => ( is => 'rw', ); sub FOREIGNBUILDARGS { my $class = shift; my %args = @_; return "$args{foo}_base"; } package Bar::Mouse; use Mouse; use Any::Moose 'X::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::Mouse; use Mouse; extends 'Bar::Mouse'; has baz => ( is => 'rw', ); package main; my $foo = Foo::Mouse->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::Mouse->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::Mouse->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'); Foo::Mouse->meta->make_immutable; Bar::Mouse->meta->make_immutable; Baz::Mouse->meta->make_immutable; $foo = Foo::Mouse->new(foo => 'bar'); is($foo->foo, 'bar', 'subclass constructor gets the right args (immutable)'); is($foo->foo_base, 'bar_base', 'subclass constructor gets the right args (immutable)'); $bar = Bar::Mouse->new('baz'); is($bar->bar, 'baz', 'subclass constructor gets the right args (immutable)'); is($bar->foo_base, 'baz_base', 'subclass constructor gets the right args (immutable)'); $baz = Baz::Mouse->new('bazbaz'); is($baz->bar, 'bazbaz', 'extensions of extensions of the nonmoose class respect BUILDARGS (immutable)'); is($baz->foo_base, 'bazbaz_base', 'extensions of extensions of the nonmoose class respect FOREIGNBUILDARGS (immutable)'); 024-nonmoose-moose-nonmoose.t100644000765000024 604412321613075 24456 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 32; package Foo; sub new { my $class = shift; bless {@_}, $class; } sub foo { shift->{name} } package Foo::Mouse; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Foo'; has foo2 => ( is => 'rw', isa => 'Str', ); package Foo::Mouse::Sub; use base 'Foo::Mouse'; package Bar; sub new { my $class = shift; bless {name => $_[0]}, $class; } sub bar { shift->{name} } package Bar::Mouse; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Bar'; has bar2 => ( is => 'rw', isa => 'Str', ); sub FOREIGNBUILDARGS { my $class = shift; my %args = @_; return $args{name}; } package Bar::Mouse::Sub; use base 'Bar::Mouse'; package main; my $foo = Foo::Mouse::Sub->new(name => 'foomoosesub', foo2 => 'FOO2'); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Mouse'); is($foo->foo, 'foomoosesub', 'got name from nonmoose constructor'); is($foo->foo2, 'FOO2', 'got attribute value from moose constructor'); $foo = Foo::Mouse->new(name => 'foomoosesub', foo2 => 'FOO2'); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Mouse'); is($foo->foo, 'foomoosesub', 'got name from nonmoose constructor'); is($foo->foo2, 'FOO2', 'got attribute value from moose constructor'); Foo::Mouse->meta->make_immutable; $foo = Foo::Mouse::Sub->new(name => 'foomoosesub', foo2 => 'FOO2'); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Mouse'); TODO: { local $TODO = 'nonmoose-moose-nonmoose inheritance doesn\'t quite work'; is($foo->foo, 'foomoosesub', 'got name from nonmoose constructor (immutable)'); } is($foo->foo2, 'FOO2', 'got attribute value from moose constructor (immutable)'); $foo = Foo::Mouse->new(name => 'foomoosesub', foo2 => 'FOO2'); isa_ok($foo, 'Foo'); isa_ok($foo, 'Foo::Mouse'); is($foo->foo, 'foomoosesub', 'got name from nonmoose constructor (immutable)'); is($foo->foo2, 'FOO2', 'got attribute value from moose constructor (immutable)'); my $bar = Bar::Mouse::Sub->new(name => 'barmoosesub', bar2 => 'BAR2'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Bar::Mouse'); is($bar->bar, 'barmoosesub', 'got name from nonmoose constructor'); is($bar->bar2, 'BAR2', 'got attribute value from moose constructor'); $bar = Bar::Mouse->new(name => 'barmoosesub', bar2 => 'BAR2'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Bar::Mouse'); is($bar->bar, 'barmoosesub', 'got name from nonmoose constructor'); is($bar->bar2, 'BAR2', 'got attribute value from moose constructor'); Bar::Mouse->meta->make_immutable; $bar = Bar::Mouse::Sub->new(name => 'barmoosesub', bar2 => 'BAR2'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Bar::Mouse'); TODO: { local $TODO = 'nonmoose-moose-nonmoose inheritance doesn\'t quite work'; is($bar->bar, 'barmoosesub', 'got name from nonmoose constructor (immutable)'); } is($bar->bar2, 'BAR2', 'got attribute value from moose constructor (immutable)'); $bar = Bar::Mouse->new(name => 'barmoosesub', bar2 => 'BAR2'); isa_ok($bar, 'Bar'); isa_ok($bar, 'Bar::Mouse'); is($bar->bar, 'barmoosesub', 'got name from nonmoose constructor (immutable)'); is($bar->bar2, 'BAR2', 'got attribute value from moose constructor (immutable)'); 030-only-metaclass-trait.t100644000765000024 125412321613075 23715 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 4; package Foo; sub new { bless {}, shift } package Foo::Mouse; use Mouse -traits => 'MouseX::Foreign::Meta::Role::Class'; extends 'Foo'; package main; ok(Foo::Mouse->meta->has_method('new'), 'using only the metaclass trait still installs the constructor'); isa_ok(Foo::Mouse->new, 'Mouse::Object'); isa_ok(Foo::Mouse->new, 'Foo'); my $method = Foo::Mouse->meta->get_method('new'); Foo::Mouse->meta->make_immutable; { local $TODO = "method object semantics is different from Moose's"; is(Foo::Mouse->meta->get_method('new'), $method, 'inlining doesn\'t happen when the constructor trait isn\'t used'); } 031-moose-exporter.t100644000765000024 424512321613075 22635 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 8; BEGIN { require Mouse; require Mouse::Util::MetaRole; package Foo::Exporter::Class; use Mouse::Exporter; Mouse::Exporter->setup_import_methods(also => ['Mouse']); sub init_meta { shift; my %options = @_; Mouse->init_meta(%options); return Mouse::Util::MetaRole::apply_metaclass_roles( for_class => $options{for_class}, metaclass_roles => ['MouseX::NonMoose::Meta::Role::Class'], ); } package Foo::Exporter::ClassAndConstructor; use Mouse::Exporter; Mouse::Exporter->setup_import_methods(also => ['Mouse']); sub init_meta { shift; my %options = @_; Mouse->init_meta(%options); return Mouse::Util::MetaRole::apply_metaclass_roles( for_class => $options{for_class}, metaclass_roles => ['MouseX::NonMoose::Meta::Role::Class'], constructor_class_roles => ['MouseX::NonMoose::Meta::Role::Method::Constructor'], ); } } package Foo; sub new { bless {}, shift } package Foo::Mouse; BEGIN { Foo::Exporter::Class->import } extends 'Foo'; package Foo::Mouse2; BEGIN { Foo::Exporter::ClassAndConstructor->import } extends 'Foo'; package main; ok(Foo::Mouse->meta->has_method('new'), 'using only the metaclass trait still installs the constructor'); isa_ok(Foo::Mouse->new, 'Mouse::Object'); isa_ok(Foo::Mouse->new, 'Foo'); my $method = Foo::Mouse->meta->get_method('new'); Foo::Mouse->meta->make_immutable; { local $TODO = "method objects has a different semantics from Moose's"; is(Foo::Mouse->meta->get_method('new'), $method, 'inlining doesn\'t happen when the constructor trait isn\'t used'); } ok(Foo::Mouse2->meta->has_method('new'), 'using only the metaclass trait still installs the constructor'); isa_ok(Foo::Mouse2->new, 'Mouse::Object'); isa_ok(Foo::Mouse2->new, 'Foo'); my $method2 = Foo::Mouse2->meta->get_method('new'); Foo::Mouse2->meta->make_immutable; isnt(Foo::Mouse2->meta->get_method('new'), $method2, 'inlining does happen when the constructor trait is used'); 040-destructor.t100644000765000024 116512321613075 22041 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/t/91-90-with-Any-Moose#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 4; my $destroyed = 0; my $demolished = 0; package Foo; sub new { bless {}, shift } sub DESTROY { $destroyed++ } package Foo::Sub; use Mouse; use Any::Moose 'X::NonMoose'; extends 'Foo'; sub DEMOLISH { $demolished++ } package main; { Foo::Sub->new } is($destroyed, 1, "non-Mouse destructor called"); is($demolished, 1, "Mouse destructor called"); Foo::Sub->meta->make_immutable; ($destroyed, $demolished) = (0, 0); { Foo::Sub->new } is($destroyed, 1, "non-Mouse destructor called (immutable)"); is($demolished, 1, "Mouse destructor called (immutable)"); pod.t100644000765000024 23312321613075 15032 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/xt#!perl -w use strict; use Test::More; eval q{use Test::Pod 1.14}; plan skip_all => 'Test::Pod 1.14 required for testing POD' if $@; all_pod_files_ok(); pod_synopsis.t100644000765000024 22312321613075 17000 0ustar00gfxstaff000000000000MouseX-Foreign-1.000/xt#!perl -w use strict; use Test::More; eval q{use Test::Synopsis}; plan skip_all => 'Test::Synopsis required for testing' if $@; all_synopsis_ok(); META.yml100644000765000024 343212321613075 14725 0ustar00gfxstaff000000000000MouseX-Foreign-1.000--- abstract: 'Extends non-Mouse classes as well as Mouse classes' author: - 'Fuji, Goro (gfx) ' build_requires: Any::Moose: 0.15 Test::Exception: 0 Test::More: 0.88 Test::Requires: 0 configure_requires: CPAN::Meta: 0 CPAN::Meta::Prereqs: 0 Module::Build: 0.38 dynamic_config: 0 generated_by: 'Minilla/v0.14.1, CPAN::Meta::Converter version 2.133380' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: MouseX-Foreign no_index: directory: - t - xt - inc - share - eg - examples - author - builder provides: MouseX::Foreign: file: lib/MouseX/Foreign.pm version: 1.000 MouseX::Foreign::Meta::Role::Class: file: lib/MouseX/Foreign/Meta/Role/Class.pm MouseX::Foreign::Meta::Role::Method::Constructor: file: lib/MouseX/Foreign/Meta/Role/Method/Constructor.pm MouseX::Foreign::Meta::Role::Method::Destructor: file: lib/MouseX/Foreign/Meta/Role/Method/Destructor.pm MouseX::NonMoose: file: lib/MouseX/NonMoose.pm version: 1.000 MouseX::NonMoose::Meta::Role::Class: file: lib/MouseX/NonMoose/Meta/Role/Class.pm MouseX::NonMoose::Meta::Role::Method::Constructor: file: lib/MouseX/NonMoose/Meta/Role/Method/Constructor.pm MouseX::NonMoose::Meta::Role::Method::Destructor: file: lib/MouseX/NonMoose/Meta/Role/Method/Destructor.pm requires: Mouse: 0.77 perl: 5.008001 resources: bugtracker: https://github.com/gfx/p5-MouseX-Foreign/issues homepage: https://github.com/gfx/p5-MouseX-Foreign repository: git://github.com/gfx/p5-MouseX-Foreign.git version: 1.000 x_contributors: - 'Richard Simões ' - 'Fuji Goro ' - 'Michael G. Schwern ' - 'Fuji, Goro (gfx) ' MANIFEST100644000765000024 312412321613075 14603 0ustar00gfxstaff000000000000MouseX-Foreign-1.000Build.PL Changes LICENSE META.json README.md cpanfile lib/MouseX/Foreign.pm lib/MouseX/Foreign/Meta/Role/Class.pm lib/MouseX/Foreign/Meta/Role/Method/Constructor.pm lib/MouseX/Foreign/Meta/Role/Method/Destructor.pm lib/MouseX/NonMoose.pm lib/MouseX/NonMoose/Meta/Role/Class.pm lib/MouseX/NonMoose/Meta/Role/Method/Constructor.pm lib/MouseX/NonMoose/Meta/Role/Method/Destructor.pm t/00_load.t t/01_basic.t t/02_moose.t t/03_mybigint.t t/04_multpile.t t/05_bless_new_args.t t/90-MooseX-NonMoose/001-basic.t t/90-MooseX-NonMoose/002-methods.t t/90-MooseX-NonMoose/003-attrs.t t/90-MooseX-NonMoose/004-multi-level.t t/90-MooseX-NonMoose/005-moose.t t/90-MooseX-NonMoose/006-disable.t t/90-MooseX-NonMoose/010-immutable.t t/90-MooseX-NonMoose/020-BUILD.t t/90-MooseX-NonMoose/021-BUILDARGS.t t/90-MooseX-NonMoose/023-FOREIGNBUILDARGS.t t/90-MooseX-NonMoose/024-nonmoose-moose-nonmoose.t t/90-MooseX-NonMoose/030-only-metaclass-trait.t t/90-MooseX-NonMoose/031-moose-exporter.t t/90-MooseX-NonMoose/040-destructor.t t/91-90-with-Any-Moose/001-basic.t t/91-90-with-Any-Moose/002-methods.t t/91-90-with-Any-Moose/003-attrs.t t/91-90-with-Any-Moose/004-multi-level.t t/91-90-with-Any-Moose/005-moose.t t/91-90-with-Any-Moose/006-disable.t t/91-90-with-Any-Moose/010-immutable.t t/91-90-with-Any-Moose/020-BUILD.t t/91-90-with-Any-Moose/021-BUILDARGS.t t/91-90-with-Any-Moose/023-FOREIGNBUILDARGS.t t/91-90-with-Any-Moose/024-nonmoose-moose-nonmoose.t t/91-90-with-Any-Moose/030-only-metaclass-trait.t t/91-90-with-Any-Moose/031-moose-exporter.t t/91-90-with-Any-Moose/040-destructor.t xt/pod.t xt/pod_synopsis.t META.yml MANIFEST