From: Hans Dieter Pearcey Date: Sat, 25 Apr 2009 04:58:19 +0000 (-0400) Subject: remove trailing whitespace X-Git-Tag: 0.76~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d03bd989b97597428b460d7f9a021e2931893fa0;p=gitmo%2FMoose.git remove trailing whitespace (use git blame -w, do not complain to me about obscuring history) --- diff --git a/Changes b/Changes index f97b3fa..83db4f5 100644 --- a/Changes +++ b/Changes @@ -103,7 +103,7 @@ for, noteworthy changes. point out this fact. (hdp) * Moose::Cookbook::Basics::Recipe12 - - A new recipe, creating a custom meta-method class. + - A new recipe, creating a custom meta-method class. * Moose::Cookbook::Meta::Recipe6 - A new recipe, creating a custom meta-method class. @@ -115,7 +115,7 @@ for, noteworthy changes. called during instance construction were passed the meta-attribute, but triggers called by normal accessors were not. Fixes RT#44429, reported by Mark Swayne. (hdp) - + * Moose::Manual::Attributes - Remove references to triggers receving the meta-attribute object as an argument. (hdp) @@ -267,7 +267,7 @@ for, noteworthy changes. * Moose::Util::TypeConstraints - Added the RoleName type (stevan) - added tests for this (stevan) - + * Moose::Cookbook::Basics::Recipe3 - Updated the before qw[left right] sub to be a little more defensive about what it accepts (stevan) @@ -294,7 +294,7 @@ for, noteworthy changes. - Some tests tried to use Test::Warn 0.10, which had bugs. Now they require 0.11. (Dave Rolsky) - * Documentation + * Documentation - Lots of small changes to the manual, cookbook, and elsewhere. These were based on feedback from various users, too many to list here. (Dave Rolsky) @@ -520,7 +520,7 @@ for, noteworthy changes. - Passing "-traits" when loading Moose caused the Moose.pm exports to be broken. Reported by t0m. (Dave Rolsky) - Tests for this bug. (t0m) - + * Moose::Util - Change resolve_metaclass alias to use the new load_first_existing_class function. This makes it a lot @@ -545,7 +545,7 @@ for, noteworthy changes. * Moose::Meta::TypeConstraint::Union - Type constraint names are sorted as strings, not numbers. (jnapiorkowski) - + * Moose::Meta::TypeConstraint::Parameterizable - New parameterize method. This can be used as a factory method to make a new type constraint with a given parameterized @@ -555,7 +555,7 @@ for, noteworthy changes. 0.59 Tue October 14, 2008 * Moose - Add abridged documentation for builder/default/initializer/ - predicate, and link to more details sections in + predicate, and link to more details sections in Class::MOP::Attribute. (t0m) * Moose::Util::TypeConstraints @@ -766,16 +766,16 @@ for, noteworthy changes. - explicitly require Perl 5.8.0+ (Dave Rolsky) * Moose::Util::TypeConstraints - - Fix warnings from find_type_constraint if the type is not + - Fix warnings from find_type_constraint if the type is not found (t0m). - + * Moose::Meta::TypeConstraint - Predicate methods (equals/is_a_type_of/is_subtype_of) now return false if the type you specify cannot be found in the type registry, rather than throwing an unhelpful and coincidental exception. (t0m). - added docs & test for this (t0m) - + * Moose::Meta::TypeConstraint::Registry - add_type_constraint now throws an exception if a parameter is not supplied (t0m). @@ -790,7 +790,7 @@ for, noteworthy changes. method when that method was provided by another role being composed at the same time. (Dave Rolsky) - test and bug finding (tokuhirom) - + 0.55_01 Wed August 20, 2008 !! Calling Moose::init_meta as a function is now !! @@ -898,32 +898,32 @@ for, noteworthy changes. 0.54 Thurs. July 3, 2008 ... this is not my day today ... - + * Moose::Meta::Attribute - - fixed legal_options_for_inheritance such that - clone_and_inherit options still works for - Class::MOP::Attribute objects and therefore + - fixed legal_options_for_inheritance such that + clone_and_inherit options still works for + Class::MOP::Attribute objects and therefore does not break MooseX::AttributeHelpers (stevan) 0.53 Thurs. July 3, 2008 - * Whoops, I guess I should run 'make manifest' before - actually releasing the module. No actual changes + * Whoops, I guess I should run 'make manifest' before + actually releasing the module. No actual changes in this release, except the fact that it includes - the changes that I didn't include in the last + the changes that I didn't include in the last release. (stevan--) 0.52 Thurs. July 3, 2008 * Moose - added "FEATURE REQUESTS" section to the Moose docs to properly direct people (stevan) (RT #34333) - - making 'extends' croak if it is passed a Role since - this is not ever something you want to do + - making 'extends' croak if it is passed a Role since + this is not ever something you want to do (fixed by stevan, found by obra) - added tests for this (stevan) * Moose::Object - - adding support for DOES (as in UNIVERSAL::DOES) + - adding support for DOES (as in UNIVERSAL::DOES) (nothingmuch) - added test for this @@ -932,12 +932,12 @@ for, noteworthy changes. - added tests for this (wreis) * Moose::Cookbook::Snacks::* - - removed some of the unfinished snacks that should + - removed some of the unfinished snacks that should not have been released yet. Added some more examples to the 'Keywords' snack. (stevan) * Moose::Cookbook::Style - - added general Moose "style guide" of sorts to the + - added general Moose "style guide" of sorts to the cookbook (nothingmuch) (RT #34335) * t/ @@ -993,9 +993,9 @@ for, noteworthy changes. !! faster with new Class::MOP 0.59 !! * Moose::Meta::Attribute - - fixed how the is => (ro|rw) works with + - fixed how the is => (ro|rw) works with custom defined reader, writer and accessor - options. + options. - added docs for this (TODO). - added tests for this (Thanks to Penfold) - added the custom attribute alias for regular @@ -1009,15 +1009,15 @@ for, noteworthy changes. Moose::Meta::Role Moose::Meta::Role::Composite Moose::Util::TypeConstraints - - switched usage of reftype to ref because + - switched usage of reftype to ref because it is much faster - + * Moose::Meta::Role - changing add_package_symbol to use the new HASH ref form - + * Moose::Object - - fixed how DEMOLISHALL is called so that it + - fixed how DEMOLISHALL is called so that it can be overrided in subclasses (thanks to Sartak) - added test for this (thanks to Sartak) @@ -1037,7 +1037,7 @@ for, noteworthy changes. 0.47 Thurs. May 29, 2008 (late night release engineering)-- - - fixing the version is META.yml, no functional + - fixing the version is META.yml, no functional changes in this release 0.46 Wed. May 28, 2008 @@ -1046,153 +1046,153 @@ for, noteworthy changes. * Moose::Meta::Class - some optimizations of the &initialize method - since it is called so often by &meta - + since it is called so often by &meta + * Moose::Meta::Class Moose::Meta::Role - - now use the get_all_package_symbols from the - updated Class::MOP, test suite is now 10 seconds + - now use the get_all_package_symbols from the + updated Class::MOP, test suite is now 10 seconds faster - + * Moose::Meta::Method::Destructor - - is_needed can now also be called as a class - method for immutablization to check if the - destructor object even needs to be created + - is_needed can now also be called as a class + method for immutablization to check if the + destructor object even needs to be created at all - + * Moose::Meta::Method::Destructor Moose::Meta::Method::Constructor - - added more descriptive error message to help + - added more descriptive error message to help keep people from wasting time tracking an error that is easily fixed by upgrading. 0.45 Saturday, May 24, 2008 * Moose - - Because of work in Class::MOP 0.57, all + - Because of work in Class::MOP 0.57, all XS based functionality is now optional and a Pure Perl version is supplied - the CLASS_MOP_NO_XS environment variable - can now be used to force non-XS versions - to always be used + can now be used to force non-XS versions + to always be used - several of the packages have been tweaked to take care of this, mostly we added - support for the package_name and name + support for the package_name and name variables in all the Method metaclasses - - before/around/after method modifiers now + - before/around/after method modifiers now support regexp matching of names (thanks to Takatoshi Kitano) - tests added for this - - NOTE: this only works for classes, it - is currently not supported in roles, + - NOTE: this only works for classes, it + is currently not supported in roles, but, ... patches welcome - All usage of Carp::confess have been replaced by Carp::croak in the "keyword" functions since the stack trace is usually not helpful - + * Moose::Role - All usage of Carp::confess have been replaced by Carp::croak in the "keyword" functions since - the stack trace is usually not helpful - - The 'has' keyword for roles now accepts the - same array ref form that Moose.pm does + the stack trace is usually not helpful + - The 'has' keyword for roles now accepts the + same array ref form that Moose.pm does (has [qw/foo bar/] => (is => 'rw', ...)) - added test for this - + * Moose::Meta::Attribute - trigger on a ro-attribute is no longer an error, as it's useful to trigger off of the constructor * Moose::Meta::Class - - added same 'add_package_symbol' fix as in + - added same 'add_package_symbol' fix as in Class::MOP 0.57 * Moose::Util - - does_role now handles non-Moose classes + - does_role now handles non-Moose classes more gracefully - added tests for this - - added the 'add_method_modifier' function + - added the 'add_method_modifier' function (thanks to Takatoshi Kitano) * Moose::Util::TypeConstraints - - subtypes of parameterizable types now are + - subtypes of parameterizable types now are themselves parameterizable types * Moose::Meta::Method::Constructor - - fixed bug where trigger was not being - called by the inlined immutable - constructors + - fixed bug where trigger was not being + called by the inlined immutable + constructors - added test for this (thanks to Caelum) - + * Moose::Meta::Role::Application::ToInstance - now uses the metaclass of the instance (if possible) to create the anon-class (thanks Jonathan Rockway) - + * Moose::Cookbook::Recipe22 - added the meta-attribute trait recipe (thanks to Sartak) - + * t/ - - fixed hash-ordering test bug that was + - fixed hash-ordering test bug that was causing occasional cpantester failures - - renamed the t/000_recipe/*.t tests to be - more descriptive (thanks to Sartak) + - renamed the t/000_recipe/*.t tests to be + more descriptive (thanks to Sartak) 0.44 Sat. May 10, 2008 * Moose - - made make_immutable warning cluck to + - made make_immutable warning cluck to show where the error is (thanks mst) - + * Moose::Object - - BUILDALL and DEMOLISHALL now call - ->body when looping through the + - BUILDALL and DEMOLISHALL now call + ->body when looping through the methods, to avoid the overloaded method call. - fixed issue where DEMOLISHALL was - eating the $@ values, and so not + eating the $@ values, and so not working correctly, it still kind of - eats them, but so does vanilla perl + eats them, but so does vanilla perl - added tests for this - + * Moose::Cookbook::Recipe7 - - added new recipe for immutable + - added new recipe for immutable functionality (thanks Dave Rolsky) - + * Moose::Cookbook::Recipe9 - - added new recipe for builder and + - added new recipe for builder and lazy_build (thanks Dave Rolsky) - + * Moose::Cookbook::Recipe11 - - added new recipe for method aliasing + - added new recipe for method aliasing and exclusion with Roles (thanks Dave Rolsky) * t/ - fixed Win32 test failure (thanks spicyjack) - ~ removed Build.PL and Module::Build compat + ~ removed Build.PL and Module::Build compat since Module::Install has done that. 0.43 Wed. April, 30, 2008 * NOTE TO SELF: - drink more coffee before + drink more coffee before doing release engineering - - - whoops, forgot to do the smolder tests, + + - whoops, forgot to do the smolder tests, and we broke some of the custom meta-attr modules. This fixes that. 0.42 Mon. April 28, 2008 - - some bad tests slipped by, nothing else + - some bad tests slipped by, nothing else changed in this release (cpantesters++) - - - upped the Class::MOP dependency to 0.55 - since we have tests which need the C3 + + - upped the Class::MOP dependency to 0.55 + since we have tests which need the C3 support 0.41 Mon. April 28, 2008 ~~ numerous documentation updates ~~ - + - Changed all usage of die to Carp::croak for better error reporting (initial patch by Tod Hagan) @@ -1209,8 +1209,8 @@ for, noteworthy changes. any method/@ISA cache penalty (nothingmuch) * Moose::Meta::Class - - fixing &new_object to make sure trigger gets the - coerced value (spotted by Charles Alderman on the + - fixing &new_object to make sure trigger gets the + coerced value (spotted by Charles Alderman on the mailing list) - added test for this @@ -1220,23 +1220,23 @@ for, noteworthy changes. found by Jesse Luehrs, fixed by Dave Rolsky) - added tests for this (Dave Rolsky) - fix typo in initialize_body method (nothingmuch) - + * Moose::Meta::Method::Destructor - fix typo in initialize_body method (nothingmuch) * Moose::Meta::Method::Overriden Moose::Meta::Method::Augmented - - moved the logic for these into their own + - moved the logic for these into their own classes (nothingmuch) * Moose::Meta::Attribute - - inherited attributes may now be extended without + - inherited attributes may now be extended without restriction on the type ('isa', 'does') (Sartak) - added tests for this (Sartak) - - when an attribute property is malformed (such as lazy without - a default), give the name of the attribute in the error + - when an attribute property is malformed (such as lazy without + a default), give the name of the attribute in the error message (Sartak) - - added the &applied_traits and &has_applied_traits methods + - added the &applied_traits and &has_applied_traits methods to allow introspection of traits - added tests for this - moved 'trait' and 'metaclass' argument handling to here from @@ -1244,14 +1244,14 @@ for, noteworthy changes. - clone_and_inherit_options now handles 'trait' and 'metaclass' (has '+foo' syntax) (nothingmuch) - added tests for this (t0m) - - * Moose::Object - - localize $@ inside DEMOLISHALL to avoid it + + * Moose::Object + - localize $@ inside DEMOLISHALL to avoid it eating $@ (found by Ernesto) - added test for this (thanks to Ernesto) * Moose::Util::TypeConstraints - - &find_type_constraint now DWIMs when given an + - &find_type_constraint now DWIMs when given an type constraint object or name (nothingmuch) - &find_or_create_type_constraint superseded with a number of more specific functions: @@ -1264,19 +1264,19 @@ for, noteworthy changes. Moose::Meta::TypeConstraint::Enum Moose::Meta::TypeConstraint::Union Moose::Meta::TypeConstraint::Parameterized - - added the &equals method for comparing two type + - added the &equals method for comparing two type constraints (nothingmuch) - added tests for this (nothingmuch) * Moose::Meta::TypeConstraint - - add the &parents method, which is just an alias to &parent. + - add the &parents method, which is just an alias to &parent. Useful for polymorphism with TC::{Class,Role,Union} (nothingmuch) * Moose::Meta::TypeConstraint::Class - added the class attribute for introspection purposes (nothingmuch) - added tests for this - + * Moose::Meta::TypeConstraint::Enum Moose::Meta::TypeConstraint::Role - broke these out into their own classes (nothingmuch) @@ -1295,70 +1295,70 @@ for, noteworthy changes. 0.39 Fri. March 14, 2008 * Moose - - documenting the use of '+name' with attributes + - documenting the use of '+name' with attributes that come from recently composed roles. It makes - sense, people are using it, and so why not just + sense, people are using it, and so why not just officially support it. - - fixing the 'extends' keyword so that it will not + - fixing the 'extends' keyword so that it will not trigger Ovid's bug (http://use.perl.org/~Ovid/journal/35763) - + * oose - - added the perl -Moose=+Class::Name feature to allow + - added the perl -Moose=+Class::Name feature to allow monkeypatching of classes in one liners - + * Moose::Util - - fixing the 'apply_all_roles' keyword so that it will not - trigger Ovid's bug (http://use.perl.org/~Ovid/journal/35763) - + - fixing the 'apply_all_roles' keyword so that it will not + trigger Ovid's bug (http://use.perl.org/~Ovid/journal/35763) + * Moose::Meta::Class - added ->create method which now supports roles (thanks to jrockway) - added tests for this - - added ->create_anon_class which now supports roles and caching of + - added ->create_anon_class which now supports roles and caching of the results (thanks to jrockway) - added tests for this - made ->does_role a little more forgiving when it is checking a Class::MOP era metaclasses. - + * Moose::Meta::Role::Application::ToInstance - - it is now possible to pass extra params to be used when + - it is now possible to pass extra params to be used when a role is applied to an the instance (rebless_params) - added tests for this - + * Moose::Util::TypeConstraints - class_type now accepts an optional second argument for a custom message. POD anotated accordingly (groditi) - - added tests for this - - it is now possible to make anon-enums by passing 'enum' an - ARRAY ref instead of the $name => @values. Everything else + - added tests for this + - it is now possible to make anon-enums by passing 'enum' an + ARRAY ref instead of the $name => @values. Everything else works as before. - added tests for this - + * t/ - - making test for using '+name' on attributes consumed + - making test for using '+name' on attributes consumed from a role, it works and makes sense too. - * Moose::Meta::Attribute - - fix handles so that it doesn't return nothing - when the method cannot be found, not sure why + * Moose::Meta::Attribute + - fix handles so that it doesn't return nothing + when the method cannot be found, not sure why it ever did this originally, this means we now - have slightly better support for AUTOLOADed + have slightly better support for AUTOLOADed objects - added more delegation tests - - adding ->does method to this so as to better + - adding ->does method to this so as to better support traits and their introspection. - added tests for this - + * Moose::Object - - localizing the Data::Dumper configurations so + - localizing the Data::Dumper configurations so that it does not pollute others (RT #33509) - made ->does a little more forgiving when it is passed Class::MOP era metaclasses. 0.38 Fri. Feb. 15, 2008 - * Moose::Meta::Attribute - - fixed initializer to correctly do - type checking and coercion in the - callback + * Moose::Meta::Attribute + - fixed initializer to correctly do + type checking and coercion in the + callback - added tests for this * t/ @@ -1366,62 +1366,62 @@ for, noteworthy changes. 0.37 Thurs. Feb. 14, 2008 * Moose - - fixed some details in Moose::init_meta + - fixed some details in Moose::init_meta and its superclass handling (thanks thepler) - added tests for this (thanks thepler) - - 'has' now dies if you don't pass in name + - 'has' now dies if you don't pass in name value pairs - added the 'make_immutable' keyword as a shortcut to make_immutable * Moose::Meta::Class Moose::Meta::Method::Constructor - Moose::Meta::Attribute + Moose::Meta::Attribute - making (init_arg => undef) work here too (thanks to nothingmuch) - - * Moose::Meta::Attribute + + * Moose::Meta::Attribute Moose::Meta::Method::Constructor - Moose::Meta::Method::Accessor + Moose::Meta::Method::Accessor - make lazy attributes respect attr initializers (rjbs) - added tests for this - + * Moose::Util::TypeConstraints Moose::Util::TypeConstraints::OptimizedConstraints Moose::Meta::TypeConstraints Moose::Meta::Attribute Moose::Meta::Method::Constructor - Moose::Meta::Method::Accessor - - making type errors use the + Moose::Meta::Method::Accessor + - making type errors use the assigned message (thanks to Sartak) - added tests for this * Moose::Meta::Method::Destructor - - making sure DESTROY gets inlined properly + - making sure DESTROY gets inlined properly with successive DEMOLISH calls (thanks to manito) - * Moose::Meta::Attribute - Moose::Meta::Method::Accessor - - fixed handling of undef with type constraints - (thanks to Ernesto) + * Moose::Meta::Attribute + Moose::Meta::Method::Accessor + - fixed handling of undef with type constraints + (thanks to Ernesto) - added tests for this - + * Moose::Util - - added &get_all_init_args and &get_all_attribute_values + - added &get_all_init_args and &get_all_attribute_values (thanks to Sartak and nothingmuch) 0.36 Sat. Jan. 26, 2008 * Moose::Role Moose::Meta::Attribute - - role type tests now support when roles are + - role type tests now support when roles are applied to non-Moose classes (found by ash) - added tests for this (thanks to ash) - couple extra tests to boost code coverage - * Moose::Meta::Method::Constructor + * Moose::Meta::Method::Constructor - improved fix for handling Class::MOP attributes - - added test for this - + - added test for this + * Moose::Meta::Class - handled the add_attribute($attribute_meta_object) case correctly @@ -1429,12 +1429,12 @@ for, noteworthy changes. 0.35 Tues. Jan. 22, 2008 * Moose::Meta::Method::Constructor - - fix to make sure even Class::MOP attributes + - fix to make sure even Class::MOP attributes are handled correctly (Thanks to Dave Rolsky) - added test for this (also Dave Rolsky) - + * Moose::Meta::Class - - improved error message on _apply_all_roles, + - improved error message on _apply_all_roles, you should now use Moose::Util::apply_all_roles and you shouldnt have been using a _ prefixed method in the first place ;) @@ -1445,27 +1445,27 @@ for, noteworthy changes. Moose is now a postmodern object system :) - (see the POD for details) - - * <> - - this release contains a major reworking and - cleanup of the role system + + * <> + - this release contains a major reworking and + cleanup of the role system - 100% backwards compat. - Role application now restructured into seperate classes based on type of applicants - Role summation (combining of more than one role) - is much cleaner and anon-classes are no longer + is much cleaner and anon-classes are no longer used in this process - - new Composite role metaclass + - new Composite role metaclass - runtime application of roles to instances is now more efficient and re-uses generated classes when applicable - + * <> - - methods can now be excluded from a given role + - methods can now be excluded from a given role during composition - - methods can now be aliased to another name (and - still retain the original as well) - + - methods can now be aliased to another name (and + still retain the original as well) + * Moose::Util::TypeConstraints::OptimizedConstraints - added this module (see above) @@ -1482,20 +1482,20 @@ for, noteworthy changes. * Moose::Meta::Method::Accessor Moose::Meta::Method::Constructor Moose::Meta::Attribute - Moose::Meta::TypeConstraint - Moose::Meta::TypeCoercion - - lots of cleanup of such things as: + Moose::Meta::TypeConstraint + Moose::Meta::TypeCoercion + - lots of cleanup of such things as: - generated methods - type constraint handling - - error handling/messages - (thanks to nothingmuch) - + - error handling/messages + (thanks to nothingmuch) + * Moose::Meta::TypeConstraint::Parameterizable - - added this module to support the refactor + - added this module to support the refactor in Moose::Meta::TypeConstraint::Parameterized * Moose::Meta::TypeConstraint::Parameterized - - refactored how these types are handled so they + - refactored how these types are handled so they are more generic and not confined to ArrayRef and HashRef only diff --git a/PLANS b/PLANS index 35c6aa1..b4624ad 100644 --- a/PLANS +++ b/PLANS @@ -1,25 +1,25 @@ ----------------------------------------------------------- -- Type Constraints refactor ------------------------------------------------------------ +----------------------------------------------------------- - add support for locally scoped TC -This would borrow from MooseX::TypeLibrary to prefix the TC with the name -of the package. It would then be accesible from the outside as the fully -scoped name, but the local attributes would use it first. (this would need support +This would borrow from MooseX::TypeLibrary to prefix the TC with the name +of the package. It would then be accesible from the outside as the fully +scoped name, but the local attributes would use it first. (this would need support in the registry for this). - look into sugar extensions -Use roles as sugar layer function providers (ala MooseX::AttributeHelpers). This +Use roles as sugar layer function providers (ala MooseX::AttributeHelpers). This would allow custom metaclasses to provide roles to extend the sugar syntax with. (NOTE: Talk to phaylon a bit more on this) -- allow a switch of some kind to optionally turn TC checking off at runtime +- allow a switch of some kind to optionally turn TC checking off at runtime -The type checks can get expensive and some people have suggested that allowing -the checks to be turned off would be helpful for deploying into performance +The type checks can get expensive and some people have suggested that allowing +the checks to be turned off would be helpful for deploying into performance intensive systems. Perhaps this can actually be done as an option to make_immutable? - misc. minor bits @@ -46,11 +46,11 @@ $tc->check_or_fail($value); * and then something like this: subtype Foo => as Bar => where { ... } => scoped => -global; -subtype Foo => as Bar => where { ... } => scoped => -local; +subtype Foo => as Bar => where { ... } => scoped => -local; -# or +# or -subtype Foo => as Bar => where { ... } => in __PACKAGE__ ; +subtype Foo => as Bar => where { ... } => in __PACKAGE__ ; # or (not sure if it would be possible) @@ -59,7 +59,7 @@ my $Foo = subtype Bar => where { ... }; # ---------- [17:10] stevan: it should do it if I pass coerce => 1 as part of the attribute definition -[17:12] autarch: what I am not 100% sure of is how to tell it to deep coerce and when to not +[17:12] autarch: what I am not 100% sure of is how to tell it to deep coerce and when to not [17:13] cause a basic coerce is from A to B [17:13] hmm [17:13] which is valid for collection types too @@ -78,12 +78,12 @@ coerce_deeply => 1 # reads better - create an official TC registry API (DONE) -Right now the registration of the TC is a by-product of creation in the sugar -layer, this is bad and make extension of TCs difficult. I am not sure if this -registry API should exist as part of Moose::Util::TypeConstraints, or of we -should create a complete registry object itself. +Right now the registration of the TC is a by-product of creation in the sugar +layer, this is bad and make extension of TCs difficult. I am not sure if this +registry API should exist as part of Moose::Util::TypeConstraints, or of we +should create a complete registry object itself. -This registry should be a singleton, but M::U::TC should enforce that lifecycle +This registry should be a singleton, but M::U::TC should enforce that lifecycle choice so that you can use your own registry if you really want too. I mean parent of the registry. So that I can create my own registry @@ -92,20 +92,20 @@ this object would automatically search parent registries as well. - refactor the various TC internals to make it more subclassing friendly (DONE) -This also includes the coercion stuff as well. This should give you what you +This also includes the coercion stuff as well. This should give you what you need to make your object/class bound stuff. - move the container TCs from MooseX::AttributeHelpers into Moose core (DONE) -These have proven so useful for me in the latest $work project that I think +These have proven so useful for me in the latest $work project that I think they should really be core. -- move the details of TC construction that are in Moose.pm and +- move the details of TC construction that are in Moose.pm and Moose::Util::TypeConstraints into the Moose::Meta::TypeConstraint module (DONE) -This will make it much easier to generate TCs on their own, without -having to use the sugar layer. This should also clean up their APIs +This will make it much easier to generate TCs on their own, without +having to use the sugar layer. This should also clean up their APIs as well, which will make it easier to subclass them. ----------------------------------------------------------- diff --git a/README b/README index 99d8c9c..0ffbc96 100644 --- a/README +++ b/README @@ -28,5 +28,5 @@ Copyright (C) 2006-2009 Infinity Interactive, Inc. http://www.iinteractive.com This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +it under the same terms as Perl itself. diff --git a/TODO b/TODO index 7e66a51..9b5d65b 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ ------------------------------------------------------------------------------- BUGS -------------------------------------------------------------------------------- +------------------------------------------------------------------------------- ------------------------------------------------------------------------------- TODO @@ -8,24 +8,24 @@ TODO - DDuncan's Str types -subtype 'Str' - => as 'Value' - => where { Encode::is_utf8( $_[0] ) or $_[0] !~ m/[^0x00-0x7F]/x } +subtype 'Str' + => as 'Value' + => where { Encode::is_utf8( $_[0] ) or $_[0] !~ m/[^0x00-0x7F]/x } => optimize_as { defined($_[0]) && !ref($_[0]) }; -subtype 'Blob' - => as 'Value' - => where { !Encode::is_utf8( $_[0] ) } +subtype 'Blob' + => as 'Value' + => where { !Encode::is_utf8( $_[0] ) } => optimize_as { defined($_[0]) && !ref($_[0]) }; - should handle some moose-specific options in &Moose::Meta::Class::create - things like roles, and method modifiers (although those can probably be + things like roles, and method modifiers (although those can probably be ignored if i want to) - type unions -Add support for doing it with Classes which do not have +Add support for doing it with Classes which do not have a type constraint yet created - type intersections @@ -40,10 +40,10 @@ Mostly just for Roles - proxy attributes a proxied attribute is an attribute -which looks like an attribute, -talks like an attribute, smells -like an attribute,.. but if you -look behind the curtain,.. its +which looks like an attribute, +talks like an attribute, smells +like an attribute,.. but if you +look behind the curtain,.. its over there.. in that other object (... probably be a custom metaclass) @@ -55,15 +55,15 @@ over there.. in that other object [22:57] stevan :P [22:57] stevan are you wanting to reuse it or something? [22:57] stevan my $subtype = subtype 'Something' => where { ... }; -[22:58] stevan then you can do isa => $subtype +[22:58] stevan then you can do isa => $subtype [22:58] mst but I can't subtype it again -[22:59] stevan mst: ahhh... +[22:59] stevan mst: ahhh... [22:59] mst well, I can. but it suddenly gets very "long way round" ish [23:00] stevan my $constraint = Moose::Meta::TypeConstraint->new( [23:00] stevan name => $name || '__ANON__', -[23:00] stevan parent => $parent, -[23:00] stevan constraint => $check, -[23:00] stevan message => $message, +[23:00] stevan parent => $parent, +[23:00] stevan constraint => $check, +[23:00] stevan message => $message, [23:00] stevan ); [23:00] stevan yeah thats kinda the long way [23:00] stevan mst: what would you like it to be? @@ -73,7 +73,7 @@ over there.. in that other object [23:00] stevan hmm [23:00] mst should be all you need to change [23:00] stevan yeah -[23:01] stevan so you can then say +[23:01] stevan so you can then say [23:01] stevan subtype $anon => where { ... }; [23:01] mst right [23:01] stevan ok @@ -85,7 +85,7 @@ over there.. in that other object [13:17] mst so if I'm trying to declare it cast-style per-source-class rather than per-target-class [13:17] mst I am extremely screwed [13:17] stevan yes -[13:17] stevan they are not class specific +[13:17] stevan they are not class specific [13:18] stevan they are attached to the type constraint itself [13:18] * stevan ponders anon-coercion-metaobjects [13:18] mst yes, that's fine @@ -104,9 +104,9 @@ over there.. in that other object [13:32] mst stevan: I want to be able to say in package Bar [13:32] mst stevan: coerce_to 'Foo' via { ... }; [13:32] mst etc. -[13:53] stevan hmm - - +[13:53] stevan hmm + + ------------------------------------------------------------------------------- TO PONDER ------------------------------------------------------------------------------- @@ -114,8 +114,8 @@ TO PONDER - Moose "strict" mode use Moose 'strict'; This would allow us to have all sort of expensive tests -which can be turned off in prod. - +which can be turned off in prod. + - Moose::Philosophy.pod To explain Moose from a very high level @@ -123,6 +123,6 @@ To explain Moose from a very high level - moosedoc We certainly have enough meta-information to make pretty complete POD docs. - - - + + + diff --git a/benchmarks/immutable.pl b/benchmarks/immutable.pl index 0e5fab9..8118511 100644 --- a/benchmarks/immutable.pl +++ b/benchmarks/immutable.pl @@ -23,18 +23,18 @@ coerce 'Foo' use Moose; has 'default' => (is => 'rw', default => 10); - has 'default_sub' => (is => 'rw', default => sub { [] }); + has 'default_sub' => (is => 'rw', default => sub { [] }); has 'lazy' => (is => 'rw', default => 10, lazy => 1); - has 'required' => (is => 'rw', required => 1); - has 'weak_ref' => (is => 'rw', weak_ref => 1); - has 'type_constraint' => (is => 'rw', isa => 'Foo'); - has 'coercion' => (is => 'rw', isa => 'Foo', coerce => 1); - + has 'required' => (is => 'rw', required => 1); + has 'weak_ref' => (is => 'rw', weak_ref => 1); + has 'type_constraint' => (is => 'rw', isa => 'Foo'); + has 'coercion' => (is => 'rw', isa => 'Foo', coerce => 1); + package Bar::Normal; use Moose; - + extends 'Foo::Normal'; - + has 'default_w_type_constraint' => ( is => 'rw', isa => 'Int', @@ -45,40 +45,40 @@ coerce 'Foo' { package Foo::Immutable; use Moose; - + has 'default' => (is => 'rw', default => 10); - has 'default_sub' => (is => 'rw', default => sub { [] }); + has 'default_sub' => (is => 'rw', default => sub { [] }); has 'lazy' => (is => 'rw', default => 10, lazy => 1); - has 'required' => (is => 'rw', required => 1); - has 'weak_ref' => (is => 'rw', weak_ref => 1); - has 'type_constraint' => (is => 'rw', isa => 'Foo'); + has 'required' => (is => 'rw', required => 1); + has 'weak_ref' => (is => 'rw', weak_ref => 1); + has 'type_constraint' => (is => 'rw', isa => 'Foo'); has 'coercion' => (is => 'rw', isa => 'Foo', coerce => 1); - + #sub BUILD { # # ... #} - + Foo::Immutable->meta->make_immutable(debug => 0); - + package Bar::Immutable; use Moose; - - extends 'Foo::Immutable'; - + + extends 'Foo::Immutable'; + has 'default_w_type_constraint' => ( is => 'rw', isa => 'Int', default => 10, - ); - - Bar::Immutable->meta->make_immutable(debug => 0); + ); + + Bar::Immutable->meta->make_immutable(debug => 0); } #__END__ my $foo = Foo->new; -cmpthese(10_000, +cmpthese(10_000, { 'normal' => sub { Foo::Normal->new( @@ -93,7 +93,7 @@ cmpthese(10_000, required => 'BAR', type_constraint => $foo, coercion => [], - weak_ref => {}, + weak_ref => {}, ); }, } diff --git a/benchmarks/method_modifiers.pl b/benchmarks/method_modifiers.pl index 8193298..16f1c5e 100755 --- a/benchmarks/method_modifiers.pl +++ b/benchmarks/method_modifiers.pl @@ -17,7 +17,7 @@ package CMMChild::Before; use Class::Method::Modifiers; use base 'PlainParent'; - + before method => sub { "B" }; } { @@ -32,7 +32,7 @@ package CMMChild::Around; use Class::Method::Modifiers; use base 'PlainParent'; - + around method => sub { shift->() . "A" }; } { @@ -47,7 +47,7 @@ package CMMChild::AllThree; use Class::Method::Modifiers; use base 'PlainParent'; - + before method => sub { "B" }; around method => sub { shift->() . "A" }; after method => sub { "Z" }; diff --git a/benchmarks/simple_class.pl b/benchmarks/simple_class.pl index bb8aef1..f0061f1 100644 --- a/benchmarks/simple_class.pl +++ b/benchmarks/simple_class.pl @@ -7,24 +7,24 @@ use Benchmark::Forking qw[cmpthese]; =pod -This compares the burden of a basic Moose -class to a basic Class::MOP class. +This compares the burden of a basic Moose +class to a basic Class::MOP class. -It is worth noting that the basic Moose -class will also create a type constraint -as well as export many subs, so this comparison +It is worth noting that the basic Moose +class will also create a type constraint +as well as export many subs, so this comparison is really not fair :) =cut -cmpthese(5_000, - { +cmpthese(5_000, + { 'w/out_moose' => sub { eval 'package Bar; use metaclass;'; }, 'w_moose' => sub { eval 'package Baz; use Moose;'; - }, + }, } ); diff --git a/benchmarks/simple_compile.pl b/benchmarks/simple_compile.pl index f12c518..4b5b4a8 100644 --- a/benchmarks/simple_compile.pl +++ b/benchmarks/simple_compile.pl @@ -8,26 +8,26 @@ use Benchmark::Forking qw[cmpthese]; =pod This compare the overhead of Class::MOP -to the overhead of Moose. +to the overhead of Moose. -The goal here is to see how much more +The goal here is to see how much more startup cost Moose adds to Class::MOP. NOTE: -This benchmark may not be all that -relevant really, but it's helpful to +This benchmark may not be all that +relevant really, but it's helpful to see maybe. =cut -cmpthese(5_000, +cmpthese(5_000, { 'w/out_moose' => sub { eval 'use Class::MOP;'; }, 'w_moose' => sub { eval 'use Moose;'; - }, + }, } ); diff --git a/benchmarks/simple_constructor.pl b/benchmarks/simple_constructor.pl index 66c0ac3..def63ed 100644 --- a/benchmarks/simple_constructor.pl +++ b/benchmarks/simple_constructor.pl @@ -10,11 +10,11 @@ my $num_iterations = shift || 100; use Moose; has 'default' => (is => 'rw', default => 10); - has 'default_sub' => (is => 'rw', default => sub { [] }); + has 'default_sub' => (is => 'rw', default => sub { [] }); has 'lazy' => (is => 'rw', default => 10, lazy => 1); - has 'required' => (is => 'rw', required => 1); - has 'weak_ref' => (is => 'rw', weak_ref => 1); - has 'type_constraint' => (is => 'rw', isa => 'ArrayRef'); + has 'required' => (is => 'rw', required => 1); + has 'weak_ref' => (is => 'rw', weak_ref => 1); + has 'type_constraint' => (is => 'rw', isa => 'ArrayRef'); } foreach (0 .. $num_iterations) { diff --git a/benchmarks/type_constraints.pl b/benchmarks/type_constraints.pl index 8af49ef..e9b29f8 100644 --- a/benchmarks/type_constraints.pl +++ b/benchmarks/type_constraints.pl @@ -7,8 +7,8 @@ use Benchmark qw[cmpthese]; =pod -This benchmark compares the overhead of a -auto-created type constraint vs. none at +This benchmark compares the overhead of a +auto-created type constraint vs. none at all vs. a custom-created type. =cut @@ -17,16 +17,16 @@ all vs. a custom-created type. package Foo; use Moose; use Moose::Util::TypeConstraints; - + has 'baz' => (is => 'rw'); has 'bar' => (is => 'rw', isa => 'Foo'); } { package Bar; - + sub new { bless {} => __PACKAGE__ } - sub bar { + sub bar { my $self = shift; $self->{bar} = shift if @_; $self->{bar}; @@ -36,7 +36,7 @@ all vs. a custom-created type. my $foo = Foo->new; my $bar = Bar->new; -cmpthese(200_000, +cmpthese(200_000, { 'hand coded' => sub { $bar->bar($bar); @@ -45,8 +45,8 @@ cmpthese(200_000, $foo->baz($foo); }, 'w_constraint' => sub { - $foo->bar($foo); - }, + $foo->bar($foo); + }, } ); diff --git a/doc/moosex-compile b/doc/moosex-compile index 7d72f81..7d0a049 100644 --- a/doc/moosex-compile +++ b/doc/moosex-compile @@ -20,7 +20,7 @@ TODO: PLEASE EDIT ME 19:23 except without the Moose test suite's assumptions 19:23 about state and module loading, and all that 19:24 and doing that is a much more daunting prospect than hacking on MXC itself -19:24 understood. the problem is that I still don't have a good sense of how to get it going, even manually +19:24 understood. the problem is that I still don't have a good sense of how to get it going, even manually 19:24 ah 19:24 none of the test files seem to show off what I need 19:24 i can walk you through thjat @@ -105,7 +105,7 @@ TODO: PLEASE EDIT ME 19:36 my tests aren't scientific. 19:36 trunk moose as of you sending me nytprofs 19:37 actually that's CPAN moose now -19:37 0.35 - 0.45 +19:37 0.35 - 0.45 19:37 ouch 19:37 well, part of the problem is that it loads *EVERYTHING* 19:37 every type of meta method class, meta type constraint, the role system, etc @@ -170,7 +170,7 @@ TODO: PLEASE EDIT ME 19:46 yeah. but the goal is to turn it into written docs. 19:46 ok. for now, it should end up in MooseX-Compile/doc/design 19:46 sounds good -19:46 . o O { Thank god I don't have a moose commit bit } +19:46 . o O { Thank god I don't have a moose commit bit } 19:47 though most of this affects moose itself though 19:47 * obra nods 19:47 Moose/doc/moosex-compile, then diff --git a/lib/Moose.pm b/lib/Moose.pm index c4f714d..83224d5 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -44,7 +44,7 @@ sub _caller_info { } sub throw_error { - # FIXME This + # FIXME This shift; goto \&confess } @@ -362,7 +362,7 @@ or coercion. =head1 PROVIDED METHODS -Moose provides a number of methods to all your classes, mostly through the +Moose provides a number of methods to all your classes, mostly through the inheritance of L. There is however, one exception. =over 4 @@ -392,7 +392,7 @@ superclasses still properly inherit from L. =item B -This will apply a given set of C<@roles> to the local class. +This will apply a given set of C<@roles> to the local class. =item B %options> @@ -495,9 +495,9 @@ almost never want to do this, since it usually breaks your class. As with overriding locally defined methods, if you do want to do this, you should do it manually, not with Moose. -You do not I to have a reader (or accessor) for the attribute in order -to delegate to it. Moose will create a means of accessing the value for you, -however this will be several times B efficient then if you had given +You do not I to have a reader (or accessor) for the attribute in order +to delegate to it. Moose will create a means of accessing the value for you, +however this will be several times B efficient then if you had given the attribute a reader (or accessor) to use. Below is the documentation for each option format: @@ -581,7 +581,7 @@ a HASH ref) of the methods you want mapped. This tells the class to use a custom attribute metaclass for this particular attribute. Custom attribute metaclasses are useful for extending the capabilities of the I keyword: they are the simplest way to extend the MOP, -but they are still a fairly advanced topic and too much to cover here, see +but they are still a fairly advanced topic and too much to cover here, see L for more information. The default behavior here is to just load C<$metaclass_name>; however, we also @@ -594,8 +594,8 @@ B as the metaclass name. =item I [ @role_names ]> -This tells Moose to take the list of C<@role_names> and apply them to the -attribute meta-object. This is very similar to the I option, but +This tells Moose to take the list of C<@role_names> and apply them to the +attribute meta-object. This is very similar to the I option, but allows you to use more than one extension at a time. See L for details on how a trait name is @@ -654,7 +654,7 @@ information. =item B %options> This is variation on the normal attribute creator C which allows you to -clone and extend an attribute from a superclass or from a role. Here is an +clone and extend an attribute from a superclass or from a role. Here is an example of the superclass usage: package Foo; @@ -695,12 +695,12 @@ Here is another example, but within the context of a role: has '+message' => (default => 'Hello I am My::Foo'); -In this case, we are basically taking the attribute which the role supplied -and altering it within the bounds of this feature. +In this case, we are basically taking the attribute which the role supplied +and altering it within the bounds of this feature. -Aside from where the attributes come from (one from superclass, the other -from a role), this feature works exactly the same. This feature is restricted -somewhat, so as to try and force at least I sanity into it. You are only +Aside from where the attributes come from (one from superclass, the other +from a role), this feature works exactly the same. This feature is restricted +somewhat, so as to try and force at least I sanity into it. You are only allowed to change the following attributes: =over 4 @@ -727,12 +727,12 @@ Change if the attribute lazily initializes the slot. =item I -You I allowed to change the type without restriction. +You I allowed to change the type without restriction. -It is recommended that you use this freedom with caution. We used to -only allow for extension only if the type was a subtype of the parent's -type, but we felt that was too restrictive and is better left as a -policy decision. +It is recommended that you use this freedom with caution. We used to +only allow for extension only if the type was a subtype of the parent's +type, but we felt that was too restrictive and is better left as a +policy decision. =item I @@ -797,7 +797,7 @@ C work is best described in the L. =item B This is the C function, and exported here because I use it -all the time. +all the time. =item B @@ -941,11 +941,11 @@ unresolvable conflict. =head2 The MooseX:: namespace -Generally if you're writing an extension I Moose itself you'll want -to put your extension in the C namespace. This namespace is -specifically for extensions that make Moose better or different in some -fundamental way. It is traditionally B for a package that just happens -to use Moose. This namespace follows from the examples of the C +Generally if you're writing an extension I Moose itself you'll want +to put your extension in the C namespace. This namespace is +specifically for extensions that make Moose better or different in some +fundamental way. It is traditionally B for a package that just happens +to use Moose. This namespace follows from the examples of the C and C namespaces that perform the same function for C and C respectively. @@ -1034,7 +1034,7 @@ See L for extensions. =item The Art of the MetaObject Protocol -I mention this in the L docs too, this book was critical in +I mention this in the L docs too, this book was critical in the development of both modules and is highly recommended. =back @@ -1059,24 +1059,24 @@ to cpan-RT. =head1 FEATURE REQUESTS -We are very strict about what features we add to the Moose core, especially -the user-visible features. Instead we have made sure that the underlying -meta-system of Moose is as extensible as possible so that you can add your -own features easily. That said, occasionally there is a feature needed in the -meta-system to support your planned extension, in which case you should +We are very strict about what features we add to the Moose core, especially +the user-visible features. Instead we have made sure that the underlying +meta-system of Moose is as extensible as possible so that you can add your +own features easily. That said, occasionally there is a feature needed in the +meta-system to support your planned extension, in which case you should either email the mailing list or join us on irc at #moose to discuss. The L has more detail about how and when you can contribute. =head1 AUTHOR -Moose is an open project, there are at this point dozens of people who have -contributed, and can contribute. If you have added anything to the Moose +Moose is an open project, there are at this point dozens of people who have +contributed, and can contribute. If you have added anything to the Moose project you have a commit bit on this file and can add your name to the list. =head2 CABAL -However there are only a few people with the rights to release a new version +However there are only a few people with the rights to release a new version of Moose. The Moose Cabal are the people to go to with questions regarding the wider purview of Moose, and help out maintaining not just the code but the community as well. diff --git a/lib/Moose/Cookbook/Basics/Recipe1.pod b/lib/Moose/Cookbook/Basics/Recipe1.pod index 4e5fb91..bd1239b 100644 --- a/lib/Moose/Cookbook/Basics/Recipe1.pod +++ b/lib/Moose/Cookbook/Basics/Recipe1.pod @@ -216,7 +216,7 @@ L). =item Method Modifiers -The concept of method modifiers is directly ripped off from CLOS. A +The concept of method modifiers is directly ripped off from CLOS. A great explanation of them can be found by following this link. L diff --git a/lib/Moose/Cookbook/FAQ.pod b/lib/Moose/Cookbook/FAQ.pod index 9a54c6a..9437881 100644 --- a/lib/Moose/Cookbook/FAQ.pod +++ b/lib/Moose/Cookbook/FAQ.pod @@ -11,42 +11,42 @@ Moose::Cookbook::FAQ - Frequently asked questions about Moose =head3 Is Moose "production ready"? -Yes. I have several medium-to-large-ish web applications in -production using Moose, they have been running without -issue now for well over a year. +Yes. I have several medium-to-large-ish web applications in +production using Moose, they have been running without +issue now for well over a year. -At C<$work> we are re-writing our core offering to use Moose, -so its continued development is assured. +At C<$work> we are re-writing our core offering to use Moose, +so its continued development is assured. -Several other people on #moose either have apps in production -which use Moose, or are in the process of deploying sites -which use Moose. +Several other people on #moose either have apps in production +which use Moose, or are in the process of deploying sites +which use Moose. =head3 Is Moose's API stable? Yes and No. The external API, the one 90% of users will interact -with, is B and any changes B. The introspection API is I stable; I still -reserve the right to tweak that if needed, but I will do my +with, is B and any changes B. The introspection API is I stable; I still +reserve the right to tweak that if needed, but I will do my absolute best to maintain backwards compatibility here as well. =head3 I heard Moose is slow, is this true? Again, this one is tricky, so Yes I No. -First let me say that I in life is free, and that some -Moose features do cost more than others. It is also the -policy of Moose to B, -and to do our absolute best to not place any extra burdens on -the execution of your code for features you are not using. Of -course using Moose itself does involve some overhead, but it -is mostly compile time. At this point we do have some options -available for getting the speed you need. - -Currently we have the option of making your classes immutable -as a means of boosting speed. This will mean a slightly larger compile +First let me say that I in life is free, and that some +Moose features do cost more than others. It is also the +policy of Moose to B, +and to do our absolute best to not place any extra burdens on +the execution of your code for features you are not using. Of +course using Moose itself does involve some overhead, but it +is mostly compile time. At this point we do have some options +available for getting the speed you need. + +Currently we have the option of making your classes immutable +as a means of boosting speed. This will mean a slightly larger compile time cost, but the runtime speed increase (especially in object -construction) is pretty significant. This is not very well +construction) is pretty significant. This is not very well documented yet, so please ask on the list or on #moose for more information. @@ -67,15 +67,15 @@ Ideally, you should never write your own C method, and should use Moose's other features to handle your specific object construction needs. Here are a few scenarios, and the Moose way to solve them; -If you need to call initialization code post instance construction, -then use the C method. This feature is taken directly from -Perl 6. Every C method in your inheritance chain is called -(in the correct order) immediately after the instance is constructed. -This allows you to ensure that all your superclasses are initialized +If you need to call initialization code post instance construction, +then use the C method. This feature is taken directly from +Perl 6. Every C method in your inheritance chain is called +(in the correct order) immediately after the instance is constructed. +This allows you to ensure that all your superclasses are initialized properly as well. This is the best approach to take (when possible) because it makes subclassing your class much easier. -If you need to affect the constructor's parameters prior to the +If you need to affect the constructor's parameters prior to the instance actually being constructed, you have a number of options. To change the parameter processing as a whole, you can use @@ -90,7 +90,7 @@ argument values into the correct expected types. This approach is the most flexible and robust, but does have a slightly higher learning curve. -=head3 How do I make non-Moose constructors work with Moose? +=head3 How do I make non-Moose constructors work with Moose? Usually the correct approach to subclassing a non Moose class is delegation. Moose makes this easy using the C keyword, @@ -110,10 +110,10 @@ instantiate your Moose attributes: package My::HTML::Template; use Moose; - - # explicit inheritance + + # explicit inheritance extends 'HTML::Template', 'Moose::Object'; - + # explicit constructor sub new { my $class = shift; @@ -127,41 +127,41 @@ instantiate your Moose attributes: ); } -Of course, this only works if both your Moose class and the -inherited non-Moose class use the same instance type (typically +Of course, this only works if both your Moose class and the +inherited non-Moose class use the same instance type (typically HASH refs). Note that this doesn't call C automatically, you must do that yourself. -Other techniques can be used as well, such as creating the object -using C, but calling the inherited non-Moose -class's initialization methods (if available). +Other techniques can be used as well, such as creating the object +using C, but calling the inherited non-Moose +class's initialization methods (if available). It is also entirely possible to just rely on HASH autovivification to create the slots needed for Moose based attributes, although this does restrict use of construction time attribute features somewhat. -In short, there are several ways to go about this, it is best to -evaluate each case based on the class you wish to extend, and the -features you wish to employ. As always, both IRC and the mailing +In short, there are several ways to go about this, it is best to +evaluate each case based on the class you wish to extend, and the +features you wish to employ. As always, both IRC and the mailing list are great ways to get help finding the best approach. =head2 Accessors =head3 How do I tell Moose to use get/set accessors? -The easiest way to accomplish this is to use the C and +The easiest way to accomplish this is to use the C and C attribute options. Here is some example code: has 'bar' => ( isa => 'Baz', - reader => 'get_bar', + reader => 'get_bar', writer => 'set_bar', ); -Moose will still take advantage of type constraints, triggers, etc. -when creating these methods. +Moose will still take advantage of type constraints, triggers, etc. +when creating these methods. If you do not like this much typing, and wish it to be a default for your class, please see L. This will allow you to write: @@ -174,44 +174,44 @@ class, please see L. This will allow you to write: And have Moose create separate C and C methods instead of a single C method. -NOTE: This B be set globally in Moose, as that would break +NOTE: This B be set globally in Moose, as that would break other classes which are built with Moose. =head3 How can I get Moose to inflate/deflate values in the accessor? -Well, the first question to ask is if you actually need both inflate +Well, the first question to ask is if you actually need both inflate and deflate. -If you only need to inflate, then I suggest using coercions. Here is +If you only need to inflate, then I suggest using coercions. Here is some basic sample code for inflating a L object: subtype 'DateTime' => as 'Object' => where { $_->isa('DateTime') }; - + coerce 'DateTime' => from 'Str' => via { DateTime::Format::MySQL->parse_datetime($_) }; - + has 'timestamp' => (is => 'rw', isa => 'DateTime', coerce => 1); -This creates a custom subtype for L objects, then attaches -a coercion to that subtype. The C attribute is then told +This creates a custom subtype for L objects, then attaches +a coercion to that subtype. The C attribute is then told to expect a C type, and to try to coerce it. When a C -type is given to the C accessor, it will attempt to -coerce the value into a C object using the code in found -in the C block. +type is given to the C accessor, it will attempt to +coerce the value into a C object using the code in found +in the C block. For a more comprehensive example of using coercions, see the L. -If you need to deflate your attribute, the current best practice is to +If you need to deflate your attribute, the current best practice is to add an C modifier to your accessor. Here is some example code: - # a timestamp which stores as + # a timestamp which stores as # seconds from the epoch has 'timestamp' => (is => 'rw', isa => 'Int'); - + around 'timestamp' => sub { my $next = shift; my ($self, $timestamp) = @_; @@ -219,28 +219,28 @@ add an C modifier to your accessor. Here is some example code: $next->($self, $timestamp->epoch); }; -It is also possible to do deflation using coercion, but this tends -to get quite complex and require many subtypes. An example of this -is outside the scope of this document, ask on #moose or send a mail +It is also possible to do deflation using coercion, but this tends +to get quite complex and require many subtypes. An example of this +is outside the scope of this document, ask on #moose or send a mail to the list. -Still another option is to write a custom attribute metaclass, which -is also outside the scope of this document, but I would be happy to +Still another option is to write a custom attribute metaclass, which +is also outside the scope of this document, but I would be happy to explain it on #moose or the mailing list. =head2 Method Modifiers =head3 How can I affect the values in C<@_> using C? -You can't, actually: C only runs before the main method, -and it cannot easily affect the method's execution. What you want is -an C method. +You can't, actually: C only runs before the main method, +and it cannot easily affect the method's execution. What you want is +an C method. =head3 Can I use C to stop execution of a method? -Yes, but only if you throw an exception. If this is too drastic a -measure then I suggest using C instead. The C method -modifier is the only modifier which can gracefully prevent execution +Yes, but only if you throw an exception. If this is too drastic a +measure then I suggest using C instead. The C method +modifier is the only modifier which can gracefully prevent execution of the main method. Here is an example: around 'baz' => sub { @@ -252,7 +252,7 @@ of the main method. Here is an example: $next->($self, %options); }; -By choosing not to call the C<$next> method, you can stop the +By choosing not to call the C<$next> method, you can stop the execution of the main method. =head2 Type Constraints @@ -261,24 +261,24 @@ execution of the main method. Use the C option when building the subtype, like so: - subtype 'NaturalLessThanTen' + subtype 'NaturalLessThanTen' => as 'Natural' => where { $_ < 10 } => message { "This number ($_) is not less than ten!" }; This will be called when a value fails to pass the C -constraint check. +constraint check. =head3 Can I turn off type constraint checking? -Not yet, but soon. This option will likely be coming in the next +Not yet, but soon. This option will likely be coming in the next release. =head2 Roles =head3 How do I get Moose to call BUILD in all my composed roles? -See L and specifically the B and specifically the B question in the B section. =head3 What are Traits, and how are they different from Roles? diff --git a/lib/Moose/Cookbook/WTF.pod b/lib/Moose/Cookbook/WTF.pod index 529409e..c62f3ef 100644 --- a/lib/Moose/Cookbook/WTF.pod +++ b/lib/Moose/Cookbook/WTF.pod @@ -11,52 +11,52 @@ Moose::Cookbook::WTF - For when things go wrong with Moose =head3 Why is my code taking so long to load? -Moose does have a compile time performance burden, -which it inherits from Class::MOP. If load/compile -time is a concern for your application, Moose may not -be the right tool for you. +Moose does have a compile time performance burden, +which it inherits from Class::MOP. If load/compile +time is a concern for your application, Moose may not +be the right tool for you. -Although, you should note that we are exploring the -use of L to try and reduce this problem, +Although, you should note that we are exploring the +use of L to try and reduce this problem, but nothing is ready yet. =head3 Why are my objects taking so long to construct? -Moose uses a lot of introspection when constructing an -instance, and introspection can be slow. This problem -can be solved by making your class immutable. This can +Moose uses a lot of introspection when constructing an +instance, and introspection can be slow. This problem +can be solved by making your class immutable. This can be done with the following code: MyClass->meta->make_immutable(); Moose will then memoize a number of meta-level methods -and inline a constructor for you. For more information -on this see the L section below and in the +and inline a constructor for you. For more information +on this see the L section below and in the L. =head2 Constructors & Immutability =head3 I made my class immutable, but C is still slow! -Do you have a custom C method in your class? Moose -will not overwrite your custom C method, you would -probably do better to try and convert this to use the -C method or possibly set C values in -the attribute declaration. +Do you have a custom C method in your class? Moose +will not overwrite your custom C method, you would +probably do better to try and convert this to use the +C method or possibly set C values in +the attribute declaration. -=head3 I made my class immutable, and now my (before | after | +=head3 I made my class immutable, and now my (before | after | around) C is not being called? -Making a I, I or I wrap around the -C method will actually create a C method within +Making a I, I or I wrap around the +C method will actually create a C method within your class. This will prevent Moose from creating one itself -when you make the class immutable. +when you make the class immutable. =head2 Accessors =head3 I created an attribute, where are my accessors? -Accessors are B created implicitly, you B ask Moose +Accessors are B created implicitly, you B ask Moose to create them for you. My guess is that you have this: has 'foo' => (isa => 'Bar'); @@ -65,46 +65,46 @@ when what you really want to say is: has 'foo' => (isa => 'Bar', is => 'rw'); -The reason this is so is because it is a perfectly valid use -case to I have an accessor. The simplest one is that you +The reason this is so is because it is a perfectly valid use +case to I have an accessor. The simplest one is that you want to write your own. If Moose created one automatically, then -because of the order in which classes are constructed, Moose -would overwrite your custom accessor. You wouldn't want that +because of the order in which classes are constructed, Moose +would overwrite your custom accessor. You wouldn't want that would you? =head2 Method Modifiers =head3 Why can't I change C<@_> in a C modifier? -The C modifier is called I the main method. -Its return values are simply ignored, and are B passed onto -the main method body. +The C modifier is called I the main method. +Its return values are simply ignored, and are B passed onto +the main method body. -There are a number of reasons for this, but those arguments are -too lengthy for this document. Instead, I suggest using an C +There are a number of reasons for this, but those arguments are +too lengthy for this document. Instead, I suggest using an C modifier instead. Here is some sample code: around 'foo' => sub { my $next = shift; my ($self, @args) = @_; - # do something silly here to @args - $next->($self, reverse(@args)); + # do something silly here to @args + $next->($self, reverse(@args)); }; =head3 Why can't I see return values in an C modifier? -As with the C modifier, the C modifier is simply -called I the main method. It is passed the original contents -of C<@_> and B the return values of the main method. +As with the C modifier, the C modifier is simply +called I the main method. It is passed the original contents +of C<@_> and B the return values of the main method. -Again, the arguments are too lengthy as to why this has to be. And +Again, the arguments are too lengthy as to why this has to be. And as with C I recommend using an C modifier instead. Here is some sample code: around 'foo' => sub { my $next = shift; my ($self, @args) = @_; - my @rv = $next->($self, @args); + my @rv = $next->($self, @args); # do something silly with the return values return reverse @rv; }; @@ -136,43 +136,43 @@ See L. =head3 Why is BUILD not called for my composed roles? -BUILD is never called in composed roles. The primary reason is that -roles are B order sensitive. Roles are composed in such a way -that the order of composition does not matter (for information on -the deeper theory of this read the original traits papers here -L). +BUILD is never called in composed roles. The primary reason is that +roles are B order sensitive. Roles are composed in such a way +that the order of composition does not matter (for information on +the deeper theory of this read the original traits papers here +L). -Because roles are essentially unordered, it would be impossible to -determine the order in which to execute the BUILD methods. +Because roles are essentially unordered, it would be impossible to +determine the order in which to execute the BUILD methods. As for alternate solutions, there are a couple. =over 4 -=item * +=item * -Using a combination of lazy and default in your attributes to +Using a combination of lazy and default in your attributes to defer initialization (see the Binary Tree example in the cookbook for a good example of lazy/default usage L) =item * -Use attribute triggers, which fire after an attribute is set, to facilitate -initialization. These are described in the L docs, and examples can be +Use attribute triggers, which fire after an attribute is set, to facilitate +initialization. These are described in the L docs, and examples can be found in the test suite. =back -In general, roles should not I initialization; they should either -provide sane defaults or should be documented as needing specific +In general, roles should not I initialization; they should either +provide sane defaults or should be documented as needing specific initialization. One such way to "document" this is to have a separate -attribute initializer which is required for the role. Here is an example of +attribute initializer which is required for the role. Here is an example of how to do this: package My::Role; use Moose::Role; - + has 'height' => ( is => 'rw', isa => 'Int', @@ -180,15 +180,15 @@ how to do this: default => sub { my $self = shift; $self->init_height; - } + } ); - + requires 'init_height'; -In this example, the role will not compose successfully unless the class -provides a C method. +In this example, the role will not compose successfully unless the class +provides a C method. -If none of those solutions work, then it is possible that a role is not +If none of those solutions work, then it is possible that a role is not the best tool for the job, and you really should be using classes. Or, at the very least, you should reduce the amount of functionality in your role so that it does not require initialization. diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 7690324..217c1ec 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -51,8 +51,8 @@ __PACKAGE__->meta->add_attribute('traits' => ( predicate => 'has_applied_traits', )); -# we need to have a ->does method in here to -# more easily support traits, and the introspection +# we need to have a ->does method in here to +# more easily support traits, and the introspection # of those traits. We extend the does check to look # for metatrait aliases. sub does { @@ -84,7 +84,7 @@ sub interpolate_class_and_new { my ($class, $name, @args) = @_; my ( $new_class, @traits ) = $class->interpolate_class(@args); - + $new_class->new($name, @args, ( scalar(@traits) ? ( traits => \@traits ) : () ) ); } @@ -95,7 +95,7 @@ sub interpolate_class { if ( my $metaclass_name = delete $options{metaclass} ) { my $new_class = Moose::Util::resolve_metaclass_alias( Attribute => $metaclass_name ); - + if ( $class ne $new_class ) { if ( $new_class->can("interpolate_class") ) { return $new_class->interpolate_class(%options); @@ -142,8 +142,8 @@ sub interpolate_class { # ... my @legal_options_for_inheritance = qw( - default coerce required - documentation lazy handles + default coerce required + documentation lazy handles builder type_constraint definition_context lazy_build @@ -152,43 +152,43 @@ my @legal_options_for_inheritance = qw( sub legal_options_for_inheritance { @legal_options_for_inheritance } # NOTE/TODO -# This method *must* be able to handle -# Class::MOP::Attribute instances as -# well. Yes, I know that is wrong, but -# apparently we didn't realize it was -# doing that and now we have some code -# which is dependent on it. The real -# solution of course is to push this +# This method *must* be able to handle +# Class::MOP::Attribute instances as +# well. Yes, I know that is wrong, but +# apparently we didn't realize it was +# doing that and now we have some code +# which is dependent on it. The real +# solution of course is to push this # feature back up into Class::MOP::Attribute # but I not right now, I am too lazy. -# However if you are reading this and -# looking for something to do,.. please +# However if you are reading this and +# looking for something to do,.. please # be my guest. # - stevan sub clone_and_inherit_options { my ($self, %options) = @_; - + my %copy = %options; - + my %actual_options; - + # NOTE: # we may want to extends a Class::MOP::Attribute - # in which case we need to be able to use the - # core set of legal options that have always + # in which case we need to be able to use the + # core set of legal options that have always # been here. But we allows Moose::Meta::Attribute # instances to changes them. # - SL my @legal_options = $self->can('legal_options_for_inheritance') ? $self->legal_options_for_inheritance : @legal_options_for_inheritance; - + foreach my $legal_option (@legal_options) { if (exists $options{$legal_option}) { $actual_options{$legal_option} = $options{$legal_option}; delete $options{$legal_option}; } - } + } if ($options{isa}) { my $type_constraint; @@ -204,7 +204,7 @@ sub clone_and_inherit_options { $actual_options{type_constraint} = $type_constraint; delete $options{isa}; } - + if ($options{does}) { my $type_constraint; if (blessed($options{does}) && $options{does}->isa('Moose::Meta::TypeConstraint')) { @@ -218,10 +218,10 @@ sub clone_and_inherit_options { $actual_options{type_constraint} = $type_constraint; delete $options{does}; - } + } # NOTE: - # this doesn't apply to Class::MOP::Attributes, + # this doesn't apply to Class::MOP::Attributes, # so we can ignore it for them. # - SL if ($self->can('interpolate_class')) { @@ -276,7 +276,7 @@ sub _process_options { ## is => rw, accessor => _foo # turns into (accessor => _foo) ## is => ro, accessor => _foo # error, accesor is rw ### ------------------------- - + if ($options->{is} eq 'ro') { $class->throw_error("Cannot define an accessor name on a read-only attribute, accessors are read/write", data => $options) if exists $options->{accessor}; @@ -353,7 +353,7 @@ sub _process_options { if ($name =~ /^_/) { $options->{clearer} ||= "_clear${name}"; $options->{predicate} ||= "_has${name}"; - } + } else { $options->{clearer} ||= "clear_${name}"; $options->{predicate} ||= "has_${name}"; @@ -380,7 +380,7 @@ sub initialize_instance_slot { my $value_is_set; if ( defined($init_arg) and exists $params->{$init_arg}) { $val = $params->{$init_arg}; - $value_is_set = 1; + $value_is_set = 1; } else { # skip it if it's lazy @@ -394,7 +394,7 @@ sub initialize_instance_slot { if ($self->has_default) { $val = $self->default($instance); $value_is_set = 1; - } + } elsif ($self->has_builder) { $val = $self->_call_builder($instance); $value_is_set = 1; @@ -431,8 +431,8 @@ sub _call_builder { ## Slot management # FIXME: -# this duplicates too much code from -# Class::MOP::Attribute, we need to +# this duplicates too much code from +# Class::MOP::Attribute, we need to # refactor these bits eventually. # - SL sub _set_initial_slot_value { @@ -454,7 +454,7 @@ sub _set_initial_slot_value { $meta_instance->set_slot_value($instance, $slot_name, $val); }; - + my $initializer = $self->initializer; # most things will just want to set a value, so make it first arg @@ -582,7 +582,7 @@ sub install_delegation { my $method = $self->_make_delegation_method($handle, $method_to_call); $self->associated_class->add_method($method->name, $method); - } + } } sub remove_delegation { @@ -624,7 +624,7 @@ sub _canonicalize_handles { (blessed $role_meta && $role_meta->isa('Moose::Meta::Role')) || $self->throw_error("Unable to canonicalize the 'handles' option with $handles because its metaclass is not a Moose::Meta::Role", data => $handles); - + return map { $_ => $_ } ( $role_meta->get_method_list, $role_meta->get_required_method_list diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 229b073..56934ea 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -55,13 +55,13 @@ __PACKAGE__->meta->add_attribute('error_class' => ( sub initialize { my $class = shift; my $pkg = shift; - return Class::MOP::get_metaclass_by_name($pkg) + return Class::MOP::get_metaclass_by_name($pkg) || $class->SUPER::initialize($pkg, 'attribute_metaclass' => 'Moose::Meta::Attribute', 'method_metaclass' => 'Moose::Meta::Method', 'instance_metaclass' => 'Moose::Meta::Instance', @_ - ); + ); } sub _immutable_options { @@ -79,7 +79,7 @@ sub _immutable_options { sub create { my ($self, $package_name, %options) = @_; - + (ref $options{roles} eq 'ARRAY') || $self->throw_error("You must pass an ARRAY ref of roles", data => $options{roles}) if exists $options{roles}; @@ -90,7 +90,7 @@ sub create { if ($roles) { Moose::Util::apply_all_roles( $class, @$roles ); } - + return $class; } @@ -110,17 +110,17 @@ sub create_anon_class { my ($self, %options) = @_; my $cache_ok = delete $options{cache}; - + # something like Super::Class|Super::Class::2=Role|Role::1 my $cache_key = join '=' => ( join('|', @{$options{superclasses} || []}), join('|', sort @{$options{roles} || []}), ); - + if ($cache_ok && defined $ANON_CLASSES{$cache_key}) { return $ANON_CLASSES{$cache_key}; } - + my $new_class = $self->SUPER::create_anon_class(%options); $ANON_CLASSES{$cache_key} = $new_class @@ -242,8 +242,8 @@ sub add_attribute { my $self = shift; $self->SUPER::add_attribute( (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute') - ? $_[0] - : $self->_process_attribute(@_)) + ? $_[0] + : $self->_process_attribute(@_)) ); } diff --git a/lib/Moose/Meta/Instance.pm b/lib/Moose/Meta/Instance.pm index 862d123..ff6128d 100644 --- a/lib/Moose/Meta/Instance.pm +++ b/lib/Moose/Meta/Instance.pm @@ -43,7 +43,7 @@ C is a subclass of L. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/Method.pm b/lib/Moose/Meta/Method.pm index 686c56e..b2acd5b 100644 --- a/lib/Moose/Meta/Method.pm +++ b/lib/Moose/Meta/Method.pm @@ -53,7 +53,7 @@ C is a subclass of L. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/Method/Accessor.pm b/lib/Moose/Meta/Method/Accessor.pm index e695e64..e4a5f29 100644 --- a/lib/Moose/Meta/Method/Accessor.pm +++ b/lib/Moose/Meta/Method/Accessor.pm @@ -120,12 +120,12 @@ sub _inline_post_body { '' } sub _inline_check_constraint { my ($self, $value) = @_; - + my $attr = $self->associated_attribute; my $attr_name = $attr->name; - + return '' unless $attr->has_type_constraint; - + my $type_constraint_name = $attr->type_constraint->name; qq{\$type_constraint->($value) || } . $self->_inline_throw_error(qq{"Attribute ($attr_name) does not pass the type constraint because: " . \$type_constraint_obj->get_message($value)}, "data => $value") . ";"; @@ -135,7 +135,7 @@ sub _inline_check_coercion { my ($self, $value) = @_; my $attr = $self->associated_attribute; - + return '' unless $attr->should_coerce; return "$value = \$attr->type_constraint->coerce($value);"; } @@ -145,7 +145,7 @@ sub _inline_check_required { my $attr = $self->associated_attribute; my $attr_name = $attr->name; - + return '' unless $attr->is_required; return qq{(\@_ >= 2) || } . $self->_inline_throw_error(qq{"Attribute ($attr_name) is required, so cannot be set to undef"}) . ';' # defined $_[1] is not good enough } @@ -166,7 +166,7 @@ sub _inline_check_lazy { if ($attr->has_default || $attr->has_builder) { if ($attr->has_default) { $code .= ' my $default = $attr->default(' . $instance . ');'."\n"; - } + } elsif ($attr->has_builder) { $code .= ' my $default;'."\n". ' if(my $builder = '.$instance.'->can($attr->builder)){ '."\n". @@ -177,22 +177,22 @@ sub _inline_check_lazy { $code .= $self->_inline_check_coercion('$default') . "\n"; $code .= $self->_inline_check_constraint('$default') . "\n"; $code .= ' ' . $self->_inline_init_slot($attr, $instance, $slot_access, '$default') . "\n"; - } + } else { $code .= ' ' . $self->_inline_init_slot($attr, $instance, $slot_access, 'undef') . "\n"; } } else { if ($attr->has_default) { - $code .= ' ' . $self->_inline_init_slot($attr, $instance, $slot_access, ('$attr->default(' . $instance . ')')) . "\n"; - } + $code .= ' ' . $self->_inline_init_slot($attr, $instance, $slot_access, ('$attr->default(' . $instance . ')')) . "\n"; + } elsif ($attr->has_builder) { - $code .= ' if (my $builder = '.$instance.'->can($attr->builder)) { ' . "\n" - . ' ' . $self->_inline_init_slot($attr, $instance, $slot_access, ($instance . '->$builder')) + $code .= ' if (my $builder = '.$instance.'->can($attr->builder)) { ' . "\n" + . ' ' . $self->_inline_init_slot($attr, $instance, $slot_access, ($instance . '->$builder')) . "\n } else {\n" . ' ' . $self->_inline_throw_error(q{sprintf "%s does not support builder method '%s' for attribute '%s'", ref(} . $instance . ') || '.$instance.', $attr->builder, $attr->name') . ';'. "\n }"; - } + } else { $code .= ' ' . $self->_inline_init_slot($attr, $instance, $slot_access, 'undef') . "\n"; } @@ -208,15 +208,15 @@ sub _inline_init_slot { } else { return ($slot_access . ' = ' . $value . ';'); - } + } } sub _inline_store { my ($self, $instance, $value) = @_; my $attr = $self->associated_attribute; - + my $mi = $attr->associated_class->get_meta_instance; - + my $code = $mi->inline_set_slot_value($instance, $attr->slots, $value) . ";"; $code .= $mi->inline_weaken_slot_value($instance, $attr->slots, $value) . ";" if $attr->is_weak_ref; @@ -233,7 +233,7 @@ sub _inline_trigger { sub _inline_get { my ($self, $instance) = @_; my $attr = $self->associated_attribute; - + my $mi = $attr->associated_class->get_meta_instance; return $mi->inline_get_slot_value($instance, $attr->slots); @@ -242,7 +242,7 @@ sub _inline_get { sub _inline_access { my ($self, $instance) = @_; my $attr = $self->associated_attribute; - + my $mi = $attr->associated_class->get_meta_instance; return $mi->inline_slot_access($instance, $attr->slots); @@ -251,7 +251,7 @@ sub _inline_access { sub _inline_has { my ($self, $instance) = @_; my $attr = $self->associated_attribute; - + my $mi = $attr->associated_class->get_meta_instance; return $mi->inline_is_slot_initialized($instance, $attr->slots); diff --git a/lib/Moose/Meta/Method/Augmented.pm b/lib/Moose/Meta/Method/Augmented.pm index bab3a9a..90df02b 100644 --- a/lib/Moose/Meta/Method/Augmented.pm +++ b/lib/Moose/Meta/Method/Augmented.pm @@ -107,7 +107,7 @@ option is required. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/Method/Constructor.pm b/lib/Moose/Meta/Method/Constructor.pm index 4474207..60609e7 100644 --- a/lib/Moose/Meta/Method/Constructor.pm +++ b/lib/Moose/Meta/Method/Constructor.pm @@ -25,7 +25,7 @@ sub new { || $class->throw_error("You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"); my $self = bless { - 'body' => undef, + 'body' => undef, 'package_name' => $options{package_name}, 'name' => $options{name}, 'options' => $options{options}, @@ -63,7 +63,7 @@ sub _initialize_body { $source .= "\n" . 'my $class = shift;'; $source .= "\n" . 'return $class->Moose::Object::new(@_)'; - $source .= "\n if \$class ne '" . $self->associated_metaclass->name + $source .= "\n if \$class ne '" . $self->associated_metaclass->name . "';\n"; $source .= $self->_generate_params('$params', '$class'); @@ -105,7 +105,7 @@ sub _initialize_body { '@type_constraint_bodies' => \@type_constraint_bodies, }, ) or $self->throw_error("Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source ); - + $self->{'body'} = $code; } @@ -213,18 +213,18 @@ sub _generate_slot_initializer { my $default; if ( $attr->has_default ) { $default = $self->_generate_default_value($attr, $index); - } + } else { my $builder = $attr->builder; $default = '$instance->' . $builder; } - + push @source => '{'; # wrap this to avoid my $val overwrite warnings push @source => ('my $val = ' . $default . ';'); push @source => $self->_generate_type_constraint_and_coercion($attr, $index) - if $is_moose; + if $is_moose; push @source => $self->_generate_slot_assignment($attr, '$val', $index); - push @source => '}'; # close - wrap this to avoid my $val overrite warnings + push @source => '}'; # close - wrap this to avoid my $val overrite warnings push @source => "}" if defined $attr->init_arg; } @@ -235,16 +235,16 @@ sub _generate_slot_initializer { if ($is_moose && $attr->has_type_constraint) { if ($attr->should_coerce && $attr->type_constraint->has_coercion) { push @source => $self->_generate_type_coercion( - $attr, - '$type_constraints[' . $index . ']', - '$val', + $attr, + '$type_constraints[' . $index . ']', + '$val', '$val' ); } push @source => $self->_generate_type_constraint_check( - $attr, - '$type_constraint_bodies[' . $index . ']', - '$type_constraints[' . $index . ']', + $attr, + '$type_constraint_bodies[' . $index . ']', + '$type_constraints[' . $index . ']', '$val' ); } @@ -260,11 +260,11 @@ sub _generate_slot_assignment { my ($self, $attr, $value, $index) = @_; my $source; - + if ($attr->has_initializer) { $source = ( '$attrs->[' . $index . ']->set_initial_value($instance, ' . $value . ');' - ); + ); } else { $source = ( @@ -273,10 +273,10 @@ sub _generate_slot_assignment { $attr->name, $value ) . ';' - ); + ); } - - my $is_moose = $attr->isa('Moose::Meta::Attribute'); # XXX FIXME + + my $is_moose = $attr->isa('Moose::Meta::Attribute'); # XXX FIXME if ($is_moose && $attr->is_weak_ref) { $source .= ( @@ -294,9 +294,9 @@ sub _generate_slot_assignment { sub _generate_type_constraint_and_coercion { my ($self, $attr, $index) = @_; - + return unless $attr->has_type_constraint; - + my @source; if ($attr->should_coerce && $attr->type_constraint->has_coercion) { push @source => $self->_generate_type_coercion( @@ -309,7 +309,7 @@ sub _generate_type_constraint_and_coercion { push @source => $self->_generate_type_constraint_check( $attr, ('$type_constraint_bodies[' . $index . ']'), - ('$type_constraints[' . $index . ']'), + ('$type_constraints[' . $index . ']'), '$val' ); return @source; @@ -324,8 +324,8 @@ sub _generate_type_constraint_check { my ($self, $attr, $type_constraint_cv, $type_constraint_obj, $value_name) = @_; return ( $self->_inline_throw_error('"Attribute (' # FIXME add 'dad' - . $attr->name - . ') does not pass the type constraint because: " . ' + . $attr->name + . ') does not pass the type constraint because: " . ' . $type_constraint_obj . '->get_message(' . $value_name . ')') . "\n\t unless " . $type_constraint_cv . '->(' . $value_name . ');' ); diff --git a/lib/Moose/Meta/Method/Delegation.pm b/lib/Moose/Meta/Method/Delegation.pm index 5c24d5f..b40c71a 100644 --- a/lib/Moose/Meta/Method/Delegation.pm +++ b/lib/Moose/Meta/Method/Delegation.pm @@ -152,7 +152,7 @@ constructor. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/Method/Destructor.pm b/lib/Moose/Meta/Method/Destructor.pm index ea644e6..499ba6b 100644 --- a/lib/Moose/Meta/Method/Destructor.pm +++ b/lib/Moose/Meta/Method/Destructor.pm @@ -16,7 +16,7 @@ use base 'Moose::Meta::Method', sub new { my $class = shift; my %options = @_; - + (ref $options{options} eq 'HASH') || $class->throw_error("You must pass a hash of options", data => $options{options}); @@ -25,25 +25,25 @@ sub new { my $self = bless { # from our superclass - 'body' => undef, + 'body' => undef, 'package_name' => $options{package_name}, - 'name' => $options{name}, + 'name' => $options{name}, # ... - 'options' => $options{options}, + 'options' => $options{options}, 'associated_metaclass' => $options{metaclass}, } => $class; - # we don't want this creating - # a cycle in the code, if not + # we don't want this creating + # a cycle in the code, if not # needed - weaken($self->{'associated_metaclass'}); + weaken($self->{'associated_metaclass'}); $self->_initialize_body; - return $self; + return $self; } -## accessors +## accessors sub options { (shift)->{'options'} } @@ -69,29 +69,29 @@ sub initialize_body { sub _initialize_body { my $self = shift; # TODO: - # the %options should also include a both - # a call 'initializer' and call 'SUPER::' - # options, which should cover approx 90% - # of the possible use cases (even if it - # requires some adaption on the part of + # the %options should also include a both + # a call 'initializer' and call 'SUPER::' + # options, which should cover approx 90% + # of the possible use cases (even if it + # requires some adaption on the part of # the author, after all, nothing is free) - + my @DEMOLISH_methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH'); - + return unless @DEMOLISH_methods; - + my $source = 'sub {'; my @DEMOLISH_calls; foreach my $method (@DEMOLISH_methods) { - push @DEMOLISH_calls => '$_[0]->' . $method->{class} . '::DEMOLISH()'; + push @DEMOLISH_calls => '$_[0]->' . $method->{class} . '::DEMOLISH()'; } - + $source .= join ";\n" => @DEMOLISH_calls; - $source .= ";\n" . '}'; - warn $source if $self->options->{debug}; - + $source .= ";\n" . '}'; + warn $source if $self->options->{debug}; + my $code = $self->_compile_code( environment => {}, code => $source, @@ -107,7 +107,7 @@ __END__ =pod -=head1 NAME +=head1 NAME Moose::Meta::Method::Destructor - Method Meta Object for destructors @@ -170,7 +170,7 @@ Copyright 2006-2009 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +it under the same terms as Perl itself. =cut diff --git a/lib/Moose/Meta/Method/Overridden.pm b/lib/Moose/Meta/Method/Overridden.pm index 65ace59..39b7167 100644 --- a/lib/Moose/Meta/Method/Overridden.pm +++ b/lib/Moose/Meta/Method/Overridden.pm @@ -96,7 +96,7 @@ is required. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/Role.pm b/lib/Moose/Meta/Role.pm index 9c00815..e566f17 100644 --- a/lib/Moose/Meta/Role.pm +++ b/lib/Moose/Meta/Role.pm @@ -23,8 +23,8 @@ use base 'Class::MOP::Module'; ## I normally don't do this, but I am doing ## a whole bunch of meta-programmin in this ## module, so it just makes sense. For a clearer -## picture of what is going on in the next -## several lines of code, look at the really +## picture of what is going on in the next +## several lines of code, look at the really ## big comment at the end of this file (right ## before the POD). ## - SL @@ -41,7 +41,7 @@ my $META = __PACKAGE__->meta; # time when it is applied to a class. This means # keeping a lot of things in hash maps, so we are # using a little of that meta-programmin' magic -# here an saving lots of extra typin. And since +# here an saving lots of extra typin. And since # many of these attributes above require similar # functionality to support them, so we again use # the wonders of meta-programmin' to deliver a @@ -68,7 +68,7 @@ foreach my $action ( get_list => 'get_required_method_list', existence => 'requires_method', } - }, + }, { name => 'attribute_map', attr_reader => 'get_attribute_map', @@ -156,12 +156,12 @@ sub add_attribute { foreach my $modifier_type (qw[ before around after ]) { my $attr_reader = "get_${modifier_type}_method_modifiers_map"; - + # create the attribute ... $META->add_attribute("${modifier_type}_method_modifiers" => ( reader => $attr_reader, default => sub { {} } - )); + )); # and some helper methods ... $META->add_method("get_${modifier_type}_method_modifiers" => sub { @@ -326,29 +326,29 @@ sub get_method_map { } else { # NOTE: - # in 5.10 constant.pm the constants show up + # in 5.10 constant.pm the constants show up # as being in the right package, but in pre-5.10 - # they show up as constant::__ANON__ so we + # they show up as constant::__ANON__ so we # make an exception here to be sure that things # work as expected in both. # - SL unless ($pkg eq 'constant' && $name eq '__ANON__') { next if ($pkg || '') ne $role_name || (($name || '') ne '__ANON__' && ($pkg || '') ne $role_name); - } + } } - + $map->{$symbol} = $method_metaclass->wrap( $code, package_name => $role_name, - name => $name + name => $name ); } - return $map; + return $map; } -sub get_method { +sub get_method { my ($self, $name) = @_; $self->get_method_map->{$name}; } @@ -383,7 +383,7 @@ sub add_method { if ($method->package_name ne $self->name) { $method = $method->clone( package_name => $self->name, - name => $method_name + name => $method_name ) if $method->can('clone'); } } @@ -429,7 +429,7 @@ sub apply { (blessed($other)) || Moose->throw_error("You must pass in an blessed instance"); - + if ($other->isa('Moose::Meta::Role')) { require Moose::Meta::Role::Application::ToRole; return Moose::Meta::Role::Application::ToRole->new(@args)->apply($self, $other); @@ -437,32 +437,32 @@ sub apply { elsif ($other->isa('Moose::Meta::Class')) { require Moose::Meta::Role::Application::ToClass; return Moose::Meta::Role::Application::ToClass->new(@args)->apply($self, $other); - } + } else { require Moose::Meta::Role::Application::ToInstance; - return Moose::Meta::Role::Application::ToInstance->new(@args)->apply($self, $other); - } + return Moose::Meta::Role::Application::ToInstance->new(@args)->apply($self, $other); + } } sub combine { my ($class, @role_specs) = @_; - + require Moose::Meta::Role::Application::RoleSummation; - require Moose::Meta::Role::Composite; - + require Moose::Meta::Role::Composite; + my (@roles, %role_params); while (@role_specs) { my ($role, $params) = @{ splice @role_specs, 0, 1 }; push @roles => Class::MOP::class_of($role); next unless defined $params; - $role_params{$role} = $params; + $role_params{$role} = $params; } - + my $c = Moose::Meta::Role::Composite->new(roles => \@roles); Moose::Meta::Role::Application::RoleSummation->new( role_params => \%role_params )->apply($c); - + return $c; } @@ -581,8 +581,8 @@ sub create { ##################################################################### ## NOTE: -## This is Moose::Meta::Role as defined by Moose (plus the use of -## MooseX::AttributeHelpers module). It is here as a reference to +## This is Moose::Meta::Role as defined by Moose (plus the use of +## MooseX::AttributeHelpers module). It is here as a reference to ## make it easier to see what is happening above with all the meta ## programming. - SL ##################################################################### @@ -596,7 +596,7 @@ sub create { # 'push' => 'add_role', # } # ); -# +# # has 'excluded_roles_map' => ( # metaclass => 'Collection::Hash', # reader => 'get_excluded_roles_map', @@ -608,95 +608,95 @@ sub create { # 'exists' => 'excludes_role', # } # ); -# +# # has 'attribute_map' => ( # metaclass => 'Collection::Hash', # reader => 'get_attribute_map', -# isa => 'HashRef[Str]', +# isa => 'HashRef[Str]', # provides => { # # 'set' => 'add_attribute' # has some special crap in it # 'get' => 'get_attribute', # 'keys' => 'get_attribute_list', # 'exists' => 'has_attribute', # # Not exactly delete, cause it sets multiple -# 'delete' => 'remove_attribute', +# 'delete' => 'remove_attribute', # } # ); -# +# # has 'required_methods' => ( # metaclass => 'Collection::Hash', # reader => 'get_required_methods_map', # isa => 'HashRef[Str]', -# provides => { -# # not exactly set, or delete since it works for multiple +# provides => { +# # not exactly set, or delete since it works for multiple # 'set' => 'add_required_methods', # 'delete' => 'remove_required_methods', # 'keys' => 'get_required_method_list', -# 'exists' => 'requires_method', +# 'exists' => 'requires_method', # } # ); -# -# # the before, around and after modifiers are -# # HASH keyed by method-name, with ARRAY of +# +# # the before, around and after modifiers are +# # HASH keyed by method-name, with ARRAY of # # CODE refs to apply in that order -# +# # has 'before_method_modifiers' => ( -# metaclass => 'Collection::Hash', +# metaclass => 'Collection::Hash', # reader => 'get_before_method_modifiers_map', # isa => 'HashRef[ArrayRef[CodeRef]]', # provides => { # 'keys' => 'get_before_method_modifiers', -# 'exists' => 'has_before_method_modifiers', -# # This actually makes sure there is an +# 'exists' => 'has_before_method_modifiers', +# # This actually makes sure there is an # # ARRAY at the given key, and pushed onto # # it. It also checks for duplicates as well -# # 'add' => 'add_before_method_modifier' -# } +# # 'add' => 'add_before_method_modifier' +# } # ); -# +# # has 'after_method_modifiers' => ( -# metaclass => 'Collection::Hash', +# metaclass => 'Collection::Hash', # reader =>'get_after_method_modifiers_map', # isa => 'HashRef[ArrayRef[CodeRef]]', # provides => { # 'keys' => 'get_after_method_modifiers', -# 'exists' => 'has_after_method_modifiers', -# # This actually makes sure there is an +# 'exists' => 'has_after_method_modifiers', +# # This actually makes sure there is an # # ARRAY at the given key, and pushed onto -# # it. It also checks for duplicates as well -# # 'add' => 'add_after_method_modifier' -# } +# # it. It also checks for duplicates as well +# # 'add' => 'add_after_method_modifier' +# } # ); -# +# # has 'around_method_modifiers' => ( -# metaclass => 'Collection::Hash', +# metaclass => 'Collection::Hash', # reader =>'get_around_method_modifiers_map', # isa => 'HashRef[ArrayRef[CodeRef]]', # provides => { # 'keys' => 'get_around_method_modifiers', -# 'exists' => 'has_around_method_modifiers', -# # This actually makes sure there is an +# 'exists' => 'has_around_method_modifiers', +# # This actually makes sure there is an # # ARRAY at the given key, and pushed onto -# # it. It also checks for duplicates as well -# # 'add' => 'add_around_method_modifier' -# } +# # it. It also checks for duplicates as well +# # 'add' => 'add_around_method_modifier' +# } # ); -# +# # # override is similar to the other modifiers # # except that it is not an ARRAY of code refs # # but instead just a single name->code mapping -# +# # has 'override_method_modifiers' => ( -# metaclass => 'Collection::Hash', +# metaclass => 'Collection::Hash', # reader =>'get_override_method_modifiers_map', -# isa => 'HashRef[CodeRef]', +# isa => 'HashRef[CodeRef]', # provides => { # 'keys' => 'get_override_method_modifier', -# 'exists' => 'has_override_method_modifier', -# 'add' => 'add_override_method_modifier', # checks for local method .. +# 'exists' => 'has_override_method_modifier', +# 'add' => 'add_override_method_modifier', # checks for local method .. # } # ); -# +# ##################################################################### diff --git a/lib/Moose/Meta/Role/Application.pm b/lib/Moose/Meta/Role/Application.pm index 1d17034..22c4fb4 100644 --- a/lib/Moose/Meta/Role/Application.pm +++ b/lib/Moose/Meta/Role/Application.pm @@ -20,16 +20,16 @@ __PACKAGE__->meta->add_attribute('method_aliases' => ( default => sub { {} } )); -sub new { +sub new { my ($class, %params) = @_; - + if (exists $params{excludes}) { # I wish we had coercion here :) - $params{excludes} = (ref $params{excludes} eq 'ARRAY' - ? $params{excludes} + $params{excludes} = (ref $params{excludes} eq 'ARRAY' + ? $params{excludes} : [ $params{excludes} ]); } - + $class->_new(\%params); } @@ -58,12 +58,12 @@ sub apply { $self->check_role_exclusions(@_); $self->check_required_methods(@_); $self->check_required_attributes(@_); - + $self->apply_attributes(@_); - $self->apply_methods(@_); - + $self->apply_methods(@_); + $self->apply_override_method_modifiers(@_); - + $self->apply_before_method_modifiers(@_); $self->apply_around_method_modifiers(@_); $self->apply_after_method_modifiers(@_); diff --git a/lib/Moose/Meta/Role/Application/RoleSummation.pm b/lib/Moose/Meta/Role/Application/RoleSummation.pm index d7afd4d..8b9ea0e 100644 --- a/lib/Moose/Meta/Role/Application/RoleSummation.pm +++ b/lib/Moose/Meta/Role/Application/RoleSummation.pm @@ -37,7 +37,7 @@ sub get_method_aliases_for_role { if ($self->role_params->{$role} && defined $self->role_params->{$role}->{alias}) { return $self->role_params->{$role}->{alias}; } - return {}; + return {}; } sub is_method_excluded { @@ -55,7 +55,7 @@ sub is_method_aliased { sub is_aliased_method { my ($self, $role, $method_name) = @_; - my %aliased_names = reverse %{$self->get_method_aliases_for_role($role->name)}; + my %aliased_names = reverse %{$self->get_method_aliases_for_role($role->name)}; exists $aliased_names{$method_name} ? 1 : 0; } @@ -97,7 +97,7 @@ sub check_required_methods { foreach my $role (@{$c->get_roles}) { foreach my $required (keys %all_required_methods) { - + delete $all_required_methods{$required} if $role->has_method($required) || $self->is_aliased_method($role, $required); @@ -108,65 +108,65 @@ sub check_required_methods { } sub check_required_attributes { - + } sub apply_attributes { my ($self, $c) = @_; - + my @all_attributes = map { my $role = $_; - map { - +{ + map { + +{ name => $_, attr => $role->get_attribute($_), } } $role->get_attribute_list } @{$c->get_roles}; - + my %seen; foreach my $attr (@all_attributes) { if (exists $seen{$attr->{name}}) { if ( $seen{$attr->{name}} != $attr->{attr} ) { require Moose; - Moose->throw_error("We have encountered an attribute conflict with '" . $attr->{name} . "' " + Moose->throw_error("We have encountered an attribute conflict with '" . $attr->{name} . "' " . "during composition. This is fatal error and cannot be disambiguated.") } } $seen{$attr->{name}} = $attr->{attr}; } - foreach my $attr (@all_attributes) { + foreach my $attr (@all_attributes) { $c->add_attribute($attr->{name}, $attr->{attr}); } } sub apply_methods { my ($self, $c) = @_; - + my @all_methods = map { my $role = $_; my $aliases = $self->get_method_aliases_for_role($role); my %excludes = map { $_ => undef } @{ $self->get_exclusions_for_role($role) }; ( - (map { + (map { exists $excludes{$_} ? () : - +{ + +{ role => $role, name => $_, method => $role->get_method($_), } } $role->get_method_list), - (map { - +{ + (map { + +{ role => $role, name => $aliases->{$_}, method => $role->get_method($_), - } + } } keys %$aliases) ); } @{$c->get_roles}; - + my (%seen, %method_map); foreach my $method (@all_methods) { if (exists $seen{$method->{name}}) { @@ -174,9 +174,9 @@ sub apply_methods { $c->add_required_methods($method->{name}); delete $method_map{$method->{name}}; next; - } - } - + } + } + $seen{$method->{name}} = $method->{method}; $method_map{$method->{name}} = $method->{method}; } @@ -186,17 +186,17 @@ sub apply_methods { sub apply_override_method_modifiers { my ($self, $c) = @_; - + my @all_overrides = map { my $role = $_; - map { - +{ + map { + +{ name => $_, method => $role->get_override_method_modifier($_), } } $role->get_method_modifier_list('override'); } @{$c->get_roles}; - + my %seen; foreach my $override (@all_overrides) { if ( $c->has_method($override->{name}) ){ @@ -215,11 +215,11 @@ sub apply_override_method_modifiers { } $seen{$override->{name}} = $override->{method}; } - + $c->add_override_method_modifier( $_->{name}, $_->{method} ) for @all_overrides; - + } sub apply_method_modifiers { @@ -248,7 +248,7 @@ Moose::Meta::Role::Application::RoleSummation - Combine two or more roles =head1 DESCRIPTION -Summation composes two traits, forming the union of non-conflicting +Summation composes two traits, forming the union of non-conflicting bindings and 'disabling' the conflicting bindings =head2 METHODS diff --git a/lib/Moose/Meta/Role/Application/ToClass.pm b/lib/Moose/Meta/Role/Application/ToClass.pm index 624b2d1..2bc593e 100644 --- a/lib/Moose/Meta/Role/Application/ToClass.pm +++ b/lib/Moose/Meta/Role/Application/ToClass.pm @@ -14,9 +14,9 @@ our $AUTHORITY = 'cpan:STEVAN'; use base 'Moose::Meta::Role::Application'; sub apply { - my ($self, $role, $class) = @_; + my ($self, $role, $class) = @_; $self->SUPER::apply($role, $class); - $class->add_role($role); + $class->add_role($role); } sub check_role_exclusions { @@ -46,7 +46,7 @@ sub check_required_methods { foreach my $required_method_name ($role->get_required_method_list) { if (!$class->find_method_by_name($required_method_name)) { - + next if $self->is_aliased_method($required_method_name); push @missing, $required_method_name; @@ -75,7 +75,7 @@ sub check_required_methods { } sub check_required_attributes { - + } sub apply_attributes { @@ -99,7 +99,7 @@ sub apply_attributes { sub apply_methods { my ($self, $role, $class) = @_; foreach my $method_name ($role->get_method_list) { - + unless ($self->is_method_excluded($method_name)) { # it if it has one already if ($class->has_method($method_name) && @@ -112,10 +112,10 @@ sub apply_methods { $class->add_method( $method_name, $role->get_method($method_name) - ); + ); } } - + if ($self->is_method_aliased($method_name)) { my $aliased_method_name = $self->get_method_aliases->{$method_name}; # it if it has one already @@ -123,17 +123,17 @@ sub apply_methods { # and if they are not the same thing ... $class->get_method($aliased_method_name)->body != $role->get_method($method_name)->body) { $class->throw_error("Cannot create a method alias if a local method of the same name exists"); - } + } $class->add_method( $aliased_method_name, $role->get_method($method_name) - ); - } + ); + } } # we must reset the cache here since # we are just aliasing methods, otherwise # the modifiers go wonky. - $class->reset_package_cache_flag; + $class->reset_package_cache_flag; } sub apply_override_method_modifiers { diff --git a/lib/Moose/Meta/Role/Application/ToRole.pm b/lib/Moose/Meta/Role/Application/ToRole.pm index f5bdb39..d324702 100644 --- a/lib/Moose/Meta/Role/Application/ToRole.pm +++ b/lib/Moose/Meta/Role/Application/ToRole.pm @@ -13,9 +13,9 @@ our $AUTHORITY = 'cpan:STEVAN'; use base 'Moose::Meta::Role::Application'; sub apply { - my ($self, $role1, $role2) = @_; - $self->SUPER::apply($role1, $role2); - $role2->add_role($role1); + my ($self, $role1, $role2) = @_; + $self->SUPER::apply($role1, $role2); + $role2->add_role($role1); } sub check_role_exclusions { @@ -36,16 +36,16 @@ sub check_role_exclusions { sub check_required_methods { my ($self, $role1, $role2) = @_; foreach my $required_method_name ($role1->get_required_method_list) { - + next if $self->is_aliased_method($required_method_name); - + $role2->add_required_methods($required_method_name) unless $role2->find_method_by_name($required_method_name); } } sub check_required_attributes { - + } sub apply_attributes { @@ -95,10 +95,10 @@ sub apply_methods { } next; - } - - next if $self->is_method_excluded($method_name); - + } + + next if $self->is_method_excluded($method_name); + # it if it has one already if ($role2->has_method($method_name) && # and if they are not the same thing ... @@ -113,9 +113,9 @@ sub apply_methods { $method_name, $role1->get_method($method_name) ); - + } - + } } diff --git a/lib/Moose/Meta/Role/Composite.pm b/lib/Moose/Meta/Role/Composite.pm index 06d4d6f..fdd9678 100644 --- a/lib/Moose/Meta/Role/Composite.pm +++ b/lib/Moose/Meta/Role/Composite.pm @@ -13,17 +13,17 @@ our $AUTHORITY = 'cpan:STEVAN'; use base 'Moose::Meta::Role'; # NOTE: -# we need to override the ->name +# we need to override the ->name # method from Class::MOP::Package -# since we don't have an actual +# since we don't have an actual # package for this. # - SL __PACKAGE__->meta->add_attribute('name' => (reader => 'name')); # NOTE: -# Again, since we don't have a real -# package to store our methods in, -# we use a HASH ref instead. +# Again, since we don't have a real +# package to store our methods in, +# we use a HASH ref instead. # - SL __PACKAGE__->meta->add_attribute('methods' => ( reader => 'get_method_map', @@ -62,7 +62,7 @@ sub add_method { if ($method->package_name ne $self->name) { $method = $method->clone( package_name => $self->name, - name => $method_name + name => $method_name ) if $method->can('clone'); } } diff --git a/lib/Moose/Meta/Role/Method.pm b/lib/Moose/Meta/Role/Method.pm index 1b126e9..23fddfd 100644 --- a/lib/Moose/Meta/Role/Method.pm +++ b/lib/Moose/Meta/Role/Method.pm @@ -22,13 +22,13 @@ Moose::Meta::Role::Method - A Moose Method metaclass for Roles =head1 DESCRIPTION -This is primarily used to mark methods coming from a role +This is primarily used to mark methods coming from a role as being different. Right now it is nothing but a subclass of L. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/Role/Method/Required.pm b/lib/Moose/Meta/Role/Method/Required.pm index 2425d09..61e0e6e 100644 --- a/lib/Moose/Meta/Role/Method/Required.pm +++ b/lib/Moose/Meta/Role/Method/Required.pm @@ -24,7 +24,7 @@ Moose::Meta::Role::Method::Required - A Moose metaclass for required methods in =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/TypeCoercion.pm b/lib/Moose/Meta/TypeCoercion.pm index 8b73ca1..0bb36c0 100644 --- a/lib/Moose/Meta/TypeCoercion.pm +++ b/lib/Moose/Meta/TypeCoercion.pm @@ -29,7 +29,7 @@ __PACKAGE__->meta->add_attribute('compiled_type_coercion' => ( accessor => '_compiled_type_coercion' )); -sub new { +sub new { my $class = shift; my $self = Class::MOP::class_of($class)->new_object(@_); $self->compile_type_coercion; @@ -49,22 +49,22 @@ sub compile_type_coercion { Moose->throw_error("Could not find the type constraint ($constraint_name) to coerce from"); } - push @coercions => [ - $type_constraint->_compiled_type_constraint, - $action + push @coercions => [ + $type_constraint->_compiled_type_constraint, + $action ]; } - $self->_compiled_type_coercion(sub { + $self->_compiled_type_coercion(sub { my $thing = shift; foreach my $coercion (@coercions) { my ($constraint, $converter) = @$coercion; if ($constraint->($thing)) { - local $_ = $thing; + local $_ = $thing; return $converter->($thing); } } return $thing; - }); + }); } sub has_coercion_for_type { @@ -75,12 +75,12 @@ sub has_coercion_for_type { sub add_type_coercions { my ($self, @new_coercion_map) = @_; - - my $coercion_map = $self->type_coercion_map; + + my $coercion_map = $self->type_coercion_map; my %has_coercion = @$coercion_map; - + while (@new_coercion_map) { - my ($constraint_name, $action) = splice(@new_coercion_map, 0, 2); + my ($constraint_name, $action) = splice(@new_coercion_map, 0, 2); if ( exists $has_coercion{$constraint_name} ) { require Moose; @@ -89,7 +89,7 @@ sub add_type_coercions { push @{$coercion_map} => ($constraint_name, $action); } - + # and re-compile ... $self->compile_type_coercion; } @@ -174,7 +174,7 @@ This will return a L instance for this class. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. @@ -189,6 +189,6 @@ Copyright 2006-2009 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +it under the same terms as Perl itself. =cut diff --git a/lib/Moose/Meta/TypeCoercion/Union.pm b/lib/Moose/Meta/TypeCoercion/Union.pm index b0b1af8..3d02618 100644 --- a/lib/Moose/Meta/TypeCoercion/Union.pm +++ b/lib/Moose/Meta/TypeCoercion/Union.pm @@ -16,27 +16,27 @@ use base 'Moose::Meta::TypeCoercion'; sub compile_type_coercion { my $self = shift; my $type_constraint = $self->type_constraint; - + (blessed $type_constraint && $type_constraint->isa('Moose::Meta::TypeConstraint::Union')) || Moose->throw_error("You can only a Moose::Meta::TypeCoercion::Union for a " . "Moose::Meta::TypeConstraint::Union, not a $type_constraint"); - + $self->_compiled_type_coercion(sub { my $value = shift; - # go through all the type constraints + # go through all the type constraints # in the union, and check em ... foreach my $type (@{$type_constraint->type_constraints}) { # if they have a coercion first - if ($type->has_coercion) { + if ($type->has_coercion) { # then try to coerce them ... my $temp = $type->coerce($value); - # and if they get something + # and if they get something # make sure it still fits within # the union type ... return $temp if $type_constraint->check($temp); } } - return undef; + return undef; }); } @@ -83,7 +83,7 @@ union. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. @@ -98,6 +98,6 @@ Copyright 2006-2009 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +it under the same terms as Perl itself. =cut diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index 559ef20..4b78f54 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -110,9 +110,9 @@ sub get_message { return $msg->($value); } else { - $value = (defined $value ? overload::StrVal($value) : 'undef'); + $value = (defined $value ? overload::StrVal($value) : 'undef'); return "Validation failed for '" . $self->name . "' failed with value $value"; - } + } } ## type predicates ... diff --git a/lib/Moose/Meta/TypeConstraint/Class.pm b/lib/Moose/Meta/TypeConstraint/Class.pm index a128acc..1c26e78 100644 --- a/lib/Moose/Meta/TypeConstraint/Class.pm +++ b/lib/Moose/Meta/TypeConstraint/Class.pm @@ -33,8 +33,8 @@ sub _create_hand_optimized_type_constraint { my $self = shift; my $class = $self->class; $self->hand_optimized_type_constraint( - sub { - blessed( $_[0] ) && $_[0]->isa($class) + sub { + blessed( $_[0] ) && $_[0]->isa($class) } ); } @@ -49,8 +49,8 @@ sub parents { # if anybody thinks this problematic please discuss on IRC. # a possible fix is to add by attr indexing to the type registry to find types of a certain property # regardless of their name - Moose::Util::TypeConstraints::find_type_constraint($_) - || + Moose::Util::TypeConstraints::find_type_constraint($_) + || __PACKAGE__->new( class => $_, name => "__ANON__" ) } Class::MOP::class_of($self->class)->superclasses, ); @@ -84,7 +84,7 @@ sub is_subtype_of { } my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name_or_class); - + return unless defined $type; if ( $type->isa(__PACKAGE__) ) { @@ -183,7 +183,7 @@ C object! =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/TypeConstraint/Enum.pm b/lib/Moose/Meta/TypeConstraint/Enum.pm index 9892d84..65e6c86 100644 --- a/lib/Moose/Meta/TypeConstraint/Enum.pm +++ b/lib/Moose/Meta/TypeConstraint/Enum.pm @@ -126,7 +126,7 @@ object! =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/TypeConstraint/Parameterizable.pm b/lib/Moose/Meta/TypeConstraint/Parameterizable.pm index 7efe3fc..558b841 100644 --- a/lib/Moose/Meta/TypeConstraint/Parameterizable.pm +++ b/lib/Moose/Meta/TypeConstraint/Parameterizable.pm @@ -19,16 +19,16 @@ __PACKAGE__->meta->add_attribute('constraint_generator' => ( sub generate_constraint_for { my ($self, $type) = @_; - + return unless $self->has_constraint_generator; - + return $self->constraint_generator->($type->type_parameter) if $type->is_subtype_of($self->name); - + return $self->_can_coerce_constraint_from($type) if $self->has_coercion && $self->coercion->has_coercion_for_type($type->parent->name); - + return; } @@ -51,10 +51,10 @@ sub parameterize { my ($self, $type_parameter) = @_; my $contained_tc = $self->_parse_type_parameter($type_parameter); - + ## The type parameter should be a subtype of the parent's type parameter ## if there is one. - + if(my $parent = $self->parent) { if($parent->can('type_parameter')) { unless ( $contained_tc->is_a_type_of($parent->type_parameter) ) { @@ -114,7 +114,7 @@ confusing and needs some work. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/TypeConstraint/Parameterized.pm b/lib/Moose/Meta/TypeConstraint/Parameterized.pm index da3261e..dc4f383 100644 --- a/lib/Moose/Meta/TypeConstraint/Parameterized.pm +++ b/lib/Moose/Meta/TypeConstraint/Parameterized.pm @@ -25,7 +25,7 @@ sub equals { my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name); return unless $other->isa(__PACKAGE__); - + return ( $self->type_parameter->equals( $other->type_parameter ) and @@ -35,14 +35,14 @@ sub equals { sub compile_type_constraint { my $self = shift; - + unless ( $self->has_type_parameter ) { require Moose; Moose->throw_error("You cannot create a Higher Order type without a type parameter"); } my $type_parameter = $self->type_parameter; - + unless ( blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint') ) { require Moose; Moose->throw_error("The type parameter must be a Moose meta type"); @@ -51,14 +51,14 @@ sub compile_type_constraint { foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) { if (my $constraint = $type->generate_constraint_for($self)) { $self->_set_constraint($constraint); - return $self->SUPER::compile_type_constraint; + return $self->SUPER::compile_type_constraint; } } - - # if we get here, then we couldn't + + # if we get here, then we couldn't # find a way to parameterize this type require Moose; - Moose->throw_error("The " . $self->name . " constraint cannot be used, because " + Moose->throw_error("The " . $self->name . " constraint cannot be used, because " . $self->parent->name . " doesn't subtype or coerce from a parameterizable type."); } @@ -90,7 +90,7 @@ L. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/TypeConstraint/Registry.pm b/lib/Moose/Meta/TypeConstraint/Registry.pm index d36d65c..32d3a0b 100644 --- a/lib/Moose/Meta/TypeConstraint/Registry.pm +++ b/lib/Moose/Meta/TypeConstraint/Registry.pm @@ -15,8 +15,8 @@ use base 'Class::MOP::Object'; __PACKAGE__->meta->add_attribute('parent_registry' => ( reader => 'get_parent_registry', - writer => 'set_parent_registry', - predicate => 'has_parent_registry', + writer => 'set_parent_registry', + predicate => 'has_parent_registry', )); __PACKAGE__->meta->add_attribute('type_constraints' => ( @@ -24,7 +24,7 @@ __PACKAGE__->meta->add_attribute('type_constraints' => ( default => sub { {} } )); -sub new { +sub new { my $class = shift; my $self = $class->_new(@_); return $self; @@ -37,7 +37,7 @@ sub has_type_constraint { sub get_type_constraint { my ($self, $type_name) = @_; - return unless defined $type_name; + return unless defined $type_name; $self->type_constraints->{$type_name} } @@ -144,7 +144,7 @@ parent, if it has one. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/TypeConstraint/Role.pm b/lib/Moose/Meta/TypeConstraint/Role.pm index 7727173..e9449d0 100644 --- a/lib/Moose/Meta/TypeConstraint/Role.pm +++ b/lib/Moose/Meta/TypeConstraint/Role.pm @@ -47,8 +47,8 @@ sub parents { # if anybody thinks this problematic please discuss on IRC. # a possible fix is to add by attr indexing to the type registry to find types of a certain property # regardless of their name - Moose::Util::TypeConstraints::find_type_constraint($_) - || + Moose::Util::TypeConstraints::find_type_constraint($_) + || __PACKAGE__->new( role => $_, name => "__ANON__" ) } @{ Class::MOP::class_of($self->role)->get_roles }, ); @@ -84,7 +84,7 @@ sub is_subtype_of { my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name_or_role); return unless defined $type; - + if ( $type->isa(__PACKAGE__) ) { # if $type_or_name_or_role isn't a role, it might be the TC name of another ::Role type # or it could also just be a type object in this branch @@ -165,7 +165,7 @@ object! =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Meta/TypeConstraint/Union.pm b/lib/Moose/Meta/TypeConstraint/Union.pm index 4c3a424..86ccb22 100644 --- a/lib/Moose/Meta/TypeConstraint/Union.pm +++ b/lib/Moose/Meta/TypeConstraint/Union.pm @@ -18,7 +18,7 @@ __PACKAGE__->meta->add_attribute('type_constraints' => ( default => sub { [] } )); -sub new { +sub new { my ($class, %options) = @_; my $name = join '|' => sort { $a cmp $b } @@ -90,7 +90,7 @@ sub validate { $message .= ($message ? ' and ' : '') . $err if defined $err; } - return ($message . ' in (' . $self->name . ')') ; + return ($message . ' in (' . $self->name . ')') ; } sub is_a_type_of { @@ -98,7 +98,7 @@ sub is_a_type_of { foreach my $type (@{$self->type_constraints}) { return 1 if $type->is_a_type_of($type_name); } - return 0; + return 0; } sub is_subtype_of { @@ -216,7 +216,7 @@ as its parent. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Object.pm b/lib/Moose/Object.pm index 3f02e5a..b6991bc 100644 --- a/lib/Moose/Object.pm +++ b/lib/Moose/Object.pm @@ -44,10 +44,10 @@ sub BUILDARGS { } sub BUILDALL { - # NOTE: we ask Perl if we even + # NOTE: we ask Perl if we even # need to do this first, to avoid # extra meta level calls - return unless $_[0]->can('BUILD'); + return unless $_[0]->can('BUILD'); my ($self, $params) = @_; foreach my $method (reverse Class::MOP::class_of($self)->find_all_methods_by_name('BUILD')) { $method->{code}->execute($self, $params); @@ -74,7 +74,7 @@ sub DEMOLISHALL { } } -sub DESTROY { +sub DESTROY { # if we have an exception here ... if ($@) { # localize the $@ ... @@ -98,7 +98,7 @@ BEGIN { }'; } -# new does() methods will be created +# new does() methods will be created # as appropiate see Moose::Meta::Role sub does { my ($self, $role_name) = @_; @@ -107,13 +107,13 @@ sub does { || $meta->throw_error("You much supply a role name to does()"); foreach my $class ($meta->class_precedence_list) { my $m = $meta->initialize($class); - return 1 - if $m->can('does_role') && $m->does_role($role_name); + return 1 + if $m->can('does_role') && $m->does_role($role_name); } - return 0; + return 0; } -sub dump { +sub dump { my $self = shift; require Data::Dumper; local $Data::Dumper::Maxdepth = shift if @_; @@ -202,7 +202,7 @@ the maximum depth is 1, to avoid making a mess. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. @@ -217,6 +217,6 @@ Copyright 2006-2009 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +it under the same terms as Perl itself. =cut diff --git a/lib/Moose/Spec/Role.pod b/lib/Moose/Spec/Role.pod index 0d845da..44b1626 100644 --- a/lib/Moose/Spec/Role.pod +++ b/lib/Moose/Spec/Role.pod @@ -15,17 +15,17 @@ B This document is currently incomplete. =item Excluded Roles -A role can have a list of excluded roles, these are basically -roles that they shouldn't be composed with. This is not just -direct composition either, but also "inherited" composition. +A role can have a list of excluded roles, these are basically +roles that they shouldn't be composed with. This is not just +direct composition either, but also "inherited" composition. -This feature was taken from the Fortress language and is really +This feature was taken from the Fortress language and is really of most use when building a large set of role "building blocks" some of which should never be used together. =item Attributes -A roles attributes are similar to those of a class, except that +A roles attributes are similar to those of a class, except that they are not actually applied. This means that methods that are generated by an attributes accessor will not be generated in the role, but only created once the role is applied to a class. @@ -36,38 +36,38 @@ These are the methods defined within the role. Simple as that. =item Required Methods -A role can require a consuming class (or role) to provide a -given method. Failure to do so for classes is a fatal error, -while for roles it simply passes on the method requirement to +A role can require a consuming class (or role) to provide a +given method. Failure to do so for classes is a fatal error, +while for roles it simply passes on the method requirement to the consuming role. =item Required Attributes Just as a role can require methods, it can also require attributes. -The requirement fulfilling attribute must implement at least as much +The requirement fulfilling attribute must implement at least as much as is required. That means, for instance, that if the role requires that the attribute be read-only, then it must at least have a reader -and can also have a writer. It means that if the role requires that -the attribute be an ArrayRef, then it must either be an ArrayRef or +and can also have a writer. It means that if the role requires that +the attribute be an ArrayRef, then it must either be an ArrayRef or a subtype of an ArrayRef. =item Overridden Methods -The C and C keywords are allowed in roles, but -their behavior is different from that of it's class counterparts. -The C in a class refers directly to that class's superclass, +The C and C keywords are allowed in roles, but +their behavior is different from that of it's class counterparts. +The C in a class refers directly to that class's superclass, while the C in a role is deferred and only has meaning once -the role is composed into a class. Once that composition occurs, -C then refers to that class's superclass. +the role is composed into a class. Once that composition occurs, +C then refers to that class's superclass. -It is key to remember that roles do not have hierarchy, so they +It is key to remember that roles do not have hierarchy, so they can never have a I role. =item Method Modifiers -These are the C, C and C modifiers provided -in Moose classes. The difference here is that the modifiers are not -actually applied until the role is composed into a class (this is +These are the C, C and C modifiers provided +in Moose classes. The difference here is that the modifiers are not +actually applied until the role is composed into a class (this is just like attributes and the C keyword). =back @@ -96,7 +96,7 @@ just like attributes and the C keyword). =head3 Composing into a Instance -=head3 Composing into a Role +=head3 Composing into a Role =over 4 @@ -118,9 +118,9 @@ just like attributes and the C keyword). =head3 Role Summation -When multiple roles are added to another role (using the -C keyword) the roles are composed symmetrically. -The product of the composition is a composite role +When multiple roles are added to another role (using the +C keyword) the roles are composed symmetrically. +The product of the composition is a composite role (L). =over 4 @@ -134,74 +134,74 @@ The product of the composition is a composite role =item Attributes Attributes with the same name will conflict and are considered -a unrecoverable error. No other aspect of the attribute is -examined, it is enough that just the attribute names conflict. +a unrecoverable error. No other aspect of the attribute is +examined, it is enough that just the attribute names conflict. -The reason for such early and harsh conflicts with attributes -is because there is so much room for variance between two -attributes that the problem quickly explodes and rules get -very complex. It is my opinion that this complexity is not +The reason for such early and harsh conflicts with attributes +is because there is so much room for variance between two +attributes that the problem quickly explodes and rules get +very complex. It is my opinion that this complexity is not worth the trouble. =item Methods -Methods with the same name will conflict, but no error is -thrown, instead the method name is added to the list of +Methods with the same name will conflict, but no error is +thrown, instead the method name is added to the list of I methods for the new composite role. -To look at this in terms of set theory, each role can be -said to have a set of methods. The symmetric difference of -these two sets is the new set of methods for the composite -role, while the intersection of these two sets are the +To look at this in terms of set theory, each role can be +said to have a set of methods. The symmetric difference of +these two sets is the new set of methods for the composite +role, while the intersection of these two sets are the conflicts. This can be illustrated like so: Role A has method set { a, b, c } Role B has method set { c, d, e } - - The composite role (A,B) has + + The composite role (A,B) has method set { a, b, d, e } conflict set { c } =item Overridden methods -An overridden method can conflict in one of two ways. +An overridden method can conflict in one of two ways. -The first way is with another overridden method of the same -name, and this is considered an unrecoverable error. This +The first way is with another overridden method of the same +name, and this is considered an unrecoverable error. This is an obvious error since you cannot override a method twice -in the same class. +in the same class. -The second way for conflict is for an overridden method and a -regular method to have the same name. This is also an unrecoverable -error since there is no way to combine these two, nor is it -okay for both items to be composed into a single class at some -point. +The second way for conflict is for an overridden method and a +regular method to have the same name. This is also an unrecoverable +error since there is no way to combine these two, nor is it +okay for both items to be composed into a single class at some +point. The use of override in roles can be tricky, but if used carefully they can be a very powerful tool. =item Method Modifiers (before, around, after) -Method modifiers are the only place where the ordering of -role composition matters. This is due to the nature of -method modifiers themselves. +Method modifiers are the only place where the ordering of +role composition matters. This is due to the nature of +method modifiers themselves. -Since a method can have multiple method modifiers, these -are just collected in order to be later applied to the +Since a method can have multiple method modifiers, these +are just collected in order to be later applied to the class in that same order. -In general, great care should be taken in using method -modifiers in roles. The order sensitivity can possibly -lead to subtle and difficult to find bugs if they are -overused. As with all good things in life, moderation +In general, great care should be taken in using method +modifiers in roles. The order sensitivity can possibly +lead to subtle and difficult to find bugs if they are +overused. As with all good things in life, moderation is the key. =back =head3 Composition Edge Cases -This is a just a set of complex edge cases which can easily get -confused. This attempts to clarify those cases and provide an +This is a just a set of complex edge cases which can easily get +confused. This attempts to clarify those cases and provide an explanation of what is going on in them. =over 4 @@ -210,9 +210,9 @@ explanation of what is going on in them. Many people want to "override" methods in roles they are consuming. This works fine for classes, since the local class method is favored -over the role method. However in roles it is trickier, this is because -conflicts result in neither method being chosen and the method being -"required" instead. +over the role method. However in roles it is trickier, this is because +conflicts result in neither method being chosen and the method being +"required" instead. Here is an example of this (incorrect) type of overriding. @@ -229,7 +229,7 @@ Here is an example of this (incorrect) type of overriding. sub foo { ... } sub bar { ... } -Here the C methods conflict and the Role::FooBar now requires a +Here the C methods conflict and the Role::FooBar now requires a class or role consuming it to implement C. This is very often not what the user wants. @@ -251,36 +251,36 @@ not overriding at all, as is explained in the text below. use Moose::Role; with 'Role::Foo', 'Role::Bar'; - + sub foo { ... } This works because the combination of Role::Foo and Role::Bar produce -a conflict with the C method. This conflict results in the -composite role (that was created by the combination of Role::Foo -and Role::Bar using the I keyword) having a method requirement -of C. The Role::FooBar then fulfills this requirement. +a conflict with the C method. This conflict results in the +composite role (that was created by the combination of Role::Foo +and Role::Bar using the I keyword) having a method requirement +of C. The Role::FooBar then fulfills this requirement. -It is important to note that Role::FooBar is simply fulfilling the -required C method, and **NOT** overriding C. This is an +It is important to note that Role::FooBar is simply fulfilling the +required C method, and **NOT** overriding C. This is an important distinction to make. -Now here is another example of a (correct) type of overriding, this +Now here is another example of a (correct) type of overriding, this time using the I option. package Role::Foo; use Moose::Role; - + sub foo { ... } - + package Role::FooBar; use Moose::Role; - + with 'Role::Foo' => { excludes => 'foo' }; - + sub foo { ... } sub bar { ... } -By specifically excluding the C method during composition, +By specifically excluding the C method during composition, we allow B to define it's own version of C. =back @@ -291,10 +291,10 @@ we allow B to define it's own version of C. =item Traits -Roles are based on Traits, which originated in the Smalltalk -community. +Roles are based on Traits, which originated in the Smalltalk +community. -=over 4 +=over 4 =item L @@ -302,15 +302,15 @@ This is the main site for the original Traits papers. =item L -I created this implementation of traits several years ago, -after reading the papers linked above. (This module is now +I created this implementation of traits several years ago, +after reading the papers linked above. (This module is now maintained by Ovid and I am no longer involved with it). =back =item Roles -Since they are relatively new, and the Moose implementation +Since they are relatively new, and the Moose implementation is probably the most mature out there, roles don't have much to link to. However, here is some bits worth looking at (mostly related to Perl 6) @@ -319,7 +319,7 @@ related to Perl 6) =item L -This is chromatic's take on roles, which is worth reading since +This is chromatic's take on roles, which is worth reading since he was/is one of the big proponents of them. =item L diff --git a/lib/Moose/Util.pm b/lib/Moose/Util.pm index b49e4de..57a34f0 100644 --- a/lib/Moose/Util.pm +++ b/lib/Moose/Util.pm @@ -12,9 +12,9 @@ $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; my @exports = qw[ - find_meta + find_meta does_role - search_class_by_role + search_class_by_role ensure_all_roles apply_all_roles get_all_init_args @@ -40,7 +40,7 @@ sub does_role { my ($class_or_obj, $role) = @_; my $meta = find_meta($class_or_obj); - + return unless defined $meta; return unless $meta->can('does_role'); return 1 if $meta->does_role($role); @@ -49,14 +49,14 @@ sub does_role { sub search_class_by_role { my ($class_or_obj, $role_name) = @_; - + my $meta = find_meta($class_or_obj); return unless defined $meta; foreach my $class ($meta->class_precedence_list) { - - my $_meta = find_meta($class); + + my $_meta = find_meta($class); next unless defined $_meta; @@ -135,7 +135,7 @@ sub get_all_init_args { return +{ map { $_->init_arg => $_->get_value($instance) } grep { $_->has_value($instance) } - grep { defined($_->init_arg) } + grep { defined($_->init_arg) } $class->get_all_attributes }; } @@ -155,7 +155,7 @@ sub resolve_metatrait_alias { if $cache{$cache_key}{$metaclass_name}; my $possible_full_name - = 'Moose::Meta::' + = 'Moose::Meta::' . $type . '::Custom::' . ( $options{trait} ? "Trait::" : "" ) @@ -323,7 +323,7 @@ Here is a list of possible functions to write =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Moose/Util/TypeConstraints/OptimizedConstraints.pm b/lib/Moose/Util/TypeConstraints/OptimizedConstraints.pm index a4de7f5..341124e 100644 --- a/lib/Moose/Util/TypeConstraints/OptimizedConstraints.pm +++ b/lib/Moose/Util/TypeConstraints/OptimizedConstraints.pm @@ -60,7 +60,7 @@ bodies for various moose types =head1 DESCRIPTION -This file contains the hand optimized versions of Moose type constraints, +This file contains the hand optimized versions of Moose type constraints, no user serviceable parts inside. =head1 FUNCTIONS @@ -103,7 +103,7 @@ no user serviceable parts inside. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. diff --git a/lib/Test/Moose.pm b/lib/Test/Moose.pm index 4489fb6..d98b6c3 100644 --- a/lib/Test/Moose.pm +++ b/lib/Test/Moose.pm @@ -14,7 +14,7 @@ our $AUTHORITY = 'cpan:STEVAN'; my @exports = qw[ meta_ok - does_ok + does_ok has_attribute_ok ]; @@ -31,43 +31,43 @@ my $Test = Test::Builder->new; sub meta_ok ($;$) { my ($class_or_obj, $message) = @_; - + $message ||= "The object has a meta"; - + if (find_meta($class_or_obj)) { return $Test->ok(1, $message) } else { - return $Test->ok(0, $message); + return $Test->ok(0, $message); } } sub does_ok ($$;$) { my ($class_or_obj, $does, $message) = @_; - + $message ||= "The object does $does"; - + if (does_role($class_or_obj, $does)) { return $Test->ok(1, $message) } else { - return $Test->ok(0, $message); + return $Test->ok(0, $message); } } sub has_attribute_ok ($$;$) { my ($class_or_obj, $attr_name, $message) = @_; - + $message ||= "The object does has an attribute named $attr_name"; - - my $meta = find_meta($class_or_obj); - + + my $meta = find_meta($class_or_obj); + if ($meta->find_attribute_by_name($attr_name)) { return $Test->ok(1, $message) } else { - return $Test->ok(0, $message); - } + return $Test->ok(0, $message); + } } 1; @@ -83,7 +83,7 @@ Test::Moose - Test functions for Moose specific features =head1 SYNOPSIS use Test::More plan => 1; - use Test::Moose; + use Test::Moose; meta_ok($class_or_obj, "... Foo has a ->meta"); does_ok($class_or_obj, $role, "... Foo does the Baz role"); @@ -91,7 +91,7 @@ Test::Moose - Test functions for Moose specific features =head1 DESCRIPTION -This module provides some useful test functions for Moose based classes. It +This module provides some useful test functions for Moose based classes. It is an experimental first release, so comments and suggestions are very welcome. =head1 EXPORTED FUNCTIONS @@ -104,12 +104,12 @@ Tests if a class or object has a metaclass. =item B -Tests if a class or object does a certain role, similar to what C +Tests if a class or object does a certain role, similar to what C does for the C method. =item B -Tests if a class or object has a certain attribute, similar to what C +Tests if a class or object has a certain attribute, similar to what C does for the methods. =back @@ -146,7 +146,7 @@ does for the methods. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. @@ -163,7 +163,7 @@ Copyright 2007-2009 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +it under the same terms as Perl itself. =cut diff --git a/lib/oose.pm b/lib/oose.pm index 4273082..2773e0d 100644 --- a/lib/oose.pm +++ b/lib/oose.pm @@ -11,7 +11,7 @@ our $AUTHORITY = 'cpan:STEVAN'; BEGIN { my $package; - sub import { + sub import { $package = $_[1] || 'Class'; if ($package =~ /^\+/) { $package =~ s/^\+//; @@ -35,19 +35,19 @@ oose - syntactic sugar to make Moose one-liners easier # create a Moose class on the fly ... perl -Moose=Foo -e 'has bar => ( is=>q[ro], default => q[baz] ); print Foo->new->bar' # prints baz - + # loads an existing class (Moose or non-Moose) # and re-"opens" the package definition to make # debugging/introspection easier - perl -Moose=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list' + perl -Moose=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list' =head1 DESCRIPTION -oose.pm is a simple source filter that adds C -to the beginning of your script and was entirely created because typing +oose.pm is a simple source filter that adds C +to the beginning of your script and was entirely created because typing C was annoying me. -=head1 INTERFACE +=head1 INTERFACE oose provides exactly one method and it's automatically called by perl: diff --git a/t/010_basics/001_basic_class_setup.t b/t/010_basics/001_basic_class_setup.t index 0520394..acfde73 100644 --- a/t/010_basics/001_basic_class_setup.t +++ b/t/010_basics/001_basic_class_setup.t @@ -21,18 +21,18 @@ ok(Foo->meta->has_method('meta'), '... we got the &meta method'); ok(Foo->isa('Moose::Object'), '... Foo is automagically a Moose::Object'); dies_ok { - Foo->meta->has_method() + Foo->meta->has_method() } '... has_method requires an arg'; dies_ok { - Foo->meta->has_method('') + Foo->meta->has_method('') } '... has_method requires an arg'; can_ok('Foo', 'does'); foreach my $function (qw( extends - has + has before after around blessed confess type subtype as where diff --git a/t/010_basics/002_require_superclasses.t b/t/010_basics/002_require_superclasses.t index 28b52e0..36859ca 100644 --- a/t/010_basics/002_require_superclasses.t +++ b/t/010_basics/002_require_superclasses.t @@ -12,7 +12,7 @@ use Test::More tests => 5; { package Bar; use Moose; - + eval { extends 'Foo'; }; ::ok(!$@, '... loaded Foo superclass correctly'); } @@ -20,7 +20,7 @@ use Test::More tests => 5; { package Baz; use Moose; - + eval { extends 'Bar'; }; ::ok(!$@, '... loaded (inline) Bar superclass correctly'); } @@ -28,7 +28,7 @@ use Test::More tests => 5; { package Foo::Bar; use Moose; - + eval { extends 'Foo', 'Bar'; }; ::ok(!$@, '... loaded Foo and (inline) Bar superclass correctly'); } @@ -36,7 +36,7 @@ use Test::More tests => 5; { package Bling; use Moose; - + eval { extends 'No::Class'; }; ::ok($@, '... could not find the superclass (as expected)'); ::like($@, qr/^Could not load class \(No\:\:Class\) because \:/, '... and got the error we expected'); diff --git a/t/010_basics/003_super_and_override.t b/t/010_basics/003_super_and_override.t index 54d5c2d..9484082 100644 --- a/t/010_basics/003_super_and_override.t +++ b/t/010_basics/003_super_and_override.t @@ -11,25 +11,25 @@ use Test::Exception; { package Foo; use Moose; - + sub foo { 'Foo::foo' } - sub bar { 'Foo::bar' } + sub bar { 'Foo::bar' } sub baz { 'Foo::baz' } - + package Bar; use Moose; - + extends 'Foo'; - - override bar => sub { 'Bar::bar -> ' . super() }; - + + override bar => sub { 'Bar::bar -> ' . super() }; + package Baz; use Moose; - + extends 'Bar'; - - override bar => sub { 'Baz::bar -> ' . super() }; - override baz => sub { 'Baz::baz -> ' . super() }; + + override bar => sub { 'Baz::bar -> ' . super() }; + override baz => sub { 'Baz::baz -> ' . super() }; no Moose; # ensure super() still works after unimport } @@ -63,19 +63,19 @@ is($foo->baz(), 'Foo::baz', '... got the right value from &baz'); { package Bling; use Moose; - + sub bling { 'Bling::bling' } - + package Bling::Bling; use Moose; - + extends 'Bling'; - - sub bling { 'Bling::bling' } - + + sub bling { 'Bling::bling' } + ::dies_ok { override 'bling' => sub {}; } '... cannot override a method which has a local equivalent'; - + } diff --git a/t/010_basics/004_inner_and_augment.t b/t/010_basics/004_inner_and_augment.t index 15f4248..4957d26 100644 --- a/t/010_basics/004_inner_and_augment.t +++ b/t/010_basics/004_inner_and_augment.t @@ -11,32 +11,32 @@ use Test::Exception; { package Foo; use Moose; - + sub foo { 'Foo::foo(' . (inner() || '') . ')' } - sub bar { 'Foo::bar(' . (inner() || '') . ')' } - sub baz { 'Foo::baz(' . (inner() || '') . ')' } - + sub bar { 'Foo::bar(' . (inner() || '') . ')' } + sub baz { 'Foo::baz(' . (inner() || '') . ')' } + package Bar; use Moose; - + extends 'Foo'; - - augment foo => sub { 'Bar::foo(' . (inner() || '') . ')' }; - augment bar => sub { 'Bar::bar' }; + + augment foo => sub { 'Bar::foo(' . (inner() || '') . ')' }; + augment bar => sub { 'Bar::bar' }; no Moose; # ensure inner() still works after unimport - + package Baz; use Moose; - + extends 'Bar'; - - augment foo => sub { 'Baz::foo' }; - augment baz => sub { 'Baz::baz' }; - # this will actually never run, + augment foo => sub { 'Baz::foo' }; + augment baz => sub { 'Baz::baz' }; + + # this will actually never run, # because Bar::bar does not call inner() - augment bar => sub { 'Baz::bar' }; + augment bar => sub { 'Baz::bar' }; } my $baz = Baz->new(); @@ -68,19 +68,19 @@ is($foo->baz(), 'Foo::baz()', '... got the right value from &baz'); { package Bling; use Moose; - + sub bling { 'Bling::bling' } - + package Bling::Bling; use Moose; - + extends 'Bling'; - - sub bling { 'Bling::bling' } - + + sub bling { 'Bling::bling' } + ::dies_ok { augment 'bling' => sub {}; } '... cannot augment a method which has a local equivalent'; - + } diff --git a/t/010_basics/005_override_augment_inner_super.t b/t/010_basics/005_override_augment_inner_super.t index c81a506..295601e 100644 --- a/t/010_basics/005_override_augment_inner_super.t +++ b/t/010_basics/005_override_augment_inner_super.t @@ -10,23 +10,23 @@ use Test::More tests => 5; { package Foo; use Moose; - + sub foo { 'Foo::foo(' . (inner() || '') . ')' }; sub bar { 'Foo::bar(' . (inner() || '') . ')' } - + package Bar; use Moose; - + extends 'Foo'; - + augment 'foo' => sub { 'Bar::foo' }; - override 'bar' => sub { 'Bar::bar -> ' . super() }; - + override 'bar' => sub { 'Bar::bar -> ' . super() }; + package Baz; use Moose; - + extends 'Bar'; - + override 'foo' => sub { 'Baz::foo -> ' . super() }; augment 'bar' => sub { 'Baz::bar' }; } @@ -38,33 +38,33 @@ isa_ok($baz, 'Foo'); =pod -Let em clarify what is happening here. Baz::foo is calling -super(), which calls Bar::foo, which is an augmented sub -that calls Foo::foo, then calls inner() which actually -then calls Bar::foo. Confusing I know,.. but this is +Let em clarify what is happening here. Baz::foo is calling +super(), which calls Bar::foo, which is an augmented sub +that calls Foo::foo, then calls inner() which actually +then calls Bar::foo. Confusing I know,.. but this is *exactly* what is it supposed to do :) =cut -is($baz->foo, - 'Baz::foo -> Foo::foo(Bar::foo)', +is($baz->foo, + 'Baz::foo -> Foo::foo(Bar::foo)', '... got the right value from mixed augment/override foo'); =pod Allow me to clarify this one now ... -Since Baz::bar is an augment routine, it needs to find the +Since Baz::bar is an augment routine, it needs to find the correct inner() to be called by. In this case it is Foo::bar. However, Bar::bar is in-between us, so it should actually be called first. Bar::bar is an overriden sub, and calls super() -which in turn then calls our Foo::bar, which calls inner(), +which in turn then calls our Foo::bar, which calls inner(), which calls Baz::bar. Confusing I know, but it is correct :) =cut -is($baz->bar, - 'Bar::bar -> Foo::bar(Baz::bar)', +is($baz->bar, + 'Bar::bar -> Foo::bar(Baz::bar)', '... got the right value from mixed augment/override bar'); diff --git a/t/010_basics/006_override_and_foreign_classes.t b/t/010_basics/006_override_and_foreign_classes.t index 26fbb44..28907aa 100644 --- a/t/010_basics/006_override_and_foreign_classes.t +++ b/t/010_basics/006_override_and_foreign_classes.t @@ -10,14 +10,14 @@ use Test::More tests => 15; =pod This just tests the interaction of override/super -with non-Moose superclasses. It really should not -cause issues, the only thing it does is to create -a metaclass for Foo so that it can find the right +with non-Moose superclasses. It really should not +cause issues, the only thing it does is to create +a metaclass for Foo so that it can find the right super method. -This may end up being a sensitive issue for some -non-Moose classes, but in 99% of the cases it -should be just fine. +This may end up being a sensitive issue for some +non-Moose classes, but in 99% of the cases it +should be just fine. =cut @@ -25,27 +25,27 @@ should be just fine. package Foo; use strict; use warnings; - + sub new { bless {} => shift() } - + sub foo { 'Foo::foo' } - sub bar { 'Foo::bar' } + sub bar { 'Foo::bar' } sub baz { 'Foo::baz' } - + package Bar; use Moose; - + extends 'Foo'; - - override bar => sub { 'Bar::bar -> ' . super() }; - + + override bar => sub { 'Bar::bar -> ' . super() }; + package Baz; use Moose; - + extends 'Bar'; - - override bar => sub { 'Baz::bar -> ' . super() }; - override baz => sub { 'Baz::baz -> ' . super() }; + + override bar => sub { 'Baz::bar -> ' . super() }; + override baz => sub { 'Baz::baz -> ' . super() }; } my $baz = Baz->new(); diff --git a/t/010_basics/007_always_strict_warnings.t b/t/010_basics/007_always_strict_warnings.t index b81588c..bcac522 100644 --- a/t/010_basics/007_always_strict_warnings.t +++ b/t/010_basics/007_always_strict_warnings.t @@ -6,19 +6,19 @@ use Test::More tests => 10; { package Foo; use Moose; - + eval '$foo = 5;'; ::ok($@, '... got an error because strict is on'); ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error'); - + { my $warn; local $SIG{__WARN__} = sub { $warn = $_[0] }; ::ok(!$warn, '... no warning yet'); - + eval 'my $bar = 1 + "hello"'; - + ::ok($warn, '... got a warning'); ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); } @@ -28,19 +28,19 @@ use Test::More tests => 10; { package Bar; use Moose::Role; - + eval '$foo = 5;'; ::ok($@, '... got an error because strict is on'); ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error'); - + { my $warn; local $SIG{__WARN__} = sub { $warn = $_[0] }; ::ok(!$warn, '... no warning yet'); - + eval 'my $bar = 1 + "hello"'; - + ::ok($warn, '... got a warning'); ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); } diff --git a/t/010_basics/008_wrapped_method_cxt_propagation.t b/t/010_basics/008_wrapped_method_cxt_propagation.t index 226cf54..3147e4e 100644 --- a/t/010_basics/008_wrapped_method_cxt_propagation.t +++ b/t/010_basics/008_wrapped_method_cxt_propagation.t @@ -30,7 +30,7 @@ use Test::More tests => 7; after qw/scalar_or_array void/ => sub { my $self = shift; - $self->inc; + $self->inc; } } diff --git a/t/010_basics/009_import_unimport.t b/t/010_basics/009_import_unimport.t index 08e0ced..f956bee 100644 --- a/t/010_basics/009_import_unimport.t +++ b/t/010_basics/009_import_unimport.t @@ -7,8 +7,8 @@ use Test::More tests => 41; my @moose_exports = qw( - extends with - has + extends with + has before after around override augment @@ -36,8 +36,8 @@ ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports; # and check the type constraints as well my @moose_type_constraint_exports = qw( - type subtype as where message - coerce from via + type subtype as where message + coerce from via enum find_type_constraint ); diff --git a/t/010_basics/010_method_modifier_with_regexp.t b/t/010_basics/010_method_modifier_with_regexp.t index 41f55cd..64553f7 100644 --- a/t/010_basics/010_method_modifier_with_regexp.t +++ b/t/010_basics/010_method_modifier_with_regexp.t @@ -76,11 +76,11 @@ is( $Cat::AFTER_BARK_COUNTER, 2, 'after modifier is called twice' ); ::dies_ok { around qr/bark.*/ => sub {}; - } '... this is not currently supported'; - - ::dies_ok { + } '... this is not currently supported'; + + ::dies_ok { after qr/bark.*/ => sub {}; - } '... this is not currently supported'; + } '... this is not currently supported'; } diff --git a/t/010_basics/011_moose_respects_type_constraints.t b/t/010_basics/011_moose_respects_type_constraints.t index 96058f4..764df60 100644 --- a/t/010_basics/011_moose_respects_type_constraints.t +++ b/t/010_basics/011_moose_respects_type_constraints.t @@ -10,20 +10,20 @@ use Moose::Util::TypeConstraints; =pod -This tests demonstrates that Moose will not override -a preexisting type constraint of the same name when +This tests demonstrates that Moose will not override +a preexisting type constraint of the same name when making constraints for a Moose-class. It also tests that an attribute which uses a 'Foo' for -it's isa option will get the subtype Foo, and not a +it's isa option will get the subtype Foo, and not a type representing the Foo moose class. =cut -BEGIN { +BEGIN { # create this subtype first (in BEGIN) - subtype Foo - => as 'Value' + subtype Foo + => as 'Value' => where { $_ eq 'Foo' }; } @@ -43,7 +43,7 @@ ok(!$foo_constraint->check('Bar'), '... my constraint failed correctly'); { package Bar; use Moose; - + has 'foo' => (is => 'rw', isa => 'Foo'); } @@ -51,11 +51,11 @@ my $bar = Bar->new; isa_ok($bar, 'Bar'); lives_ok { - $bar->foo('Foo'); + $bar->foo('Foo'); } '... checked the type constraint correctly'; dies_ok { - $bar->foo(Foo->new); + $bar->foo(Foo->new); } '... checked the type constraint correctly'; diff --git a/t/010_basics/012_rebless.t b/t/010_basics/012_rebless.t index c8ec23e..04a0880 100644 --- a/t/010_basics/012_rebless.t +++ b/t/010_basics/012_rebless.t @@ -61,10 +61,10 @@ is($foo->lazy_classname, 'Parent', "lazy attribute initialized"); lives_ok { $foo->type_constrained(10.5) } "Num type constraint for now.."; # try to rebless, except it will fail due to Child's stricter type constraint -throws_ok { Child->meta->rebless_instance($foo) } +throws_ok { Child->meta->rebless_instance($foo) } qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' failed with value 10\.5/, '... this failed cause of type check'; -throws_ok { Child->meta->rebless_instance($bar) } +throws_ok { Child->meta->rebless_instance($bar) } qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' failed with value 5\.5/, '... this failed cause of type check';; @@ -80,6 +80,6 @@ is($foo->name, 'Junior', "Child->name's default came through"); is($foo->lazy_classname, 'Parent', "lazy attribute was already initialized"); is($bar->lazy_classname, 'Child', "lazy attribute just now initialized"); -throws_ok { $foo->type_constrained(10.5) } +throws_ok { $foo->type_constrained(10.5) } qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' failed with value 10\.5/, '... this failed cause of type check'; diff --git a/t/010_basics/013_create.t b/t/010_basics/013_create.t index e83972d..a21b37d 100644 --- a/t/010_basics/013_create.t +++ b/t/010_basics/013_create.t @@ -6,14 +6,14 @@ use warnings; use Test::More tests => 7; use Test::Exception; -{ +{ package Class; use Moose; - + package Foo; use Moose::Role; sub foo_role_applied { 1 } - + package Conflicts::With::Foo; use Moose::Role; sub foo_role_applied { 0 } diff --git a/t/010_basics/014_create_anon.t b/t/010_basics/014_create_anon.t index d324b4b..c75cc81 100644 --- a/t/010_basics/014_create_anon.t +++ b/t/010_basics/014_create_anon.t @@ -7,14 +7,14 @@ use Test::More tests => 8; use Moose::Meta::Class; -{ +{ package Class; use Moose; - + package Foo; use Moose::Role; sub foo_role_applied { 1 } - + package Bar; use Moose::Role; sub bar_role_applied { 1 } @@ -27,12 +27,12 @@ use Moose::Meta::Class; superclasses => ['Class'], roles => ['Foo'], ); - + my $class_and_foo_2 = Moose::Meta::Class->create_anon_class( superclasses => ['Class'], roles => ['Foo'], ); - + isnt $class_and_foo_1->name, $class_and_foo_2->name, 'creating the same class twice without caching results in 2 classes'; @@ -47,18 +47,18 @@ use Moose::Meta::Class; roles => ['Foo'], cache => 1, ); - + my $class_and_foo_2 = Moose::Meta::Class->create_anon_class( superclasses => ['Class'], roles => ['Foo'], cache => 1, ); - + is $class_and_foo_1->name, $class_and_foo_2->name, 'with cache, the same class is the same class'; - + map { ok $_->name->foo_role_applied } ($class_and_foo_1, $class_and_foo_2); - + my $class_and_bar = Moose::Meta::Class->create_anon_class( superclasses => ['Class'], roles => ['Bar'], @@ -67,6 +67,6 @@ use Moose::Meta::Class; isnt $class_and_foo_1->name, $class_and_bar, 'class_and_foo and class_and_bar are different'; - + ok $class_and_bar->name->bar_role_applied; } diff --git a/t/010_basics/015_buildargs.t b/t/010_basics/015_buildargs.t index bff4aeb..ac291a1 100644 --- a/t/010_basics/015_buildargs.t +++ b/t/010_basics/015_buildargs.t @@ -10,7 +10,7 @@ use Test::More tests => 14; use Moose; has bar => ( is => "rw" ); - has baz => ( is => "rw" ); + has baz => ( is => "rw" ); sub BUILDARGS { my ( $self, @args ) = @_; @@ -37,7 +37,7 @@ foreach my $class qw(Foo Bar) { my $o = $class->new(42, baz => 47); is($o->bar, 42, '... got the right bar'); is($o->baz, 47, '... got the right bar'); - } + } } diff --git a/t/020_attributes/001_attribute_reader_generation.t b/t/020_attributes/001_attribute_reader_generation.t index d27dbfc..6f6a9f2 100644 --- a/t/020_attributes/001_attribute_reader_generation.t +++ b/t/020_attributes/001_attribute_reader_generation.t @@ -11,22 +11,22 @@ use Test::Exception; { package Foo; use Moose; - + eval { has 'foo' => ( reader => 'get_foo' ); }; ::ok(!$@, '... created the reader method okay'); - + eval { has 'lazy_foo' => ( - reader => 'get_lazy_foo', - lazy => 1, + reader => 'get_lazy_foo', + lazy => 1, default => sub { 10 } ); }; - ::ok(!$@, '... created the lazy reader method okay') or warn $@; + ::ok(!$@, '... created the lazy reader method okay') or warn $@; } { @@ -38,14 +38,14 @@ use Test::Exception; dies_ok { $foo->get_foo(100); } '... get_foo is a read-only'; - + ok(!exists($foo->{lazy_foo}), '... no value in get_lazy_foo slot'); - + can_ok($foo, 'get_lazy_foo'); is($foo->get_lazy_foo(), 10, '... got an deferred value'); dies_ok { $foo->get_lazy_foo(100); - } '... get_lazy_foo is a read-only'; + } '... get_lazy_foo is a read-only'; } { @@ -53,7 +53,7 @@ use Test::Exception; isa_ok($foo, 'Foo'); is($foo->get_foo(), 10, '... got the correct value'); - is($foo->get_lazy_foo(), 100, '... got the correct value'); + is($foo->get_lazy_foo(), 100, '... got the correct value'); } diff --git a/t/020_attributes/002_attribute_writer_generation.t b/t/020_attributes/002_attribute_writer_generation.t index 1b25f3c..f7f776c 100644 --- a/t/020_attributes/002_attribute_writer_generation.t +++ b/t/020_attributes/002_attribute_writer_generation.t @@ -13,7 +13,7 @@ use Scalar::Util 'isweak'; { package Foo; use Moose; - + eval { has 'foo' => ( reader => 'get_foo', @@ -38,8 +38,8 @@ use Scalar::Util 'isweak'; isa => 'Int', ); }; - ::ok(!$@, '... created the writer method with type constraint okay'); - + ::ok(!$@, '... created the writer method with type constraint okay'); + eval { has 'foo_weak' => ( reader => 'get_foo_weak', @@ -47,7 +47,7 @@ use Scalar::Util 'isweak'; weak_ref => 1 ); }; - ::ok(!$@, '... created the writer method with weak_ref okay'); + ::ok(!$@, '... created the writer method with weak_ref okay'); } { @@ -61,12 +61,12 @@ use Scalar::Util 'isweak'; lives_ok { $foo->set_foo(100); } '... set_foo wrote successfully'; - is($foo->get_foo(), 100, '... got the correct set value'); - - ok(!isweak($foo->{foo}), '... it is not a weak reference'); - + is($foo->get_foo(), 100, '... got the correct set value'); + + ok(!isweak($foo->{foo}), '... it is not a weak reference'); + # required writer - + dies_ok { Foo->new; } '... cannot create without the required attribute'; @@ -76,44 +76,44 @@ use Scalar::Util 'isweak'; lives_ok { $foo->set_foo_required(100); } '... set_foo_required wrote successfully'; - is($foo->get_foo_required(), 100, '... got the correct set value'); - + is($foo->get_foo_required(), 100, '... got the correct set value'); + dies_ok { $foo->set_foo_required(); } '... set_foo_required died successfully with no value'; lives_ok { $foo->set_foo_required(undef); - } '... set_foo_required did accept undef'; + } '... set_foo_required did accept undef'; + + ok(!isweak($foo->{foo_required}), '... it is not a weak reference'); - ok(!isweak($foo->{foo_required}), '... it is not a weak reference'); - # with type constraint - + can_ok($foo, 'set_foo_int'); is($foo->get_foo_int(), undef, '... got an unset value'); lives_ok { $foo->set_foo_int(100); } '... set_foo_int wrote successfully'; - is($foo->get_foo_int(), 100, '... got the correct set value'); - + is($foo->get_foo_int(), 100, '... got the correct set value'); + dies_ok { $foo->set_foo_int("Foo"); - } '... set_foo_int died successfully'; - - ok(!isweak($foo->{foo_int}), '... it is not a weak reference'); - + } '... set_foo_int died successfully'; + + ok(!isweak($foo->{foo_int}), '... it is not a weak reference'); + # with weak_ref - + my $test = []; - + can_ok($foo, 'set_foo_weak'); is($foo->get_foo_weak(), undef, '... got an unset value'); lives_ok { $foo->set_foo_weak($test); } '... set_foo_weak wrote successfully'; - is($foo->get_foo_weak(), $test, '... got the correct set value'); - + is($foo->get_foo_weak(), $test, '... got the correct set value'); + ok(isweak($foo->{foo_weak}), '... it is a weak reference'); } diff --git a/t/020_attributes/003_attribute_accessor_generation.t b/t/020_attributes/003_attribute_accessor_generation.t index 0355c2b..73487c1 100644 --- a/t/020_attributes/003_attribute_accessor_generation.t +++ b/t/020_attributes/003_attribute_accessor_generation.t @@ -13,23 +13,23 @@ use Scalar::Util 'isweak'; { package Foo; use Moose; - + eval { has 'foo' => ( accessor => 'foo', ); }; ::ok(!$@, '... created the accessor method okay'); - + eval { has 'lazy_foo' => ( - accessor => 'lazy_foo', - lazy => 1, + accessor => 'lazy_foo', + lazy => 1, default => sub { 10 } ); }; - ::ok(!$@, '... created the lazy accessor method okay'); - + ::ok(!$@, '... created the lazy accessor method okay'); + eval { has 'foo_required' => ( @@ -45,15 +45,15 @@ use Scalar::Util 'isweak'; isa => 'Int', ); }; - ::ok(!$@, '... created the accessor method with type constraint okay'); - + ::ok(!$@, '... created the accessor method with type constraint okay'); + eval { has 'foo_weak' => ( accessor => 'foo_weak', weak_ref => 1 ); }; - ::ok(!$@, '... created the accessor method with weak_ref okay'); + ::ok(!$@, '... created the accessor method with weak_ref okay'); eval { has 'foo_deref' => ( @@ -62,7 +62,7 @@ use Scalar::Util 'isweak'; auto_deref => 1, ); }; - ::ok(!$@, '... created the accessor method with auto_deref okay'); + ::ok(!$@, '... created the accessor method with auto_deref okay'); eval { has 'foo_deref_ro' => ( @@ -71,7 +71,7 @@ use Scalar::Util 'isweak'; auto_deref => 1, ); }; - ::ok(!$@, '... created the reader method with auto_deref okay'); + ::ok(!$@, '... created the reader method with auto_deref okay'); eval { has 'foo_deref_hash' => ( @@ -80,7 +80,7 @@ use Scalar::Util 'isweak'; auto_deref => 1, ); }; - ::ok(!$@, '... created the reader method with auto_deref okay'); + ::ok(!$@, '... created the reader method with auto_deref okay'); } { @@ -94,12 +94,12 @@ use Scalar::Util 'isweak'; lives_ok { $foo->foo(100); } '... foo wrote successfully'; - is($foo->foo(), 100, '... got the correct set value'); - - ok(!isweak($foo->{foo}), '... it is not a weak reference'); - + is($foo->foo(), 100, '... got the correct set value'); + + ok(!isweak($foo->{foo}), '... it is not a weak reference'); + # required writer - + dies_ok { Foo->new; } '... cannot create without the required attribute'; @@ -109,49 +109,49 @@ use Scalar::Util 'isweak'; lives_ok { $foo->foo_required(100); } '... foo_required wrote successfully'; - is($foo->foo_required(), 100, '... got the correct set value'); - + is($foo->foo_required(), 100, '... got the correct set value'); + lives_ok { $foo->foo_required(undef); - } '... foo_required did not die with undef'; + } '... foo_required did not die with undef'; is($foo->foo_required, undef, "value is undef"); - ok(!isweak($foo->{foo_required}), '... it is not a weak reference'); - + ok(!isweak($foo->{foo_required}), '... it is not a weak reference'); + # lazy - + ok(!exists($foo->{lazy_foo}), '... no value in lazy_foo slot'); - + can_ok($foo, 'lazy_foo'); - is($foo->lazy_foo(), 10, '... got an deferred value'); - + is($foo->lazy_foo(), 10, '... got an deferred value'); + # with type constraint - + can_ok($foo, 'foo_int'); is($foo->foo_int(), undef, '... got an unset value'); lives_ok { $foo->foo_int(100); } '... foo_int wrote successfully'; - is($foo->foo_int(), 100, '... got the correct set value'); - + is($foo->foo_int(), 100, '... got the correct set value'); + dies_ok { $foo->foo_int("Foo"); - } '... foo_int died successfully'; - - ok(!isweak($foo->{foo_int}), '... it is not a weak reference'); - + } '... foo_int died successfully'; + + ok(!isweak($foo->{foo_int}), '... it is not a weak reference'); + # with weak_ref - + my $test = []; - + can_ok($foo, 'foo_weak'); is($foo->foo_weak(), undef, '... got an unset value'); lives_ok { $foo->foo_weak($test); } '... foo_weak wrote successfully'; - is($foo->foo_weak(), $test, '... got the correct set value'); - + is($foo->foo_weak(), $test, '... got the correct set value'); + ok(isweak($foo->{foo_weak}), '... it is a weak reference'); can_ok( $foo, 'foo_deref'); diff --git a/t/020_attributes/004_attribute_triggers.t b/t/020_attributes/004_attribute_triggers.t index cbb54ca..e799399 100644 --- a/t/020_attributes/004_attribute_triggers.t +++ b/t/020_attributes/004_attribute_triggers.t @@ -13,32 +13,32 @@ use Test::Exception; { package Foo; use Moose; - - has 'bar' => (is => 'rw', + + has 'bar' => (is => 'rw', isa => 'Maybe[Bar]', - trigger => sub { + trigger => sub { my ($self, $bar) = @_; $bar->foo($self) if defined $bar; }); - + has 'baz' => (writer => 'set_baz', reader => 'get_baz', isa => 'Baz', - trigger => sub { + trigger => sub { my ($self, $baz) = @_; $baz->foo($self); - }); - - + }); + + package Bar; use Moose; - - has 'foo' => (is => 'rw', isa => 'Foo', weak_ref => 1); - + + has 'foo' => (is => 'rw', isa => 'Foo', weak_ref => 1); + package Baz; use Moose; - - has 'foo' => (is => 'rw', isa => 'Foo', weak_ref => 1); + + has 'foo' => (is => 'rw', isa => 'Foo', weak_ref => 1); } { @@ -59,13 +59,13 @@ use Test::Exception; is($bar->foo, $foo, '... which in turn set the value bar.foo correctly'); ok(isweak($bar->{foo}), '... bar.foo is a weak reference'); - + lives_ok { $foo->bar(undef); } '... did not die un-setting bar'; is($foo->bar, undef, '... set the value foo.bar correctly'); - is($bar->foo, $foo, '... which in turn set the value bar.foo correctly'); + is($bar->foo, $foo, '... which in turn set the value bar.foo correctly'); # test the writer @@ -85,9 +85,9 @@ use Test::Exception; my $baz = Baz->new; isa_ok($baz, 'Baz'); - + my $foo = Foo->new(bar => $bar, baz => $baz); - isa_ok($foo, 'Foo'); + isa_ok($foo, 'Foo'); is($foo->bar, $bar, '... set the value foo.bar correctly'); is($bar->foo, $foo, '... which in turn set the value bar.foo correctly'); @@ -105,14 +105,14 @@ use Test::Exception; { package Bling; use Moose; - - ::dies_ok { + + ::dies_ok { has('bling' => (is => 'rw', trigger => 'Fail')); } '... a trigger must be a CODE ref'; - - ::dies_ok { + + ::dies_ok { has('bling' => (is => 'rw', trigger => [])); - } '... a trigger must be a CODE ref'; + } '... a trigger must be a CODE ref'; } # Triggers do not fire on built values diff --git a/t/020_attributes/005_attribute_does.t b/t/020_attributes/005_attribute_does.t index d05a808..01145f8 100644 --- a/t/020_attributes/005_attribute_does.t +++ b/t/020_attributes/005_attribute_does.t @@ -11,28 +11,28 @@ use Test::Exception; { package Foo::Role; use Moose::Role; - use Moose::Util::TypeConstraints; + use Moose::Util::TypeConstraints; - # if does() exists on its own, then - # we create a type constraint for + # if does() exists on its own, then + # we create a type constraint for # it, just as we do for isa() - has 'bar' => (is => 'rw', does => 'Bar::Role'); + has 'bar' => (is => 'rw', does => 'Bar::Role'); has 'baz' => ( - is => 'rw', + is => 'rw', does => subtype('Role', where { $_->does('Bar::Role') }) - ); + ); package Bar::Role; use Moose::Role; # if isa and does appear together, then see if Class->does(Role) - # if it does work... then the does() check is actually not needed - # since the isa() check will imply the does() check - has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role'); - + # if it does work... then the does() check is actually not needed + # since the isa() check will imply the does() check + has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role'); + package Foo::Class; use Moose; - + with 'Foo::Role'; package Bar::Class; @@ -68,7 +68,7 @@ lives_ok { $bar->foo($foo); } '... foo passed the type constraint okay'; - + # some error conditions @@ -81,15 +81,15 @@ lives_ok { ::dies_ok { has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class'); } '... cannot have a does() which is not done by the isa()'; -} +} { package Bling; use strict; use warnings; - + sub bling { 'Bling::bling' } - + package Bling::Bling; use Moose; @@ -101,4 +101,4 @@ lives_ok { } - + diff --git a/t/020_attributes/007_attribute_custom_metaclass.t b/t/020_attributes/007_attribute_custom_metaclass.t index eb74b0c..de3cb5b 100644 --- a/t/020_attributes/007_attribute_custom_metaclass.t +++ b/t/020_attributes/007_attribute_custom_metaclass.t @@ -8,12 +8,12 @@ use Test::Exception; -{ +{ package Foo::Meta::Attribute; use Moose; - + extends 'Moose::Meta::Attribute'; - + around 'new' => sub { my $next = shift; my $self = shift; @@ -23,7 +23,7 @@ use Test::Exception; package Foo; use Moose; - + has 'foo' => (metaclass => 'Foo::Meta::Attribute'); } { @@ -48,46 +48,46 @@ use Test::Exception; { package Bar::Meta::Attribute; use Moose; - - extends 'Class::MOP::Attribute'; - + + extends 'Class::MOP::Attribute'; + package Bar; use Moose; - + ::lives_ok { - has 'bar' => (metaclass => 'Bar::Meta::Attribute'); + has 'bar' => (metaclass => 'Bar::Meta::Attribute'); } '... the attribute metaclass need not be a Moose::Meta::Attribute as long as it behaves'; } { package Moose::Meta::Attribute::Custom::Foo; sub register_implementation { 'Foo::Meta::Attribute' } - + package Moose::Meta::Attribute::Custom::Bar; use Moose; - + extends 'Moose::Meta::Attribute'; - + package Another::Foo; use Moose; - + ::lives_ok { - has 'foo' => (metaclass => 'Foo'); + has 'foo' => (metaclass => 'Foo'); } '... the attribute metaclass alias worked correctly'; - + ::lives_ok { - has 'bar' => (metaclass => 'Bar'); - } '... the attribute metaclass alias worked correctly'; + has 'bar' => (metaclass => 'Bar'); + } '... the attribute metaclass alias worked correctly'; } { my $foo_attr = Another::Foo->meta->get_attribute('foo'); isa_ok($foo_attr, 'Foo::Meta::Attribute'); isa_ok($foo_attr, 'Moose::Meta::Attribute'); - + my $bar_attr = Another::Foo->meta->get_attribute('bar'); isa_ok($bar_attr, 'Moose::Meta::Attribute::Custom::Bar'); - isa_ok($bar_attr, 'Moose::Meta::Attribute'); + isa_ok($bar_attr, 'Moose::Meta::Attribute'); } diff --git a/t/020_attributes/008_attribute_type_unions.t b/t/020_attributes/008_attribute_type_unions.t index 95ce5f9..86dfbcf 100644 --- a/t/020_attributes/008_attribute_type_unions.t +++ b/t/020_attributes/008_attribute_type_unions.t @@ -11,7 +11,7 @@ use Test::Exception; { package Foo; use Moose; - + has 'bar' => (is => 'rw', isa => 'ArrayRef | HashRef'); } @@ -55,7 +55,7 @@ dies_ok { { package Bar; use Moose; - + has 'baz' => (is => 'rw', isa => 'Str | CodeRef'); } diff --git a/t/020_attributes/009_attribute_inherited_slot_specs.t b/t/020_attributes/009_attribute_inherited_slot_specs.t index 3b53a1d..46963b7 100644 --- a/t/020_attributes/009_attribute_inherited_slot_specs.t +++ b/t/020_attributes/009_attribute_inherited_slot_specs.t @@ -11,99 +11,99 @@ use Test::Exception; { package Thing; use Moose; - + sub hello { 'Hello World (from Thing)' } - sub goodbye { 'Goodbye World (from Thing)' } - + sub goodbye { 'Goodbye World (from Thing)' } + package Foo; use Moose; use Moose::Util::TypeConstraints; - - subtype 'FooStr' + + subtype 'FooStr' => as 'Str' => where { /Foo/ }; - - coerce 'FooStr' + + coerce 'FooStr' => from ArrayRef => via { 'FooArrayRef' }; - + has 'bar' => (is => 'ro', isa => 'Str', default => 'Foo::bar'); - has 'baz' => (is => 'rw', isa => 'Ref'); - has 'foo' => (is => 'rw', isa => 'FooStr'); - - has 'gorch' => (is => 'ro'); - has 'gloum' => (is => 'ro', default => sub {[]}); - + has 'baz' => (is => 'rw', isa => 'Ref'); + has 'foo' => (is => 'rw', isa => 'FooStr'); + + has 'gorch' => (is => 'ro'); + has 'gloum' => (is => 'ro', default => sub {[]}); + has 'bling' => (is => 'ro', isa => 'Thing'); - has 'blang' => (is => 'ro', isa => 'Thing', handles => ['goodbye']); - + has 'blang' => (is => 'ro', isa => 'Thing', handles => ['goodbye']); + has 'bunch_of_stuff' => (is => 'rw', isa => 'ArrayRef'); - has 'one_last_one' => (is => 'rw', isa => 'Ref'); - + has 'one_last_one' => (is => 'rw', isa => 'Ref'); + # this one will work here .... has 'fail' => (isa => 'CodeRef'); - has 'other_fail'; - + has 'other_fail'; + package Bar; use Moose; use Moose::Util::TypeConstraints; - + extends 'Foo'; - ::lives_ok { - has '+bar' => (default => 'Bar::bar'); - } '... we can change the default attribute option'; - - ::lives_ok { - has '+baz' => (isa => 'ArrayRef'); - } '... we can add change the isa as long as it is a subtype'; - - ::lives_ok { - has '+foo' => (coerce => 1); - } '... we can change/add coerce as an attribute option'; - - ::lives_ok { - has '+gorch' => (required => 1); - } '... we can change/add required as an attribute option'; - - ::lives_ok { - has '+gloum' => (lazy => 1); - } '... we can change/add lazy as an attribute option'; + ::lives_ok { + has '+bar' => (default => 'Bar::bar'); + } '... we can change the default attribute option'; + + ::lives_ok { + has '+baz' => (isa => 'ArrayRef'); + } '... we can add change the isa as long as it is a subtype'; + + ::lives_ok { + has '+foo' => (coerce => 1); + } '... we can change/add coerce as an attribute option'; + + ::lives_ok { + has '+gorch' => (required => 1); + } '... we can change/add required as an attribute option'; + + ::lives_ok { + has '+gloum' => (lazy => 1); + } '... we can change/add lazy as an attribute option'; ::lives_ok { has '+gloum' => (lazy_build => 1); } '... we can add lazy_build as an attribute option'; ::lives_ok { - has '+bunch_of_stuff' => (isa => 'ArrayRef[Int]'); + has '+bunch_of_stuff' => (isa => 'ArrayRef[Int]'); } '... extend an attribute with parameterized type'; - + ::lives_ok { - has '+one_last_one' => (isa => subtype('Ref', where { blessed $_ eq 'CODE' })); - } '... extend an attribute with anon-subtype'; - + has '+one_last_one' => (isa => subtype('Ref', where { blessed $_ eq 'CODE' })); + } '... extend an attribute with anon-subtype'; + ::lives_ok { - has '+one_last_one' => (isa => 'Value'); - } '... now can extend an attribute with a non-subtype'; + has '+one_last_one' => (isa => 'Value'); + } '... now can extend an attribute with a non-subtype'; ::lives_ok { - has '+bling' => (handles => ['hello']); + has '+bling' => (handles => ['hello']); } '... we can add the handles attribute option'; - + # this one will *not* work here .... ::dies_ok { - has '+blang' => (handles => ['hello']); - } '... we can not alter the handles attribute option'; - ::lives_ok { - has '+fail' => (isa => 'Ref'); - } '... can now create an attribute with an improper subtype relation'; - ::dies_ok { - has '+other_fail' => (trigger => sub {}); - } '... cannot create an attribute with an illegal option'; - ::dies_ok { - has '+other_fail' => (weak_ref => 1); - } '... cannot create an attribute with an illegal option'; + has '+blang' => (handles => ['hello']); + } '... we can not alter the handles attribute option'; + ::lives_ok { + has '+fail' => (isa => 'Ref'); + } '... can now create an attribute with an improper subtype relation'; + ::dies_ok { + has '+other_fail' => (trigger => sub {}); + } '... cannot create an attribute with an illegal option'; + ::dies_ok { + has '+other_fail' => (weak_ref => 1); + } '... cannot create an attribute with an illegal option'; ::throws_ok { has '+does_not_exist' => (isa => 'Str'); } qr/in Bar/, '... cannot extend a non-existing attribute'; @@ -127,7 +127,7 @@ is($foo->baz, undef, '... got the right undef default value'); my $hash_ref = {}; lives_ok { $foo->baz($hash_ref) } '... Foo::baz accepts hash refs'; is($foo->baz, $hash_ref, '... got the right value assigned to baz'); - + my $array_ref = []; lives_ok { $foo->baz($array_ref) } '... Foo::baz accepts an array ref'; is($foo->baz, $array_ref, '... got the right value assigned to baz'); @@ -135,14 +135,14 @@ is($foo->baz, undef, '... got the right undef default value'); my $scalar_ref = \(my $var); lives_ok { $foo->baz($scalar_ref) } '... Foo::baz accepts scalar ref'; is($foo->baz, $scalar_ref, '... got the right value assigned to baz'); - - lives_ok { $foo->bunch_of_stuff([qw[one two three]]) } '... Foo::bunch_of_stuff accepts an array of strings'; - - lives_ok { $foo->one_last_one(sub { 'Hello World'}) } '... Foo::one_last_one accepts a code ref'; - + + lives_ok { $foo->bunch_of_stuff([qw[one two three]]) } '... Foo::bunch_of_stuff accepts an array of strings'; + + lives_ok { $foo->one_last_one(sub { 'Hello World'}) } '... Foo::one_last_one accepts a code ref'; + my $code_ref = sub { 1 }; lives_ok { $foo->baz($code_ref) } '... Foo::baz accepts a code ref'; - is($foo->baz, $code_ref, '... got the right value assigned to baz'); + is($foo->baz, $code_ref, '... got the right value assigned to baz'); } dies_ok { @@ -169,17 +169,17 @@ is($bar->baz, undef, '... got the right undef default value'); { my $hash_ref = {}; dies_ok { $bar->baz($hash_ref) } '... Bar::baz does not accept hash refs'; - + my $array_ref = []; lives_ok { $bar->baz($array_ref) } '... Bar::baz can accept an array ref'; is($bar->baz, $array_ref, '... got the right value assigned to baz'); my $scalar_ref = \(my $var); dies_ok { $bar->baz($scalar_ref) } '... Bar::baz does not accept a scalar ref'; - - lives_ok { $bar->bunch_of_stuff([1, 2, 3]) } '... Bar::bunch_of_stuff accepts an array of ints'; - dies_ok { $bar->bunch_of_stuff([qw[one two three]]) } '... Bar::bunch_of_stuff does not accept an array of strings'; - + + lives_ok { $bar->bunch_of_stuff([1, 2, 3]) } '... Bar::bunch_of_stuff accepts an array of ints'; + dies_ok { $bar->bunch_of_stuff([qw[one two three]]) } '... Bar::bunch_of_stuff does not accept an array of strings'; + my $code_ref = sub { 1 }; dies_ok { $bar->baz($code_ref) } '... Bar::baz does not accept a code ref'; } @@ -197,66 +197,66 @@ ok(!Bar->meta->has_attribute('blang'), '... Bar has a blang attr'); ok(Bar->meta->has_attribute('fail'), '... Bar has a fail attr'); ok(!Bar->meta->has_attribute('other_fail'), '... Bar does not have an other_fail attr'); -isnt(Foo->meta->get_attribute('foo'), - Bar->meta->get_attribute('foo'), +isnt(Foo->meta->get_attribute('foo'), + Bar->meta->get_attribute('foo'), '... Foo and Bar have different copies of foo'); -isnt(Foo->meta->get_attribute('bar'), - Bar->meta->get_attribute('bar'), +isnt(Foo->meta->get_attribute('bar'), + Bar->meta->get_attribute('bar'), '... Foo and Bar have different copies of bar'); -isnt(Foo->meta->get_attribute('baz'), - Bar->meta->get_attribute('baz'), - '... Foo and Bar have different copies of baz'); -isnt(Foo->meta->get_attribute('gorch'), - Bar->meta->get_attribute('gorch'), +isnt(Foo->meta->get_attribute('baz'), + Bar->meta->get_attribute('baz'), + '... Foo and Bar have different copies of baz'); +isnt(Foo->meta->get_attribute('gorch'), + Bar->meta->get_attribute('gorch'), '... Foo and Bar have different copies of gorch'); -isnt(Foo->meta->get_attribute('gloum'), - Bar->meta->get_attribute('gloum'), - '... Foo and Bar have different copies of gloum'); -isnt(Foo->meta->get_attribute('bling'), - Bar->meta->get_attribute('bling'), - '... Foo and Bar have different copies of bling'); -isnt(Foo->meta->get_attribute('bunch_of_stuff'), - Bar->meta->get_attribute('bunch_of_stuff'), - '... Foo and Bar have different copies of bunch_of_stuff'); - -ok(Bar->meta->get_attribute('bar')->has_type_constraint, +isnt(Foo->meta->get_attribute('gloum'), + Bar->meta->get_attribute('gloum'), + '... Foo and Bar have different copies of gloum'); +isnt(Foo->meta->get_attribute('bling'), + Bar->meta->get_attribute('bling'), + '... Foo and Bar have different copies of bling'); +isnt(Foo->meta->get_attribute('bunch_of_stuff'), + Bar->meta->get_attribute('bunch_of_stuff'), + '... Foo and Bar have different copies of bunch_of_stuff'); + +ok(Bar->meta->get_attribute('bar')->has_type_constraint, '... Bar::bar inherited the type constraint too'); -ok(Bar->meta->get_attribute('baz')->has_type_constraint, - '... Bar::baz inherited the type constraint too'); +ok(Bar->meta->get_attribute('baz')->has_type_constraint, + '... Bar::baz inherited the type constraint too'); -is(Bar->meta->get_attribute('bar')->type_constraint->name, +is(Bar->meta->get_attribute('bar')->type_constraint->name, 'Str', '... Bar::bar inherited the right type constraint too'); -is(Foo->meta->get_attribute('baz')->type_constraint->name, +is(Foo->meta->get_attribute('baz')->type_constraint->name, 'Ref', '... Foo::baz inherited the right type constraint too'); -is(Bar->meta->get_attribute('baz')->type_constraint->name, - 'ArrayRef', '... Bar::baz inherited the right type constraint too'); - -ok(!Foo->meta->get_attribute('gorch')->is_required, +is(Bar->meta->get_attribute('baz')->type_constraint->name, + 'ArrayRef', '... Bar::baz inherited the right type constraint too'); + +ok(!Foo->meta->get_attribute('gorch')->is_required, '... Foo::gorch is not a required attr'); -ok(Bar->meta->get_attribute('gorch')->is_required, +ok(Bar->meta->get_attribute('gorch')->is_required, '... Bar::gorch is a required attr'); - -is(Foo->meta->get_attribute('bunch_of_stuff')->type_constraint->name, + +is(Foo->meta->get_attribute('bunch_of_stuff')->type_constraint->name, 'ArrayRef', '... Foo::bunch_of_stuff is an ArrayRef'); -is(Bar->meta->get_attribute('bunch_of_stuff')->type_constraint->name, +is(Bar->meta->get_attribute('bunch_of_stuff')->type_constraint->name, 'ArrayRef[Int]', '... Bar::bunch_of_stuff is an ArrayRef[Int]'); - -ok(!Foo->meta->get_attribute('gloum')->is_lazy, + +ok(!Foo->meta->get_attribute('gloum')->is_lazy, '... Foo::gloum is not a required attr'); -ok(Bar->meta->get_attribute('gloum')->is_lazy, - '... Bar::gloum is a required attr'); - -ok(!Foo->meta->get_attribute('foo')->should_coerce, +ok(Bar->meta->get_attribute('gloum')->is_lazy, + '... Bar::gloum is a required attr'); + +ok(!Foo->meta->get_attribute('foo')->should_coerce, '... Foo::foo should not coerce'); -ok(Bar->meta->get_attribute('foo')->should_coerce, - '... Bar::foo should coerce'); - -ok(!Foo->meta->get_attribute('bling')->has_handles, +ok(Bar->meta->get_attribute('foo')->should_coerce, + '... Bar::foo should coerce'); + +ok(!Foo->meta->get_attribute('bling')->has_handles, '... Foo::foo should not handles'); -ok(Bar->meta->get_attribute('bling')->has_handles, - '... Bar::foo should handles'); +ok(Bar->meta->get_attribute('bling')->has_handles, + '... Bar::foo should handles'); diff --git a/t/020_attributes/010_attribute_delegation.t b/t/020_attributes/010_attribute_delegation.t index a792dc9..45505a1 100644 --- a/t/020_attributes/010_attribute_delegation.t +++ b/t/020_attributes/010_attribute_delegation.t @@ -12,18 +12,18 @@ use Test::Exception; # HASH handles # ------------------------------------------------------------------- # the canonical form of of the 'handles' -# option is the hash ref mapping a +# option is the hash ref mapping a # method name to the delegated method name { package Foo; use Moose; - has 'bar' => (is => 'rw', default => 10); + has 'bar' => (is => 'rw', default => 10); package Bar; - use Moose; - + use Moose; + has 'foo' => ( is => 'rw', default => sub { Foo->new }, @@ -60,7 +60,7 @@ is($bar->foo_bar, 30, '... bar->foo_bar delegated correctly'); $bar->foo_bar(50); -# and make sure everyone sees it +# and make sure everyone sees it is($bar->foo->bar, 50, '... bar->foo->bar returned the right (changed) value'); is($bar->foo_bar, 50, '... bar->foo_bar delegated correctly'); @@ -82,10 +82,10 @@ is($bar->foo->bar, 25, '... bar->foo->bar returned the right result'); is($bar->foo_bar, 25, '... and bar->foo_bar delegated correctly again'); # ------------------------------------------------------------------- -# ARRAY handles +# ARRAY handles # ------------------------------------------------------------------- # we also support an array based format -# which assumes that the name is the same +# which assumes that the name is the same # on either end { @@ -93,11 +93,11 @@ is($bar->foo_bar, 25, '... and bar->foo_bar delegated correctly again'); use Moose; sub go { 'Engine::go' } - sub stop { 'Engine::stop' } + sub stop { 'Engine::stop' } package Car; - use Moose; - + use Moose; + has 'engine' => ( is => 'rw', default => sub { Engine->new }, @@ -122,7 +122,7 @@ is($car->go, 'Engine::go', '... got the right value from ->go'); is($car->stop, 'Engine::stop', '... got the right value from ->stop'); # ------------------------------------------------------------------- -# REGEXP handles +# REGEXP handles # ------------------------------------------------------------------- # and we support regexp delegation @@ -131,38 +131,38 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); use Moose; sub foo { 'Baz::foo' } - sub bar { 'Baz::bar' } - sub boo { 'Baz::boo' } + sub bar { 'Baz::bar' } + sub boo { 'Baz::boo' } package Baz::Proxy1; - use Moose; - + use Moose; + has 'baz' => ( is => 'ro', isa => 'Baz', default => sub { Baz->new }, handles => qr/.*/ ); - + package Baz::Proxy2; - use Moose; - + use Moose; + has 'baz' => ( is => 'ro', isa => 'Baz', default => sub { Baz->new }, handles => qr/.oo/ - ); - + ); + package Baz::Proxy3; - use Moose; - + use Moose; + has 'baz' => ( is => 'ro', isa => 'Baz', default => sub { Baz->new }, handles => qr/b.*/ - ); + ); } { @@ -175,10 +175,10 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); can_ok($baz_proxy, 'foo'); can_ok($baz_proxy, 'bar'); can_ok($baz_proxy, 'boo'); - + is($baz_proxy->foo, 'Baz::foo', '... got the right proxied return value'); is($baz_proxy->bar, 'Baz::bar', '... got the right proxied return value'); - is($baz_proxy->boo, 'Baz::boo', '... got the right proxied return value'); + is($baz_proxy->boo, 'Baz::boo', '... got the right proxied return value'); } { my $baz_proxy = Baz::Proxy2->new; @@ -189,9 +189,9 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); can_ok($baz_proxy, 'foo'); can_ok($baz_proxy, 'boo'); - + is($baz_proxy->foo, 'Baz::foo', '... got the right proxied return value'); - is($baz_proxy->boo, 'Baz::boo', '... got the right proxied return value'); + is($baz_proxy->boo, 'Baz::boo', '... got the right proxied return value'); } { my $baz_proxy = Baz::Proxy3->new; @@ -202,9 +202,9 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); can_ok($baz_proxy, 'bar'); can_ok($baz_proxy, 'boo'); - + is($baz_proxy->bar, 'Baz::bar', '... got the right proxied return value'); - is($baz_proxy->boo, 'Baz::boo', '... got the right proxied return value'); + is($baz_proxy->boo, 'Baz::boo', '... got the right proxied return value'); } # ------------------------------------------------------------------- @@ -214,22 +214,22 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); { package Foo::Bar; use Moose::Role; - + requires 'foo'; requires 'bar'; - + package Foo::Baz; use Moose; - + sub foo { 'Foo::Baz::FOO' } sub bar { 'Foo::Baz::BAR' } - sub baz { 'Foo::Baz::BAZ' } - + sub baz { 'Foo::Baz::BAZ' } + package Foo::Thing; use Moose; - + has 'thing' => ( - is => 'rw', + is => 'rw', isa => 'Foo::Baz', handles => 'Foo::Bar', ); @@ -240,14 +240,14 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); my $foo = Foo::Thing->new(thing => Foo::Baz->new); isa_ok($foo, 'Foo::Thing'); isa_ok($foo->thing, 'Foo::Baz'); - + ok($foo->meta->has_method('foo'), '... we have the method we expect'); ok($foo->meta->has_method('bar'), '... we have the method we expect'); - ok(!$foo->meta->has_method('baz'), '... we dont have the method we expect'); - - is($foo->foo, 'Foo::Baz::FOO', '... got the right value'); + ok(!$foo->meta->has_method('baz'), '... we dont have the method we expect'); + + is($foo->foo, 'Foo::Baz::FOO', '... got the right value'); is($foo->bar, 'Foo::Baz::BAR', '... got the right value'); - is($foo->thing->baz, 'Foo::Baz::BAZ', '... got the right value'); + is($foo->thing->baz, 'Foo::Baz::BAZ', '... got the right value'); } # ------------------------------------------------------------------- @@ -272,32 +272,32 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); } package Bar::Autoloaded; - use Moose; - + use Moose; + has 'foo' => ( is => 'rw', default => sub { Foo::Autoloaded->new }, handles => { 'foo_bar' => 'bar' } ); - + package Baz::Autoloaded; - use Moose; - + use Moose; + has 'foo' => ( is => 'rw', default => sub { Foo::Autoloaded->new }, handles => ['bar'] - ); - + ); + package Goorch::Autoloaded; - use Moose; - + use Moose; + ::dies_ok { has 'foo' => ( is => 'rw', default => sub { Foo::Autoloaded->new }, handles => qr/bar/ - ); + ); } '... you cannot delegate to AUTOLOADED class with regexp'; } @@ -323,7 +323,7 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); $bar->foo_bar(50); - # and make sure everyone sees it + # and make sure everyone sees it is($bar->foo->bar, 50, '... bar->foo->bar returned the right (changed) value'); is($bar->foo_bar, 50, '... bar->foo_bar delegated correctly'); @@ -334,7 +334,7 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); isa_ok($foo, 'Foo::Autoloaded'); $foo->bar(25); - + is($foo->bar, 25, '... got the right foo->bar'); lives_ok { @@ -369,7 +369,7 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); $baz->bar(50); - # and make sure everyone sees it + # and make sure everyone sees it is($baz->foo->bar, 50, '... baz->foo->bar returned the right (changed) value'); is($baz->bar, 50, '... baz->foo_bar delegated correctly'); @@ -380,7 +380,7 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); isa_ok($foo, 'Foo::Autoloaded'); $foo->bar(25); - + is($foo->bar, 25, '... got the right foo->bar'); lives_ok { @@ -398,8 +398,8 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); { package Quux; use Moose; - has foo => ( - isa => 'Foo', + has foo => ( + isa => 'Foo', default => sub { Foo->new }, handles => { 'foo_bar' => 'bar' } ); diff --git a/t/020_attributes/011_more_attr_delegation.t b/t/020_attributes/011_more_attr_delegation.t index 66942a7..99a3b40 100644 --- a/t/020_attributes/011_more_attr_delegation.t +++ b/t/020_attributes/011_more_attr_delegation.t @@ -8,8 +8,8 @@ use Test::Exception; =pod -This tests the more complex -delegation cases and that they +This tests the more complex +delegation cases and that they do not fail at compile time. =cut @@ -158,14 +158,14 @@ do not fail at compile time. } "subrefs on non moose class give no meta"; ::is( $delegate_class, "ChildF", "plain classes are handed down to subs" ); - + ::lives_ok { has child_g => ( isa => "ChildG", default => sub { ChildG->new }, handles => ["child_g_method_1"], ); - } "can delegate to object even without explicit reader"; + } "can delegate to object even without explicit reader"; sub parent_method { "p" } } diff --git a/t/020_attributes/012_misc_attribute_tests.t b/t/020_attributes/012_misc_attribute_tests.t index 52f6e14..ac3372b 100644 --- a/t/020_attributes/012_misc_attribute_tests.t +++ b/t/020_attributes/012_misc_attribute_tests.t @@ -140,7 +140,7 @@ use Test::Exception; throws_ok { $moose_obj->a_str( $moose_obj ) - } qr/Attribute \(a_str\) does not pass the type constraint because\: Validation failed for 'Str' failed with value OverloadedStr=HASH\(0x.+?\)/, + } qr/Attribute \(a_str\) does not pass the type constraint because\: Validation failed for 'Str' failed with value OverloadedStr=HASH\(0x.+?\)/, '... dies without overloading the string'; } @@ -155,7 +155,7 @@ use Test::Exception; throws_ok { OverloadBreaker->new; - } qr/Attribute \(a_num\) does not pass the type constraint because\: Validation failed for 'Int' failed with value 7\.5/, + } qr/Attribute \(a_num\) does not pass the type constraint because\: Validation failed for 'Int' failed with value 7\.5/, '... this doesnt trip overload to break anymore '; lives_ok { @@ -184,14 +184,14 @@ use Test::Exception; is($instance->foo, 'works', "foo builder works"); } -{ +{ { package Test::Builder::Attribute::Broken; use Moose; has 'foo' => ( required => 1, builder => 'build_foo', is => 'ro'); } - + dies_ok { Test::Builder::Attribute::Broken->new; } '... no builder, wtf'; diff --git a/t/020_attributes/013_attr_dereference_test.t b/t/020_attributes/013_attr_dereference_test.t index 11b75d7..faa8a15 100644 --- a/t/020_attributes/013_attr_dereference_test.t +++ b/t/020_attributes/013_attr_dereference_test.t @@ -19,7 +19,7 @@ use Test::Exception; ::lives_ok { has 'customers' => ( is => 'ro', - isa => subtype('ArrayRef' => where { + isa => subtype('ArrayRef' => where { (blessed($_) && $_->isa('Customer') || return) for @$_; 1 }), auto_deref => 1, ); @@ -68,13 +68,13 @@ use Test::Exception; { my $autoderef = AutoDeref->new; - + dies_ok { $autoderef->bar(1, 2, 3); } '... its auto-de-ref-ing, not auto-en-ref-ing'; - - lives_ok { - $autoderef->bar([ 1, 2, 3 ]) + + lives_ok { + $autoderef->bar([ 1, 2, 3 ]) } '... set the results of bar correctly'; is_deeply [ $autoderef->bar ], [ 1, 2, 3 ], '... auto-dereffed correctly'; diff --git a/t/020_attributes/014_misc_attribute_coerce_lazy.t b/t/020_attributes/014_misc_attribute_coerce_lazy.t index 4fe4ee4..5a47246 100644 --- a/t/020_attributes/014_misc_attribute_coerce_lazy.t +++ b/t/020_attributes/014_misc_attribute_coerce_lazy.t @@ -11,32 +11,32 @@ use Test::Exception; { package HTTPHeader; use Moose; - + has 'array' => (is => 'ro'); - has 'hash' => (is => 'ro'); + has 'hash' => (is => 'ro'); } { package Request; use Moose; use Moose::Util::TypeConstraints; - - subtype Header => - => as Object + + subtype Header => + => as Object => where { $_->isa('HTTPHeader') }; - coerce Header - => from ArrayRef + coerce Header + => from ArrayRef => via { HTTPHeader->new(array => $_[0]) } - => from HashRef - => via { HTTPHeader->new(hash => $_[0]) }; - + => from HashRef + => via { HTTPHeader->new(hash => $_[0]) }; + has 'headers' => ( is => 'rw', isa => 'Header', coerce => 1, lazy => 1, - default => sub { [ 'content-type', 'text/html' ] } + default => sub { [ 'content-type', 'text/html' ] } ); } diff --git a/t/020_attributes/015_attribute_traits.t b/t/020_attributes/015_attribute_traits.t index 189d212..fc40435 100644 --- a/t/020_attributes/015_attribute_traits.t +++ b/t/020_attributes/015_attribute_traits.t @@ -12,15 +12,15 @@ use Test::Moose; { package My::Attribute::Trait; use Moose::Role; - + has 'alias_to' => (is => 'ro', isa => 'Str'); has foo => ( is => "ro", default => "blah" ); - + after 'install_accessors' => sub { my $self = shift; $self->associated_class->add_method( - $self->alias_to, + $self->alias_to, $self->get_read_method_ref ); }; @@ -29,19 +29,19 @@ use Test::Moose; { package My::Class; use Moose; - + has 'bar' => ( traits => [qw/My::Attribute::Trait/], is => 'ro', isa => 'Int', alias_to => 'baz', ); - + has 'gorch' => ( is => 'ro', isa => 'Int', default => sub { 10 } - ); + ); } my $c = My::Class->new(bar => 100); diff --git a/t/020_attributes/017_attribute_traits_n_meta.t b/t/020_attributes/017_attribute_traits_n_meta.t index c4dc206..2aa1114 100644 --- a/t/020_attributes/017_attribute_traits_n_meta.t +++ b/t/020_attributes/017_attribute_traits_n_meta.t @@ -12,28 +12,28 @@ use Test::Moose; { package My::Meta::Attribute::DefaultReadOnly; use Moose; - + extends 'Moose::Meta::Attribute'; - + around 'new' => sub { my $next = shift; my ($self, $name, %options) = @_; - $options{is} = 'ro' + $options{is} = 'ro' unless exists $options{is}; $next->($self, $name, %options); - }; + }; } { package My::Attribute::Trait; use Moose::Role; - + has 'alias_to' => (is => 'ro', isa => 'Str'); - + after 'install_accessors' => sub { my $self = shift; $self->associated_class->add_method( - $self->alias_to, + $self->alias_to, $self->get_read_method_ref ); }; @@ -42,7 +42,7 @@ use Test::Moose; { package My::Class; use Moose; - + has 'bar' => ( metaclass => 'My::Meta::Attribute::DefaultReadOnly', traits => [qw/My::Attribute::Trait/], diff --git a/t/020_attributes/018_no_init_arg.t b/t/020_attributes/018_no_init_arg.t index f5ebf87..62f6e5a 100644 --- a/t/020_attributes/018_no_init_arg.t +++ b/t/020_attributes/018_no_init_arg.t @@ -11,7 +11,7 @@ use Test::Exception; { package Foo; use Moose; - + eval { has 'foo' => ( is => "rw", diff --git a/t/020_attributes/019_attribute_lazy_initializer.t b/t/020_attributes/019_attribute_lazy_initializer.t index 6735822..06f631f 100644 --- a/t/020_attributes/019_attribute_lazy_initializer.t +++ b/t/020_attributes/019_attribute_lazy_initializer.t @@ -11,16 +11,16 @@ use Test::Exception; { package Foo; use Moose; - + has 'foo' => ( reader => 'get_foo', writer => 'set_foo', initializer => sub { my ($self, $value, $callback, $attr) = @_; - + ::isa_ok($attr, 'Moose::Meta::Attribute'); ::is($attr->name, 'foo', '... got the right name'); - + $callback->($value * 2); }, ); @@ -31,14 +31,14 @@ use Test::Exception; default => 10, initializer => sub { my ($self, $value, $callback, $attr) = @_; - + ::isa_ok($attr, 'Moose::Meta::Attribute'); - ::is($attr->name, 'lazy_foo', '... got the right name'); - + ::is($attr->name, 'lazy_foo', '... got the right name'); + $callback->($value * 2); }, ); - + has 'lazy_foo_w_type' => ( reader => 'get_lazy_foo_w_type', isa => 'Int', @@ -46,43 +46,43 @@ use Test::Exception; default => 20, initializer => sub { my ($self, $value, $callback, $attr) = @_; - + ::isa_ok($attr, 'Moose::Meta::Attribute'); - ::is($attr->name, 'lazy_foo_w_type', '... got the right name'); - + ::is($attr->name, 'lazy_foo_w_type', '... got the right name'); + $callback->($value * 2); }, - ); - + ); + has 'lazy_foo_builder' => ( reader => 'get_lazy_foo_builder', builder => 'get_foo_builder', initializer => sub { my ($self, $value, $callback, $attr) = @_; - + ::isa_ok($attr, 'Moose::Meta::Attribute'); - ::is($attr->name, 'lazy_foo_builder', '... got the right name'); - + ::is($attr->name, 'lazy_foo_builder', '... got the right name'); + $callback->($value * 2); }, ); - + has 'lazy_foo_builder_w_type' => ( reader => 'get_lazy_foo_builder_w_type', - isa => 'Int', + isa => 'Int', builder => 'get_foo_builder_w_type', initializer => sub { my ($self, $value, $callback, $attr) = @_; - + ::isa_ok($attr, 'Moose::Meta::Attribute'); - ::is($attr->name, 'lazy_foo_builder_w_type', '... got the right name'); - + ::is($attr->name, 'lazy_foo_builder_w_type', '... got the right name'); + $callback->($value * 2); }, ); - - sub get_foo_builder { 100 } - sub get_foo_builder_w_type { 1000 } + + sub get_foo_builder { 100 } + sub get_foo_builder_w_type { 1000 } } { @@ -93,26 +93,26 @@ use Test::Exception; is($foo->get_lazy_foo, 20, 'initial lazy value set to 2x given value'); is($foo->get_lazy_foo_w_type, 40, 'initial lazy value with type set to 2x given value'); is($foo->get_lazy_foo_builder, 200, 'initial lazy value with builder set to 2x given value'); - is($foo->get_lazy_foo_builder_w_type, 2000, 'initial lazy value with builder and type set to 2x given value'); + is($foo->get_lazy_foo_builder_w_type, 2000, 'initial lazy value with builder and type set to 2x given value'); } { package Bar; use Moose; - + has 'foo' => ( reader => 'get_foo', writer => 'set_foo', initializer => sub { my ($self, $value, $callback, $attr) = @_; - + ::isa_ok($attr, 'Moose::Meta::Attribute'); ::is($attr->name, 'foo', '... got the right name'); - + $callback->($value * 2); }, - ); - + ); + __PACKAGE__->meta->make_immutable; } @@ -120,27 +120,27 @@ use Test::Exception; my $bar = Bar->new(foo => 10); isa_ok($bar, 'Bar'); - is($bar->get_foo, 20, 'initial value set to 2x given value'); + is($bar->get_foo, 20, 'initial value set to 2x given value'); } { package Fail::Bar; use Moose; - + has 'foo' => ( reader => 'get_foo', writer => 'set_foo', isa => 'Int', initializer => sub { my ($self, $value, $callback, $attr) = @_; - + ::isa_ok($attr, 'Moose::Meta::Attribute'); ::is($attr->name, 'foo', '... got the right name'); - + $callback->("Hello $value World"); }, - ); - + ); + __PACKAGE__->meta->make_immutable; } diff --git a/t/020_attributes/021_method_generation_rules.t b/t/020_attributes/021_method_generation_rules.t index d0fbe0b..5876190 100644 --- a/t/020_attributes/021_method_generation_rules.t +++ b/t/020_attributes/021_method_generation_rules.t @@ -37,7 +37,7 @@ can_ok($obj, qw/foo _foo/); lives_ok {$obj->_foo(1)} "$class->_foo is writer"; is($obj->foo(), 1, "$class->foo is reader"); dies_ok {$obj->foo(2)} "$class->foo is not writer"; # this should fail -ok(!defined $obj->_foo(), "$class->_foo is not reader"); +ok(!defined $obj->_foo(), "$class->_foo is not reader"); $class = make_class('ro', 'writer', 'Test::Class::WriterRO'); ok($class, "Can define attr with ro + writer"); diff --git a/t/020_attributes/025_chained_coercion.t b/t/020_attributes/025_chained_coercion.t index 108a174..3975200 100644 --- a/t/020_attributes/025_chained_coercion.t +++ b/t/020_attributes/025_chained_coercion.t @@ -10,32 +10,32 @@ use Test::Exception; package Baz; use Moose; use Moose::Util::TypeConstraints; - + coerce 'Baz' => from 'HashRef' => via { Baz->new($_) }; - + has 'hello' => ( is => 'ro', - isa => 'Str', + isa => 'Str', ); - + package Bar; use Moose; use Moose::Util::TypeConstraints; - + coerce 'Bar' => from 'HashRef' => via { Bar->new($_) }; - + has 'baz' => ( is => 'ro', - isa => 'Baz', + isa => 'Baz', coerce => 1 ); - + package Foo; use Moose; - + has 'bar' => ( is => 'ro', - isa => 'Bar', + isa => 'Bar', coerce => 1, ); } diff --git a/t/030_roles/001_meta_role.t b/t/030_roles/001_meta_role.t index f8b377b..a977ec3 100644 --- a/t/030_roles/001_meta_role.t +++ b/t/030_roles/001_meta_role.t @@ -10,9 +10,9 @@ use Moose::Meta::Role; { package FooRole; - + our $VERSION = '0.01'; - + sub foo { 'FooRole::foo' } } @@ -34,7 +34,7 @@ is_deeply( [ $foo_role->get_method_list() ], [ 'foo' ], '... got the right method list'); - + # attributes ... is_deeply( diff --git a/t/030_roles/002_role.t b/t/030_roles/002_role.t index b03027d..1bb4741 100644 --- a/t/030_roles/002_role.t +++ b/t/030_roles/002_role.t @@ -11,7 +11,7 @@ use Test::Exception; NOTE: Should we be testing here that the has & override -are injecting their methods correctly? In other +are injecting their methods correctly? In other words, should 'has_method' return true for them? =cut @@ -19,28 +19,28 @@ words, should 'has_method' return true for them? { package FooRole; use Moose::Role; - + our $VERSION = '0.01'; - + has 'bar' => (is => 'rw', isa => 'Foo'); - has 'baz' => (is => 'ro'); - + has 'baz' => (is => 'ro'); + sub foo { 'FooRole::foo' } - sub boo { 'FooRole::boo' } - + sub boo { 'FooRole::boo' } + before 'boo' => sub { "FooRole::boo:before" }; - - after 'boo' => sub { "FooRole::boo:after1" }; - after 'boo' => sub { "FooRole::boo:after2" }; - - around 'boo' => sub { "FooRole::boo:around" }; - - override 'bling' => sub { "FooRole::bling:override" }; - override 'fling' => sub { "FooRole::fling:override" }; - + + after 'boo' => sub { "FooRole::boo:after1" }; + after 'boo' => sub { "FooRole::boo:after2" }; + + around 'boo' => sub { "FooRole::boo:around" }; + + override 'bling' => sub { "FooRole::bling:override" }; + override 'fling' => sub { "FooRole::fling:override" }; + ::dies_ok { extends() } '... extends() is not supported'; - ::dies_ok { augment() } '... augment() is not supported'; - ::dies_ok { inner() } '... inner() is not supported'; + ::dies_ok { augment() } '... augment() is not supported'; + ::dies_ok { inner() } '... inner() is not supported'; no Moose::Role; } @@ -96,8 +96,8 @@ is_deeply( # method modifiers ok($foo_role->has_before_method_modifiers('boo'), '... now we have a boo:before modifier'); -is(($foo_role->get_before_method_modifiers('boo'))[0]->(), - "FooRole::boo:before", +is(($foo_role->get_before_method_modifiers('boo'))[0]->(), + "FooRole::boo:before", '... got the right method back'); is_deeply( @@ -106,21 +106,21 @@ is_deeply( '... got the right list of before method modifiers'); ok($foo_role->has_after_method_modifiers('boo'), '... now we have a boo:after modifier'); -is(($foo_role->get_after_method_modifiers('boo'))[0]->(), - "FooRole::boo:after1", +is(($foo_role->get_after_method_modifiers('boo'))[0]->(), + "FooRole::boo:after1", + '... got the right method back'); +is(($foo_role->get_after_method_modifiers('boo'))[1]->(), + "FooRole::boo:after2", '... got the right method back'); -is(($foo_role->get_after_method_modifiers('boo'))[1]->(), - "FooRole::boo:after2", - '... got the right method back'); is_deeply( [ $foo_role->get_method_modifier_list('after') ], [ 'boo' ], '... got the right list of after method modifiers'); - + ok($foo_role->has_around_method_modifiers('boo'), '... now we have a boo:around modifier'); -is(($foo_role->get_around_method_modifiers('boo'))[0]->(), - "FooRole::boo:around", +is(($foo_role->get_around_method_modifiers('boo'))[0]->(), + "FooRole::boo:around", '... got the right method back'); is_deeply( @@ -131,13 +131,13 @@ is_deeply( ## overrides ok($foo_role->has_override_method_modifier('bling'), '... now we have a bling:override modifier'); -is($foo_role->get_override_method_modifier('bling')->(), - "FooRole::bling:override", +is($foo_role->get_override_method_modifier('bling')->(), + "FooRole::bling:override", '... got the right method back'); ok($foo_role->has_override_method_modifier('fling'), '... now we have a fling:override modifier'); -is($foo_role->get_override_method_modifier('fling')->(), - "FooRole::fling:override", +is($foo_role->get_override_method_modifier('fling')->(), + "FooRole::fling:override", '... got the right method back'); is_deeply( diff --git a/t/030_roles/005_role_conflict_detection.t b/t/030_roles/005_role_conflict_detection.t index b99b90f..800bdda 100644 --- a/t/030_roles/005_role_conflict_detection.t +++ b/t/030_roles/005_role_conflict_detection.t @@ -17,31 +17,31 @@ Mutually recursive roles. use Moose::Role; requires 'foo'; - + sub bar { 'Role::Foo::bar' } - + package Role::Bar; use Moose::Role; - + requires 'bar'; - - sub foo { 'Role::Bar::foo' } + + sub foo { 'Role::Bar::foo' } } { package My::Test1; use Moose; - + ::lives_ok { with 'Role::Foo', 'Role::Bar'; } '... our mutually recursive roles combine okay'; - + package My::Test2; use Moose; - + ::lives_ok { with 'Role::Bar', 'Role::Foo'; - } '... our mutually recursive roles combine okay (no matter what order)'; + } '... our mutually recursive roles combine okay (no matter what order)'; } my $test1 = My::Test1->new; @@ -85,46 +85,46 @@ Role method conflicts { package Role::Bling; use Moose::Role; - + sub bling { 'Role::Bling::bling' } - + package Role::Bling::Bling; use Moose::Role; - - sub bling { 'Role::Bling::Bling::bling' } + + sub bling { 'Role::Bling::Bling::bling' } } { package My::Test3; use Moose; - + ::throws_ok { with 'Role::Bling', 'Role::Bling::Bling'; } qr/requires the method \'bling\' to be implemented/, '... role methods conflicted and method was required'; - + package My::Test4; use Moose; - + ::lives_ok { with 'Role::Bling'; with 'Role::Bling::Bling'; - } '... role methods didnt conflict when manually combined'; - + } '... role methods didnt conflict when manually combined'; + package My::Test5; use Moose; - + ::lives_ok { with 'Role::Bling::Bling'; with 'Role::Bling'; - } '... role methods didnt conflict when manually combined (in opposite order)'; - + } '... role methods didnt conflict when manually combined (in opposite order)'; + package My::Test6; use Moose; - + ::lives_ok { with 'Role::Bling::Bling', 'Role::Bling'; - } '... role methods didnt conflict when manually resolved'; - + } '... role methods didnt conflict when manually resolved'; + sub bling { 'My::Test6::bling' } } @@ -151,16 +151,16 @@ is(My::Test6->bling, 'My::Test6::bling', '... and we got the local method'); { package Role::Bling::Bling::Bling; use Moose::Role; - + with 'Role::Bling::Bling'; - - sub bling { 'Role::Bling::Bling::Bling::bling' } + + sub bling { 'Role::Bling::Bling::Bling::bling' } } ok(Role::Bling::Bling->meta->has_method('bling'), '... still got the bling method in Role::Bling::Bling'); ok(Role::Bling::Bling->meta->does_role('Role::Bling::Bling'), '... our role correctly does() the other role'); ok(Role::Bling::Bling::Bling->meta->has_method('bling'), '... dont have the bling method in Role::Bling::Bling::Bling'); -is(Role::Bling::Bling::Bling->meta->get_method('bling')->(), +is(Role::Bling::Bling::Bling->meta->get_method('bling')->(), 'Role::Bling::Bling::Bling::bling', '... still got the bling method in Role::Bling::Bling::Bling'); @@ -174,22 +174,22 @@ Role attribute conflicts { package Role::Boo; use Moose::Role; - + has 'ghost' => (is => 'ro', default => 'Role::Boo::ghost'); - + package Role::Boo::Hoo; use Moose::Role; - + has 'ghost' => (is => 'ro', default => 'Role::Boo::Hoo::ghost'); } { package My::Test7; use Moose; - + ::throws_ok { with 'Role::Boo', 'Role::Boo::Hoo'; - } qr/We have encountered an attribute conflict/, + } qr/We have encountered an attribute conflict/, '... role attrs conflicted and method was required'; package My::Test8; @@ -199,24 +199,24 @@ Role attribute conflicts with 'Role::Boo'; with 'Role::Boo::Hoo'; } '... role attrs didnt conflict when manually combined'; - + package My::Test9; use Moose; ::lives_ok { with 'Role::Boo::Hoo'; with 'Role::Boo'; - } '... role attrs didnt conflict when manually combined'; + } '... role attrs didnt conflict when manually combined'; package My::Test10; use Moose; - - has 'ghost' => (is => 'ro', default => 'My::Test10::ghost'); - + + has 'ghost' => (is => 'ro', default => 'My::Test10::ghost'); + ::throws_ok { with 'Role::Boo', 'Role::Boo::Hoo'; - } qr/We have encountered an attribute conflict/, - '... role attrs conflicted and cannot be manually disambiguted'; + } qr/We have encountered an attribute conflict/, + '... role attrs conflicted and cannot be manually disambiguted'; } @@ -251,14 +251,14 @@ Role override method conflicts { package Role::Plot; use Moose::Role; - + override 'twist' => sub { super() . ' -> Role::Plot::twist'; }; - + package Role::Truth; use Moose::Role; - + override 'twist' => sub { super() . ' -> Role::Truth::twist'; }; @@ -267,43 +267,43 @@ Role override method conflicts { package My::Test::Base; use Moose; - + sub twist { 'My::Test::Base::twist' } - + package My::Test11; use Moose; - + extends 'My::Test::Base'; ::lives_ok { with 'Role::Truth'; } '... composed the role with override okay'; - + package My::Test12; use Moose; extends 'My::Test::Base'; - ::lives_ok { + ::lives_ok { with 'Role::Plot'; } '... composed the role with override okay'; - + package My::Test13; use Moose; ::dies_ok { - with 'Role::Plot'; + with 'Role::Plot'; } '... cannot compose it because we have no superclass'; - + package My::Test14; use Moose; extends 'My::Test::Base'; ::throws_ok { - with 'Role::Plot', 'Role::Truth'; - } qr/Two \'override\' methods of the same name encountered/, - '... cannot compose it because we have no superclass'; + with 'Role::Plot', 'Role::Truth'; + } qr/Two \'override\' methods of the same name encountered/, + '... cannot compose it because we have no superclass'; } ok(My::Test11->meta->has_method('twist'), '... the twist method has been added'); @@ -328,20 +328,20 @@ is(My::Test14->twist(), 'My::Test::Base::twist', '... got the right method retur package Role::Reality; use Moose::Role; - ::throws_ok { + ::throws_ok { with 'Role::Plot'; - } qr/A local method of the same name as been found/, + } qr/A local method of the same name as been found/, '... could not compose roles here, it dies'; sub twist { 'Role::Reality::twist'; } -} +} ok(Role::Reality->meta->has_method('twist'), '... the twist method has not been added'); #ok(!Role::Reality->meta->does_role('Role::Plot'), '... our role does() the correct roles'); -is(Role::Reality->meta->get_method('twist')->(), - 'Role::Reality::twist', +is(Role::Reality->meta->get_method('twist')->(), + 'Role::Reality::twist', '... the twist method returns the right value'); =pod @@ -373,22 +373,22 @@ Now I have to decide actually what happens, and how to fix it. { package Role::Method; use Moose::Role; - + sub ghost { 'Role::Method::ghost' } package Role::Method2; use Moose::Role; - + sub ghost { 'Role::Method2::ghost' } package Role::Attribute; use Moose::Role; - + has 'ghost' => (is => 'ro', default => 'Role::Attribute::ghost'); package Role::Attribute2; use Moose::Role; - + has 'ghost' => (is => 'ro', default => 'Role::Attribute2::ghost'); } @@ -396,7 +396,7 @@ Now I have to decide actually what happens, and how to fix it. package My::Test15; use Moose; - ::lives_ok { + ::lives_ok { with 'Role::Method'; } '... composed the method role into the method class'; diff --git a/t/030_roles/006_role_exclusion.t b/t/030_roles/006_role_exclusion.t index 041e013..762cefd 100644 --- a/t/030_roles/006_role_exclusion.t +++ b/t/030_roles/006_role_exclusion.t @@ -13,10 +13,10 @@ from the Fortress spec. http://research.sun.com/projects/plrg/fortress0903.pdf -trait OrganicMolecule extends Molecule - excludes { InorganicMolecule } -end -trait InorganicMolecule extends Molecule end +trait OrganicMolecule extends Molecule + excludes { InorganicMolecule } +end +trait InorganicMolecule extends Molecule end =cut @@ -26,25 +26,25 @@ trait InorganicMolecule extends Molecule end package Molecule::Organic; use Moose::Role; - + with 'Molecule'; excludes 'Molecule::Inorganic'; - + package Molecule::Inorganic; - use Moose::Role; - - with 'Molecule'; + use Moose::Role; + + with 'Molecule'; } ok(Molecule::Organic->meta->excludes_role('Molecule::Inorganic'), '... Molecule::Organic exludes Molecule::Inorganic'); is_deeply( - [ Molecule::Organic->meta->get_excluded_roles_list() ], + [ Molecule::Organic->meta->get_excluded_roles_list() ], [ 'Molecule::Inorganic' ], '... Molecule::Organic exludes Molecule::Inorganic'); =pod -Check some basic conflicts when combining +Check some basic conflicts when combining the roles into the same class =cut @@ -52,30 +52,30 @@ the roles into the same class { package My::Test1; use Moose; - + ::lives_ok { with 'Molecule::Organic'; } '... adding the role (w/ excluded roles) okay'; package My::Test2; use Moose; - + ::throws_ok { with 'Molecule::Organic', 'Molecule::Inorganic'; - } qr/Conflict detected: Role Molecule::Organic excludes role 'Molecule::Inorganic'/, - '... adding the role w/ excluded role conflict dies okay'; - + } qr/Conflict detected: Role Molecule::Organic excludes role 'Molecule::Inorganic'/, + '... adding the role w/ excluded role conflict dies okay'; + package My::Test3; use Moose; - + ::lives_ok { with 'Molecule::Organic'; - } '... adding the role (w/ excluded roles) okay'; - + } '... adding the role (w/ excluded roles) okay'; + ::throws_ok { with 'Molecule::Inorganic'; - } qr/Conflict detected: My::Test3 excludes role 'Molecule::Inorganic'/, - '... adding the role w/ excluded role conflict dies okay'; + } qr/Conflict detected: My::Test3 excludes role 'Molecule::Inorganic'/, + '... adding the role w/ excluded role conflict dies okay'; } ok(My::Test1->does('Molecule::Organic'), '... My::Test1 does Molecule::Organic'); @@ -92,7 +92,7 @@ ok(!My::Test3->does('Molecule::Inorganic'), '... ! My::Test3 does Molecule::Inor =pod -Check some basic conflicts when combining +Check some basic conflicts when combining the roles into the a superclass =cut @@ -100,16 +100,16 @@ the roles into the a superclass { package Methane; use Moose; - + with 'Molecule::Organic'; - + package My::Test4; use Moose; - - extends 'Methane'; - + + extends 'Methane'; + ::throws_ok { - with 'Molecule::Inorganic'; + with 'Molecule::Inorganic'; } qr/Conflict detected: My::Test4 excludes role \'Molecule::Inorganic\'/, '... cannot add exculded role into class which extends Methane'; } diff --git a/t/030_roles/007_roles_and_req_method_edge_cases.t b/t/030_roles/007_roles_and_req_method_edge_cases.t index df24b95..b99348b 100644 --- a/t/030_roles/007_roles_and_req_method_edge_cases.t +++ b/t/030_roles/007_roles_and_req_method_edge_cases.t @@ -9,15 +9,15 @@ use Test::Exception; =pod NOTE: -A fair amount of these tests will likely be irrelevant +A fair amount of these tests will likely be irrelevant once we have more fine grained control over the class building process. A lot of the edge cases tested here -are actually related to class construction order and +are actually related to class construction order and not any real functionality. - SL -Role which requires a method implemented -in another role as an override (it does +Role which requires a method implemented +in another role as an override (it does not remove the requirement) =cut @@ -27,31 +27,31 @@ not remove the requirement) use strict; use warnings; use Moose::Role; - + requires 'foo'; - + package Role::ProvideFoo; use strict; use warnings; use Moose::Role; - + ::lives_ok { with 'Role::RequireFoo'; } '... the required "foo" method will not exist yet (but we will live)'; - - override 'foo' => sub { 'Role::ProvideFoo::foo' }; + + override 'foo' => sub { 'Role::ProvideFoo::foo' }; } is_deeply( - [ Role::ProvideFoo->meta->get_required_method_list ], - [ 'foo' ], + [ Role::ProvideFoo->meta->get_required_method_list ], + [ 'foo' ], '... foo method is still required for Role::ProvideFoo'); =pod -Role which requires a method implemented -in the consuming class as an override. -It will fail since method modifiers are +Role which requires a method implemented +in the consuming class as an override. +It will fail since method modifiers are second class citizens. =cut @@ -61,25 +61,25 @@ second class citizens. use Moose; sub foo { 'Class::ProvideFoo::Base::foo' } - + package Class::ProvideFoo::Override1; use Moose; - + extends 'Class::ProvideFoo::Base'; - + ::lives_ok { with 'Role::RequireFoo'; } '... the required "foo" method will be found in the superclass'; - - override 'foo' => sub { 'Class::ProvideFoo::foo' }; - + + override 'foo' => sub { 'Class::ProvideFoo::foo' }; + package Class::ProvideFoo::Override2; use Moose; - + extends 'Class::ProvideFoo::Base'; - - override 'foo' => sub { 'Class::ProvideFoo::foo' }; - + + override 'foo' => sub { 'Class::ProvideFoo::foo' }; + ::lives_ok { with 'Role::RequireFoo'; } '... the required "foo" method exists, although it is overriden locally'; @@ -88,7 +88,7 @@ second class citizens. =pod -Now same thing, but with a before +Now same thing, but with a before method modifier. =cut @@ -96,55 +96,55 @@ method modifier. { package Class::ProvideFoo::Before1; use Moose; - + extends 'Class::ProvideFoo::Base'; - + ::lives_ok { with 'Role::RequireFoo'; } '... the required "foo" method will be found in the superclass'; - - before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; - + + before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; + package Class::ProvideFoo::Before2; use Moose; - + extends 'Class::ProvideFoo::Base'; - - before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; - + + before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; + ::lives_ok { with 'Role::RequireFoo'; - } '... the required "foo" method exists, although it is a before modifier locally'; - + } '... the required "foo" method exists, although it is a before modifier locally'; + package Class::ProvideFoo::Before3; use Moose; - + extends 'Class::ProvideFoo::Base'; - + sub foo { 'Class::ProvideFoo::foo' } - before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; - + before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; + ::lives_ok { with 'Role::RequireFoo'; - } '... the required "foo" method exists locally, and it is modified locally'; - + } '... the required "foo" method exists locally, and it is modified locally'; + package Class::ProvideFoo::Before4; use Moose; - + extends 'Class::ProvideFoo::Base'; - - sub foo { 'Class::ProvideFoo::foo' } - before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; + + sub foo { 'Class::ProvideFoo::foo' } + before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; ::isa_ok(__PACKAGE__->meta->get_method('foo'), 'Class::MOP::Method::Wrapped'); - ::is(__PACKAGE__->meta->get_method('foo')->get_original_method->package_name, __PACKAGE__, + ::is(__PACKAGE__->meta->get_method('foo')->get_original_method->package_name, __PACKAGE__, '... but the original method is from our package'); - + ::lives_ok { with 'Role::RequireFoo'; - } '... the required "foo" method exists in the symbol table (and we will live)'; - -} + } '... the required "foo" method exists in the symbol table (and we will live)'; + +} =pod @@ -154,63 +154,63 @@ method modifier. =cut { - + package Class::ProvideFoo::Attr1; use Moose; - + extends 'Class::ProvideFoo::Base'; - + ::lives_ok { with 'Role::RequireFoo'; } '... the required "foo" method will be found in the superclass (but then overriden)'; - + has 'foo' => (is => 'ro'); - + package Class::ProvideFoo::Attr2; use Moose; - + extends 'Class::ProvideFoo::Base'; - - has 'foo' => (is => 'ro'); - + + has 'foo' => (is => 'ro'); + ::lives_ok { with 'Role::RequireFoo'; } '... the required "foo" method exists, and is an accessor'; -} +} # ... -# a method required in a role, but then -# implemented in the superclass (as an +# a method required in a role, but then +# implemented in the superclass (as an # attribute accessor too) - + { package Foo::Class::Base; use Moose; - - has 'bar' => ( - isa => 'Int', - is => 'rw', + + has 'bar' => ( + isa => 'Int', + is => 'rw', default => sub { 1 } ); } { package Foo::Role; use Moose::Role; - + requires 'bar'; - - has 'foo' => ( - isa => 'Int', - is => 'rw', - lazy => 1, - default => sub { (shift)->bar + 1 } + + has 'foo' => ( + isa => 'Int', + is => 'rw', + lazy => 1, + default => sub { (shift)->bar + 1 } ); } { package Foo::Class::Child; use Moose; extends 'Foo::Class::Base'; - + ::lives_ok { with 'Foo::Role'; } '... our role combined successfully'; diff --git a/t/030_roles/008_role_conflict_edge_cases.t b/t/030_roles/008_role_conflict_edge_cases.t index 46dcbcb..22cc706 100644 --- a/t/030_roles/008_role_conflict_edge_cases.t +++ b/t/030_roles/008_role_conflict_edge_cases.t @@ -8,8 +8,8 @@ use Test::Exception; =pod -Check for repeated inheritance causing -a method conflict (which is not really +Check for repeated inheritance causing +a method conflict (which is not really a conflict) =cut @@ -17,24 +17,24 @@ a conflict) { package Role::Base; use Moose::Role; - + sub foo { 'Role::Base::foo' } - + package Role::Derived1; - use Moose::Role; - + use Moose::Role; + with 'Role::Base'; - + package Role::Derived2; - use Moose::Role; + use Moose::Role; with 'Role::Base'; - + package My::Test::Class1; - use Moose; - + use Moose; + ::lives_ok { - with 'Role::Derived1', 'Role::Derived2'; + with 'Role::Derived1', 'Role::Derived2'; } '... roles composed okay (no conflicts)'; } @@ -47,8 +47,8 @@ is(My::Test::Class1->foo, 'Role::Base::foo', '... got the right value from metho =pod -Check for repeated inheritance causing -a method conflict with method modifiers +Check for repeated inheritance causing +a method conflict with method modifiers (which is not really a conflict) =cut @@ -56,31 +56,31 @@ a method conflict with method modifiers { package Role::Base2; use Moose::Role; - + override 'foo' => sub { super() . ' -> Role::Base::foo' }; - + package Role::Derived3; - use Moose::Role; - + use Moose::Role; + with 'Role::Base2'; - + package Role::Derived4; - use Moose::Role; + use Moose::Role; with 'Role::Base2'; package My::Test::Class2::Base; use Moose; - + sub foo { 'My::Test::Class2::Base' } - + package My::Test::Class2; - use Moose; - - extends 'My::Test::Class2::Base'; - + use Moose; + + extends 'My::Test::Class2::Base'; + ::lives_ok { - with 'Role::Derived3', 'Role::Derived4'; + with 'Role::Derived3', 'Role::Derived4'; } '... roles composed okay (no conflicts)'; } @@ -97,11 +97,11 @@ is(My::Test::Class2->foo, 'My::Test::Class2::Base -> Role::Base::foo', '... got =pod -Check for repeated inheritance of the -same code. There are no conflicts with +Check for repeated inheritance of the +same code. There are no conflicts with before/around/after method modifiers. -This tests around, but should work the +This tests around, but should work the same for before/afters as well =cut @@ -109,31 +109,31 @@ same for before/afters as well { package Role::Base3; use Moose::Role; - + around 'foo' => sub { 'Role::Base::foo(' . (shift)->() . ')' }; - + package Role::Derived5; - use Moose::Role; - + use Moose::Role; + with 'Role::Base3'; - + package Role::Derived6; - use Moose::Role; + use Moose::Role; with 'Role::Base3'; package My::Test::Class3::Base; use Moose; - + sub foo { 'My::Test::Class3::Base' } - + package My::Test::Class3; - use Moose; - - extends 'My::Test::Class3::Base'; - + use Moose; + + extends 'My::Test::Class3::Base'; + ::lives_ok { - with 'Role::Derived5', 'Role::Derived6'; + with 'Role::Derived5', 'Role::Derived6'; } '... roles composed okay (no conflicts)'; } @@ -150,8 +150,8 @@ is(My::Test::Class3->foo, 'Role::Base::foo(My::Test::Class3::Base)', '... got th =pod -Check for repeated inheritance causing -a attr conflict (which is not really +Check for repeated inheritance causing +a attr conflict (which is not really a conflict) =cut @@ -159,24 +159,24 @@ a conflict) { package Role::Base4; use Moose::Role; - + has 'foo' => (is => 'ro', default => 'Role::Base::foo'); - + package Role::Derived7; - use Moose::Role; - + use Moose::Role; + with 'Role::Base4'; - + package Role::Derived8; - use Moose::Role; + use Moose::Role; with 'Role::Base4'; - + package My::Test::Class4; - use Moose; - + use Moose; + ::lives_ok { - with 'Role::Derived7', 'Role::Derived8'; + with 'Role::Derived7', 'Role::Derived8'; } '... roles composed okay (no conflicts)'; } diff --git a/t/030_roles/009_more_role_edge_cases.t b/t/030_roles/009_more_role_edge_cases.t index 0fec31c..e9923f0 100644 --- a/t/030_roles/009_more_role_edge_cases.t +++ b/t/030_roles/009_more_role_edge_cases.t @@ -10,11 +10,11 @@ use Test::Exception; { # NOTE: - # this tests that repeated role - # composition will not cause + # this tests that repeated role + # composition will not cause # a conflict between two methods # which are actually the same anyway - + { package RootA; use Moose::Role; @@ -31,8 +31,8 @@ use Test::Exception; package SubAB; use Moose; - ::lives_ok { - with "SubAA", "RootA"; + ::lives_ok { + with "SubAA", "RootA"; } '... role was composed as expected'; } @@ -46,31 +46,31 @@ use Test::Exception; can_ok( $i, "foo" ); my $foo_rv; - lives_ok { - $foo_rv = $i->foo; + lives_ok { + $foo_rv = $i->foo; } '... called foo successfully'; is($foo_rv, "RootA::foo", "... got the right foo rv"); } { # NOTE: - # this edge cases shows the application of - # an after modifier over a method which + # this edge cases shows the application of + # an after modifier over a method which # was added during role composotion. # The way this will work is as follows: - # role SubBA will consume RootB and - # get a local copy of RootB::foo, it + # role SubBA will consume RootB and + # get a local copy of RootB::foo, it # will also store a deferred after modifier - # to be applied to whatever class SubBA is + # to be applied to whatever class SubBA is # composed into. # When class SubBB comsumed role SubBA, the - # RootB::foo method is added to SubBB, then - # the deferred after modifier from SubBA is + # RootB::foo method is added to SubBB, then + # the deferred after modifier from SubBA is # applied to it. - # It is important to note that the application - # of the after modifier does not happen until + # It is important to note that the application + # of the after modifier does not happen until # role SubBA is composed into SubAA. - + { package RootB; use Moose::Role; @@ -95,7 +95,7 @@ use Test::Exception; package SubBB; use Moose; - ::lives_ok { + ::lives_ok { with "SubBA"; } '... composed the role successfully'; } @@ -106,21 +106,21 @@ use Test::Exception; isa_ok( my $i = SubBB->new, "SubBB" ); can_ok( $i, "foo" ); - + my $foo_rv; - lives_ok { - $foo_rv = $i->foo + lives_ok { + $foo_rv = $i->foo } '... called foo successfully'; is( $foo_rv, "RootB::foo", "foo rv" ); is( $i->counter, 1, "after hook called" ); - + lives_ok { $i->foo } '... called foo successfully (again)'; is( $i->counter, 2, "after hook called (again)" ); - + ok(SubBA->meta->has_method('foo'), '... this has the foo method'); #my $subba_foo_rv; - #lives_ok { - # $subba_foo_rv = SubBA::foo(); + #lives_ok { + # $subba_foo_rv = SubBA::foo(); #} '... called the sub as a function correctly'; #is($subba_foo_rv, 'RootB::foo', '... the SubBA->foo is still the RootB version'); } @@ -129,9 +129,9 @@ use Test::Exception; # NOTE: # this checks that an override method # does not try to trample over a locally - # composed in method. In this case the - # RootC::foo, which is composed into - # SubCA cannot be trampled with an + # composed in method. In this case the + # RootC::foo, which is composed into + # SubCA cannot be trampled with an # override of 'foo' { package RootC; @@ -144,15 +144,15 @@ use Test::Exception; with "RootC"; - ::dies_ok { + ::dies_ok { override foo => sub { "overridden" }; } '... cannot compose an override over a local method'; } } # NOTE: -# need to talk to Yuval about the motivation behind -# this test, I am not sure we are testing anything +# need to talk to Yuval about the motivation behind +# this test, I am not sure we are testing anything # useful here (although more tests cant hurt) { @@ -184,10 +184,10 @@ use Test::Exception; with "ConcreteA"; # NOTE: - # this was originally override, but + # this was originally override, but # that wont work (see above set of tests) # so I switched it to around. - # However, this may not be testing the + # However, this may not be testing the # same thing that was originally intended around other => sub { return ( (shift)->() . " + c" ); @@ -218,12 +218,12 @@ use Test::Exception; is( eval { $class->another }, "abstract", "provided by abstract" ); is( eval { $class->other }, "concrete a", "provided by concrete a" ); is( eval { $class->method }, "concrete b", "provided by concrete b" ); - } + } { package ClassWithSome; use Moose; - + eval { with ::shuffle qw/ConcreteC ConcreteB/ }; ::ok( !$@, "composition without abstract" ) || ::diag $@; diff --git a/t/030_roles/010_run_time_role_composition.t b/t/030_roles/010_run_time_role_composition.t index 1a86a18..08354c5 100644 --- a/t/030_roles/010_run_time_role_composition.t +++ b/t/030_roles/010_run_time_role_composition.t @@ -12,7 +12,7 @@ use Scalar::Util qw(blessed); =pod This test can be used as a basis for the runtime role composition. -Apparently it is not as simple as just making an anon class. One of +Apparently it is not as simple as just making an anon class. One of the problems is the way that anon classes are DESTROY-ed, which is not very compatible with how instances are dealt with. @@ -37,35 +37,35 @@ not very compatible with how instances are dealt with. } my $obj = My::Class->new; -isa_ok($obj, 'My::Class'); - +isa_ok($obj, 'My::Class'); + my $obj2 = My::Class->new; -isa_ok($obj2, 'My::Class'); +isa_ok($obj2, 'My::Class'); { ok(!$obj->can( 'talk' ), "... the role is not composed yet"); - + ok(!$obj->does('Bark'), '... we do not do any roles yet'); - + Bark->meta->apply($obj); ok($obj->does('Bark'), '... we now do the Bark role'); - ok(!My::Class->does('Bark'), '... the class does not do the Bark role'); + ok(!My::Class->does('Bark'), '... the class does not do the Bark role'); isa_ok($obj, 'My::Class'); isnt(blessed($obj), 'My::Class', '... but it is no longer blessed into My::Class'); ok(!My::Class->can('talk'), "... the role is not composed at the class level"); ok($obj->can('talk'), "... the role is now composed at the object level"); - + is($obj->talk, 'woof', '... got the right return value for the newly composed method'); } { ok(!$obj2->does('Bark'), '... we do not do any roles yet'); - + Bark->meta->apply($obj2); - + ok($obj2->does('Bark'), '... we now do the Bark role'); is(blessed($obj), blessed($obj2), '... they share the same anon-class/role thing'); } @@ -78,25 +78,25 @@ isa_ok($obj2, 'My::Class'); Sleeper->meta->apply($obj); ok($obj->does('Bark'), '... we still do the Bark role'); - ok($obj->does('Sleeper'), '... we now do the Sleeper role too'); - - ok(!My::Class->does('Sleeper'), '... the class does not do the Sleeper role'); - - isnt(blessed($obj), blessed($obj2), '... they no longer share the same anon-class/role thing'); - + ok($obj->does('Sleeper'), '... we now do the Sleeper role too'); + + ok(!My::Class->does('Sleeper'), '... the class does not do the Sleeper role'); + + isnt(blessed($obj), blessed($obj2), '... they no longer share the same anon-class/role thing'); + isa_ok($obj, 'My::Class'); is(My::Class->sleep, 'nite-nite', '... the original method still responds as expected'); is($obj->sleep, 'snore', '... got the right return value for the newly composed method'); - is($obj->talk, 'zzz', '... got the right return value for the newly composed method'); + is($obj->talk, 'zzz', '... got the right return value for the newly composed method'); } { ok(!$obj2->does('Sleeper'), '... we do not do any roles yet'); - + Sleeper->meta->apply($obj2); - + ok($obj2->does('Sleeper'), '... we now do the Bark role'); is(blessed($obj), blessed($obj2), '... they share the same anon-class/role thing again'); } diff --git a/t/030_roles/011_overriding.t b/t/030_roles/011_overriding.t index 75afe7a..7dd2dac 100644 --- a/t/030_roles/011_overriding.t +++ b/t/030_roles/011_overriding.t @@ -8,7 +8,7 @@ use Test::Exception; -{ +{ # test no conflicts here package Role::A; use Moose::Role; @@ -22,7 +22,7 @@ use Test::Exception; package Role::C; use Moose::Role; - + ::lives_ok { with qw(Role::A Role::B); # no conflict here } "define role C"; @@ -36,7 +36,7 @@ use Test::Exception; ::lives_ok { with qw(Role::C); } "define class A"; - + sub zot { 'Class::A::zot' } } @@ -50,29 +50,29 @@ is( Class::A->new->xxy, "Role::B::xxy", "... got the right xxy method" ); { # check that when a role is added to another role # and they conflict and the method they conflicted - # with is then required. - + # with is then required. + package Role::A::Conflict; use Moose::Role; - + with 'Role::A'; - + sub bar { 'Role::A::Conflict::bar' } - + package Class::A::Conflict; use Moose; - + ::throws_ok { with 'Role::A::Conflict'; } qr/requires.*'bar'/, '... did not fufill the requirement of &bar method'; - + package Class::A::Resolved; use Moose; - + ::lives_ok { with 'Role::A::Conflict'; - } '... did fufill the requirement of &bar method'; - + } '... did fufill the requirement of &bar method'; + sub bar { 'Class::A::Resolved::bar' } } @@ -85,12 +85,12 @@ is( Class::A::Resolved->new->bar, 'Class::A::Resolved::bar', "... got the right { # check that when two roles are composed, they conflict # but the composing role can resolve that conflict - + package Role::D; use Moose::Role; sub foo { 'Role::D::foo' } - sub bar { 'Role::D::bar' } + sub bar { 'Role::D::bar' } package Role::E; use Moose::Role; @@ -104,17 +104,17 @@ is( Class::A::Resolved->new->bar, 'Class::A::Resolved::bar', "... got the right ::lives_ok { with qw(Role::D Role::E); # conflict between 'foo's here } "define role Role::F"; - + sub foo { 'Role::F::foo' } - sub zot { 'Role::F::zot' } - + sub zot { 'Role::F::zot' } + package Class::B; use Moose; - + ::lives_ok { with qw(Role::F); } "define class Class::B"; - + sub zot { 'Class::B::zot' } } @@ -129,21 +129,21 @@ ok(!Role::F->meta->requires_method('foo'), '... Role::F fufilled the &foo requir { # check that a conflict can be resolved - # by a role, but also new ones can be + # by a role, but also new ones can be # created just as easily ... - + package Role::D::And::E::Conflict; use Moose::Role; ::lives_ok { with qw(Role::D Role::E); # conflict between 'foo's here } "... define role Role::D::And::E::Conflict"; - + sub foo { 'Role::D::And::E::Conflict::foo' } # this overrides ... - - # but these conflict - sub xxy { 'Role::D::And::E::Conflict::xxy' } - sub bar { 'Role::D::And::E::Conflict::bar' } + + # but these conflict + sub xxy { 'Role::D::And::E::Conflict::xxy' } + sub bar { 'Role::D::And::E::Conflict::bar' } } @@ -153,12 +153,12 @@ ok(Role::D::And::E::Conflict->meta->requires_method('bar'), '... Role::D::And::E { # conflict propagation - + package Role::H; use Moose::Role; sub foo { 'Role::H::foo' } - sub bar { 'Role::H::bar' } + sub bar { 'Role::H::bar' } package Role::J; use Moose::Role; @@ -172,13 +172,13 @@ ok(Role::D::And::E::Conflict->meta->requires_method('bar'), '... Role::D::And::E ::lives_ok { with qw(Role::J Role::H); # conflict between 'foo's here } "define role Role::I"; - + sub zot { 'Role::I::zot' } sub zzy { 'Role::I::zzy' } package Class::C; use Moose; - + ::throws_ok { with qw(Role::I); } qr/requires.*'foo'/, "defining class Class::C fails"; @@ -190,10 +190,10 @@ ok(Role::D::And::E::Conflict->meta->requires_method('bar'), '... Role::D::And::E ::lives_ok { with qw(Role::I); - } "resolved with method"; + } "resolved with method"; sub foo { 'Class::E::foo' } - sub zot { 'Class::E::zot' } + sub zot { 'Class::E::zot' } } can_ok( Class::E->new, qw(foo bar xxy zot) ); diff --git a/t/030_roles/012_method_exclusion_in_composition.t b/t/030_roles/012_method_exclusion_in_composition.t index b3128b3..683dedd 100644 --- a/t/030_roles/012_method_exclusion_in_composition.t +++ b/t/030_roles/012_method_exclusion_in_composition.t @@ -43,37 +43,37 @@ ok(My::OtherRole->meta->requires_method('bar'), '... and the &bar method is requ { package Foo::Role; use Moose::Role; - + sub foo { 'Foo::Role::foo' } - + package Bar::Role; use Moose::Role; - - sub foo { 'Bar::Role::foo' } + + sub foo { 'Bar::Role::foo' } package Baz::Role; use Moose::Role; - - sub foo { 'Baz::Role::foo' } - + + sub foo { 'Baz::Role::foo' } + package My::Foo::Class; use Moose; - + ::lives_ok { with 'Foo::Role' => { excludes => 'foo' }, - 'Bar::Role' => { excludes => 'foo' }, + 'Bar::Role' => { excludes => 'foo' }, 'Baz::Role'; } '... composed our roles correctly'; - + package My::Foo::Class::Broken; use Moose; - + ::throws_ok { with 'Foo::Role', - 'Bar::Role' => { excludes => 'foo' }, + 'Bar::Role' => { excludes => 'foo' }, 'Baz::Role'; - } qr/\'Foo::Role\|Bar::Role\|Baz::Role\' requires the method \'foo\' to be implemented by \'My::Foo::Class::Broken\'/, - '... composed our roles correctly'; + } qr/\'Foo::Role\|Bar::Role\|Baz::Role\' requires the method \'foo\' to be implemented by \'My::Foo::Class::Broken\'/, + '... composed our roles correctly'; } { @@ -89,7 +89,7 @@ ok(My::OtherRole->meta->requires_method('bar'), '... and the &bar method is requ ::lives_ok { with 'Foo::Role' => { excludes => 'foo' }, - 'Bar::Role' => { excludes => 'foo' }, + 'Bar::Role' => { excludes => 'foo' }, 'Baz::Role'; } '... composed our roles correctly'; } @@ -103,7 +103,7 @@ ok(!My::Foo::Role->meta->requires_method('foo'), '... and the &foo method is not ::lives_ok { with 'Foo::Role', - 'Bar::Role' => { excludes => 'foo' }, + 'Bar::Role' => { excludes => 'foo' }, 'Baz::Role'; } '... composed our roles correctly'; } diff --git a/t/030_roles/013_method_aliasing_in_composition.t b/t/030_roles/013_method_aliasing_in_composition.t index 4eeeed6..4e5c25a 100644 --- a/t/030_roles/013_method_aliasing_in_composition.t +++ b/t/030_roles/013_method_aliasing_in_composition.t @@ -15,7 +15,7 @@ use Test::Exception; sub foo { 'Foo::foo' } sub bar { 'Foo::bar' } sub baz { 'Foo::baz' } - + requires 'role_bar'; package My::Class; @@ -24,14 +24,14 @@ use Test::Exception; ::lives_ok { with 'My::Role' => { alias => { bar => 'role_bar' } }; } '... this succeeds'; - + package My::Class::Failure; use Moose; ::throws_ok { with 'My::Role' => { alias => { bar => 'role_bar' } }; - } qr/Cannot create a method alias if a local method of the same name exists/, '... this succeeds'; - + } qr/Cannot create a method alias if a local method of the same name exists/, '... this succeeds'; + sub role_bar { 'FAIL' } } @@ -46,15 +46,15 @@ ok(My::Class->meta->has_method($_), "we have a $_ method") for qw(foo baz bar ro } '... this succeeds'; sub bar { 'My::OtherRole::bar' } - + package My::OtherRole::Failure; use Moose::Role; ::throws_ok { with 'My::Role' => { alias => { bar => 'role_bar' } }; - } qr/Cannot create a method alias if a local method of the same name exists/, '... this succeeds'; - - sub role_bar { 'FAIL' } + } qr/Cannot create a method alias if a local method of the same name exists/, '... this succeeds'; + + sub role_bar { 'FAIL' } } ok(My::OtherRole->meta->has_method($_), "we have a $_ method") for qw(foo baz role_bar); @@ -76,37 +76,37 @@ ok(My::AliasingRole->meta->requires_method('bar'), '... and the &bar method is r { package Foo::Role; use Moose::Role; - + sub foo { 'Foo::Role::foo' } - + package Bar::Role; use Moose::Role; - - sub foo { 'Bar::Role::foo' } + + sub foo { 'Bar::Role::foo' } package Baz::Role; use Moose::Role; - - sub foo { 'Baz::Role::foo' } - + + sub foo { 'Baz::Role::foo' } + package My::Foo::Class; use Moose; - + ::lives_ok { with 'Foo::Role' => { alias => { 'foo' => 'foo_foo' }, excludes => 'foo' }, - 'Bar::Role' => { alias => { 'foo' => 'bar_foo' }, excludes => 'foo' }, + 'Bar::Role' => { alias => { 'foo' => 'bar_foo' }, excludes => 'foo' }, 'Baz::Role'; - } '... composed our roles correctly'; - + } '... composed our roles correctly'; + package My::Foo::Class::Broken; use Moose; - + ::throws_ok { with 'Foo::Role' => { alias => { 'foo' => 'foo_foo' }, excludes => 'foo' }, - 'Bar::Role' => { alias => { 'foo' => 'foo_foo' }, excludes => 'foo' }, + 'Bar::Role' => { alias => { 'foo' => 'foo_foo' }, excludes => 'foo' }, 'Baz::Role'; - } qr/\'Foo::Role\|Bar::Role\|Baz::Role\' requires the method \'foo_foo\' to be implemented by \'My::Foo::Class::Broken\'/, - '... composed our roles correctly'; + } qr/\'Foo::Role\|Bar::Role\|Baz::Role\' requires the method \'foo_foo\' to be implemented by \'My::Foo::Class::Broken\'/, + '... composed our roles correctly'; } { @@ -114,8 +114,8 @@ ok(My::AliasingRole->meta->requires_method('bar'), '... and the &bar method is r isa_ok($foo, 'My::Foo::Class'); can_ok($foo, $_) for qw/foo foo_foo bar_foo/; is($foo->foo, 'Baz::Role::foo', '... got the right method'); - is($foo->foo_foo, 'Foo::Role::foo', '... got the right method'); - is($foo->bar_foo, 'Bar::Role::foo', '... got the right method'); + is($foo->foo_foo, 'Foo::Role::foo', '... got the right method'); + is($foo->bar_foo, 'Bar::Role::foo', '... got the right method'); } { @@ -124,7 +124,7 @@ ok(My::AliasingRole->meta->requires_method('bar'), '... and the &bar method is r ::lives_ok { with 'Foo::Role' => { alias => { 'foo' => 'foo_foo' }, excludes => 'foo' }, - 'Bar::Role' => { alias => { 'foo' => 'bar_foo' }, excludes => 'foo' }, + 'Bar::Role' => { alias => { 'foo' => 'bar_foo' }, excludes => 'foo' }, 'Baz::Role'; } '... composed our roles correctly'; } @@ -139,7 +139,7 @@ ok(!My::Foo::Role->meta->requires_method('foo'), '... and the &foo method is not ::lives_ok { with 'Foo::Role' => { alias => { 'foo' => 'foo_foo' }, excludes => 'foo' }, - 'Bar::Role' => { alias => { 'foo' => 'foo_foo' }, excludes => 'foo' }, + 'Bar::Role' => { alias => { 'foo' => 'foo_foo' }, excludes => 'foo' }, 'Baz::Role'; } '... composed our roles correctly'; } diff --git a/t/030_roles/014_more_alias_and_exclude.t b/t/030_roles/014_more_alias_and_exclude.t index 346c636..a544600 100644 --- a/t/030_roles/014_more_alias_and_exclude.t +++ b/t/030_roles/014_more_alias_and_exclude.t @@ -11,41 +11,41 @@ use Test::Exception; { package Foo; use Moose::Role; - + sub foo { 'Foo::foo' } sub bar { 'Foo::bar' } sub baz { 'Foo::baz' } - sub gorch { 'Foo::gorch' } - + sub gorch { 'Foo::gorch' } + package Bar; use Moose::Role; sub foo { 'Bar::foo' } sub bar { 'Bar::bar' } sub baz { 'Bar::baz' } - sub gorch { 'Bar::gorch' } + sub gorch { 'Bar::gorch' } package Baz; use Moose::Role; - + sub foo { 'Baz::foo' } sub bar { 'Baz::bar' } sub baz { 'Baz::baz' } - sub gorch { 'Baz::gorch' } - + sub gorch { 'Baz::gorch' } + package Gorch; use Moose::Role; - + sub foo { 'Gorch::foo' } sub bar { 'Gorch::bar' } sub baz { 'Gorch::baz' } - sub gorch { 'Gorch::gorch' } + sub gorch { 'Gorch::gorch' } } { package My::Class; use Moose; - + ::lives_ok { with 'Foo' => { excludes => [qw/bar baz gorch/], alias => { gorch => 'foo_gorch' } }, 'Bar' => { excludes => [qw/foo baz gorch/] }, diff --git a/t/030_roles/015_runtime_roles_and_attrs.t b/t/030_roles/015_runtime_roles_and_attrs.t index a2b3842..55a3847 100644 --- a/t/030_roles/015_runtime_roles_and_attrs.t +++ b/t/030_roles/015_runtime_roles_and_attrs.t @@ -32,7 +32,7 @@ use Scalar::Util 'blessed'; } my $obj = Foo->new; -isa_ok($obj, 'Foo'); +isa_ok($obj, 'Foo'); ok(!$obj->can( 'talk' ), "... the role is not composed yet"); ok(!$obj->can( 'fur' ), 'ditto'); diff --git a/t/030_roles/016_runtime_roles_and_nonmoose.t b/t/030_roles/016_runtime_roles_and_nonmoose.t index ecf1af0..be31150 100644 --- a/t/030_roles/016_runtime_roles_and_nonmoose.t +++ b/t/030_roles/016_runtime_roles_and_nonmoose.t @@ -34,10 +34,10 @@ use Scalar::Util 'blessed'; } my $bar = Bar->new; -isa_ok($bar, 'Bar'); +isa_ok($bar, 'Bar'); my $foo = Foo->new; -isa_ok($foo, 'Foo'); +isa_ok($foo, 'Foo'); ok(!$bar->can( 'talk' ), "... the role is not composed yet"); diff --git a/t/030_roles/017_extending_role_attrs.t b/t/030_roles/017_extending_role_attrs.t index 7c6dcc6..df01d3d 100644 --- a/t/030_roles/017_extending_role_attrs.t +++ b/t/030_roles/017_extending_role_attrs.t @@ -10,7 +10,7 @@ use Test::Exception; =pod -This basically just makes sure that using +name +This basically just makes sure that using +name on role attributes works right. =cut @@ -18,21 +18,21 @@ on role attributes works right. { package Foo::Role; use Moose::Role; - + has 'bar' => ( is => 'rw', - isa => 'Int', + isa => 'Int', default => sub { 10 }, ); - + package Foo; use Moose; - + with 'Foo::Role'; - + ::lives_ok { has '+bar' => (default => sub { 100 }); - } '... extended the attribute successfully'; + } '... extended the attribute successfully'; } my $foo = Foo->new; diff --git a/t/030_roles/018_runtime_roles_w_params.t b/t/030_roles/018_runtime_roles_w_params.t index d3eddae..33de3c3 100644 --- a/t/030_roles/018_runtime_roles_w_params.t +++ b/t/030_roles/018_runtime_roles_w_params.t @@ -12,11 +12,11 @@ use Test::Exception; package Foo; use Moose; has 'bar' => (is => 'ro'); - + package Bar; use Moose::Role; - - has 'baz' => (is => 'ro', default => 'BAZ'); + + has 'baz' => (is => 'ro', default => 'BAZ'); } # normal ... diff --git a/t/030_roles/020_role_composite.t b/t/030_roles/020_role_composite.t index 506968e..9f3b001 100644 --- a/t/030_roles/020_role_composite.t +++ b/t/030_roles/020_role_composite.t @@ -12,15 +12,15 @@ use Moose::Meta::Role::Composite; { package Role::Foo; use Moose::Role; - + package Role::Bar; use Moose::Role; package Role::Baz; - use Moose::Role; - + use Moose::Role; + package Role::Gorch; - use Moose::Role; + use Moose::Role; } { @@ -28,7 +28,7 @@ use Moose::Meta::Role::Composite; roles => [ Role::Foo->meta, Role::Bar->meta, - Role::Baz->meta, + Role::Baz->meta, ] ); isa_ok($c, 'Moose::Meta::Role::Composite'); @@ -38,22 +38,22 @@ use Moose::Meta::Role::Composite; is_deeply($c->get_roles, [ Role::Foo->meta, Role::Bar->meta, - Role::Baz->meta, + Role::Baz->meta, ], '... got the right roles'); - + ok($c->does_role($_), '... our composite does the role ' . $_) for qw( Role::Foo Role::Bar - Role::Baz + Role::Baz ); - + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this composed okay'; - + } '... this composed okay'; + ##... now nest 'em - { + { my $c2 = Moose::Meta::Role::Composite->new( roles => [ $c, @@ -66,15 +66,15 @@ use Moose::Meta::Role::Composite; is_deeply($c2->get_roles, [ $c, - Role::Gorch->meta, + Role::Gorch->meta, ], '... got the right roles'); ok($c2->does_role($_), '... our composite does the role ' . $_) for qw( Role::Foo Role::Bar - Role::Baz - Role::Gorch - ); + Role::Baz + Role::Gorch + ); } } diff --git a/t/030_roles/021_role_composite_exclusion.t b/t/030_roles/021_role_composite_exclusion.t index aa618f5..f12cb08 100644 --- a/t/030_roles/021_role_composite_exclusion.t +++ b/t/030_roles/021_role_composite_exclusion.t @@ -12,21 +12,21 @@ use Moose::Meta::Role::Composite; { package Role::Foo; use Moose::Role; - + package Role::Bar; use Moose::Role; - + package Role::ExcludesFoo; use Moose::Role; excludes 'Role::Foo'; - + package Role::DoesExcludesFoo; use Moose::Role; - with 'Role::ExcludesFoo'; - + with 'Role::ExcludesFoo'; + package Role::DoesFoo; use Moose::Role; - with 'Role::Foo'; + with 'Role::Foo'; } ok(Role::ExcludesFoo->meta->excludes_role('Role::Foo'), '... got the right exclusions'); @@ -55,10 +55,10 @@ dies_ok { isa_ok($c, 'Moose::Meta::Role::Composite'); is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this lives as expected'; + } '... this lives as expected'; } # test no conflicts w/exclusion @@ -66,18 +66,18 @@ dies_ok { my $c = Moose::Meta::Role::Composite->new( roles => [ Role::Bar->meta, - Role::ExcludesFoo->meta, + Role::ExcludesFoo->meta, ] ); isa_ok($c, 'Moose::Meta::Role::Composite'); is($c->name, 'Role::Bar|Role::ExcludesFoo', '... got the composite role name'); - + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this lives as expected'; - - is_deeply([$c->get_excluded_roles_list], ['Role::Foo'], '... has excluded roles'); + } '... this lives as expected'; + + is_deeply([$c->get_excluded_roles_list], ['Role::Foo'], '... has excluded roles'); } @@ -91,15 +91,15 @@ dies_ok { ] ) ); - + } '... this fails as expected'; # test conflict with an "inherited" exclusion of an "inherited" role dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( - Moose::Meta::Role::Composite->new( + Moose::Meta::Role::Composite->new( roles => [ - Role::DoesFoo->meta, + Role::DoesFoo->meta, Role::DoesExcludesFoo->meta, ] ) diff --git a/t/030_roles/022_role_composition_req_methods.t b/t/030_roles/022_role_composition_req_methods.t index be56016..2e6727e 100644 --- a/t/030_roles/022_role_composition_req_methods.t +++ b/t/030_roles/022_role_composition_req_methods.t @@ -11,20 +11,20 @@ use Moose::Meta::Role::Composite; { package Role::Foo; - use Moose::Role; + use Moose::Role; requires 'foo'; - + package Role::Bar; use Moose::Role; requires 'bar'; - + package Role::ProvidesFoo; - use Moose::Role; + use Moose::Role; sub foo { 'Role::ProvidesFoo::foo' } - + package Role::ProvidesBar; - use Moose::Role; - sub bar { 'Role::ProvidesBar::bar' } + use Moose::Role; + sub bar { 'Role::ProvidesBar::bar' } } # test simple requirement @@ -33,16 +33,16 @@ use Moose::Meta::Role::Composite; roles => [ Role::Foo->meta, Role::Bar->meta, - ] + ] ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - + is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; - + } '... this succeeds as expected'; + is_deeply( [ sort $c->get_required_method_list ], [ 'bar', 'foo' ], @@ -60,12 +60,12 @@ use Moose::Meta::Role::Composite; ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::ProvidesFoo', '... got the composite role name'); - - lives_ok { + is($c->name, 'Role::Foo|Role::ProvidesFoo', '... got the composite role name'); + + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; - + } '... this succeeds as expected'; + is_deeply( [ sort $c->get_required_method_list ], [], @@ -79,17 +79,17 @@ use Moose::Meta::Role::Composite; roles => [ Role::Foo->meta, Role::ProvidesFoo->meta, - Role::Bar->meta, + Role::Bar->meta, ] ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::Bar', '... got the composite role name'); - + is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::Bar', '... got the composite role name'); + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; - + } '... this succeeds as expected'; + is_deeply( [ sort $c->get_required_method_list ], [ 'bar' ], @@ -103,18 +103,18 @@ use Moose::Meta::Role::Composite; roles => [ Role::Foo->meta, Role::ProvidesFoo->meta, - Role::ProvidesBar->meta, - Role::Bar->meta, + Role::ProvidesBar->meta, + Role::Bar->meta, ] ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::ProvidesBar|Role::Bar', '... got the composite role name'); - + is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::ProvidesBar|Role::Bar', '... got the composite role name'); + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; - + } '... this succeeds as expected'; + is_deeply( [ sort $c->get_required_method_list ], [ ], diff --git a/t/030_roles/023_role_composition_attributes.t b/t/030_roles/023_role_composition_attributes.t index b0e7ad2..0086435 100644 --- a/t/030_roles/023_role_composition_attributes.t +++ b/t/030_roles/023_role_composition_attributes.t @@ -11,23 +11,23 @@ use Moose::Meta::Role::Composite; { package Role::Foo; - use Moose::Role; + use Moose::Role; has 'foo' => (is => 'rw'); - + package Role::Bar; use Moose::Role; has 'bar' => (is => 'rw'); - + package Role::FooConflict; - use Moose::Role; + use Moose::Role; has 'foo' => (is => 'rw'); - + package Role::BarConflict; use Moose::Role; has 'bar' => (is => 'rw'); - + package Role::AnotherFooConflict; - use Moose::Role; + use Moose::Role; with 'Role::FooConflict'; } @@ -41,12 +41,12 @@ use Moose::Meta::Role::Composite; ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - + is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; - + } '... this succeeds as expected'; + is_deeply( [ sort $c->get_attribute_list ], [ 'bar', 'foo' ], @@ -72,9 +72,9 @@ dies_ok { Moose::Meta::Role::Composite->new( roles => [ Role::Foo->meta, - Role::Bar->meta, + Role::Bar->meta, Role::FooConflict->meta, - Role::BarConflict->meta, + Role::BarConflict->meta, ] ) ); diff --git a/t/030_roles/024_role_composition_methods.t b/t/030_roles/024_role_composition_methods.t index 36c3bff..bf5c517 100644 --- a/t/030_roles/024_role_composition_methods.t +++ b/t/030_roles/024_role_composition_methods.t @@ -12,26 +12,26 @@ use Moose::Meta::Role::Composite; { package Role::Foo; use Moose::Role; - - sub foo { 'Role::Foo::foo' } - + + sub foo { 'Role::Foo::foo' } + package Role::Bar; use Moose::Role; sub bar { 'Role::Bar::bar' } - + package Role::FooConflict; - use Moose::Role; - - sub foo { 'Role::FooConflict::foo' } - + use Moose::Role; + + sub foo { 'Role::FooConflict::foo' } + package Role::BarConflict; use Moose::Role; - + sub bar { 'Role::BarConflict::bar' } - + package Role::AnotherFooConflict; - use Moose::Role; + use Moose::Role; with 'Role::FooConflict'; sub baz { 'Role::AnotherFooConflict::baz' } @@ -47,12 +47,12 @@ use Moose::Meta::Role::Composite; ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - + is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; - + } '... this succeeds as expected'; + is_deeply( [ sort $c->get_method_list ], [ 'bar', 'foo' ], @@ -70,23 +70,23 @@ use Moose::Meta::Role::Composite; ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::FooConflict', '... got the composite role name'); - + is($c->name, 'Role::Foo|Role::FooConflict', '... got the composite role name'); + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; - + } '... this succeeds as expected'; + is_deeply( [ sort $c->get_method_list ], [], '... got the right list of methods' - ); - + ); + is_deeply( [ sort $c->get_required_method_list ], [ 'foo' ], '... got the right list of required methods' - ); + ); } # test complex conflict @@ -94,14 +94,14 @@ use Moose::Meta::Role::Composite; my $c = Moose::Meta::Role::Composite->new( roles => [ Role::Foo->meta, - Role::Bar->meta, + Role::Bar->meta, Role::FooConflict->meta, - Role::BarConflict->meta, + Role::BarConflict->meta, ] ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::Bar|Role::FooConflict|Role::BarConflict', '... got the composite role name'); + is($c->name, 'Role::Foo|Role::Bar|Role::FooConflict|Role::BarConflict', '... got the composite role name'); lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); @@ -111,13 +111,13 @@ use Moose::Meta::Role::Composite; [ sort $c->get_method_list ], [], '... got the right list of methods' - ); - + ); + is_deeply( [ sort $c->get_required_method_list ], [ 'bar', 'foo' ], '... got the right list of required methods' - ); + ); } # test simple conflict @@ -130,22 +130,22 @@ use Moose::Meta::Role::Composite; ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::AnotherFooConflict', '... got the composite role name'); - + is($c->name, 'Role::Foo|Role::AnotherFooConflict', '... got the composite role name'); + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; - + } '... this succeeds as expected'; + is_deeply( [ sort $c->get_method_list ], [ 'baz' ], '... got the right list of methods' - ); - + ); + is_deeply( [ sort $c->get_required_method_list ], [ 'foo' ], '... got the right list of required methods' - ); + ); } diff --git a/t/030_roles/025_role_composition_override.t b/t/030_roles/025_role_composition_override.t index 33b61cd..d47fd3b 100644 --- a/t/030_roles/025_role_composition_override.t +++ b/t/030_roles/025_role_composition_override.t @@ -12,27 +12,27 @@ use Moose::Meta::Role::Composite; { package Role::Foo; use Moose::Role; - + override foo => sub { 'Role::Foo::foo' }; - + package Role::Bar; use Moose::Role; override bar => sub { 'Role::Bar::bar' }; - + package Role::FooConflict; - use Moose::Role; - + use Moose::Role; + override foo => sub { 'Role::FooConflict::foo' }; - + package Role::FooMethodConflict; - use Moose::Role; - - sub foo { 'Role::FooConflict::foo' } - + use Moose::Role; + + sub foo { 'Role::FooConflict::foo' } + package Role::BarMethodConflict; use Moose::Role; - + sub bar { 'Role::BarConflict::bar' } } @@ -46,12 +46,12 @@ use Moose::Meta::Role::Composite; ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); - + is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); + lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this lives ok'; - + } '... this lives ok'; + is_deeply( [ sort $c->get_method_modifier_list('override') ], [ 'bar', 'foo' ], @@ -74,7 +74,7 @@ dies_ok { # test simple overrides w/ conflicts dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( - Moose::Meta::Role::Composite->new( + Moose::Meta::Role::Composite->new( roles => [ Role::Foo->meta, Role::FooMethodConflict->meta, @@ -90,8 +90,8 @@ dies_ok { Moose::Meta::Role::Composite->new( roles => [ Role::Foo->meta, - Role::Bar->meta, - Role::FooConflict->meta, + Role::Bar->meta, + Role::FooConflict->meta, ] ) ); @@ -101,11 +101,11 @@ dies_ok { # test simple overrides w/ conflicts dies_ok { Moose::Meta::Role::Application::RoleSummation->new->apply( - Moose::Meta::Role::Composite->new( + Moose::Meta::Role::Composite->new( roles => [ Role::Foo->meta, - Role::Bar->meta, - Role::FooMethodConflict->meta, + Role::Bar->meta, + Role::FooMethodConflict->meta, ] ) ); diff --git a/t/030_roles/026_role_composition_method_mods.t b/t/030_roles/026_role_composition_method_mods.t index d83ee4e..9de99b4 100644 --- a/t/030_roles/026_role_composition_method_mods.t +++ b/t/030_roles/026_role_composition_method_mods.t @@ -14,16 +14,16 @@ use Moose::Meta::Role::Composite; use Moose::Role; before foo => sub { 'Role::Foo::foo' }; - around foo => sub { 'Role::Foo::foo' }; - after foo => sub { 'Role::Foo::foo' }; + around foo => sub { 'Role::Foo::foo' }; + after foo => sub { 'Role::Foo::foo' }; around baz => sub { [ 'Role::Foo', @{shift->(@_)} ] }; package Role::Bar; use Moose::Role; before bar => sub { 'Role::Bar::bar' }; - around bar => sub { 'Role::Bar::bar' }; - after bar => sub { 'Role::Bar::bar' }; + around bar => sub { 'Role::Bar::bar' }; + after bar => sub { 'Role::Bar::bar' }; package Role::Baz; use Moose::Role; @@ -60,11 +60,11 @@ use Moose::Meta::Role::Composite; ); isa_ok($c, 'Moose::Meta::Role::Composite'); - is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); + is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); lives_ok { Moose::Meta::Role::Application::RoleSummation->new->apply($c); - } '... this succeeds as expected'; + } '... this succeeds as expected'; is_deeply( [ sort $c->get_method_modifier_list('before') ], @@ -76,11 +76,11 @@ use Moose::Meta::Role::Composite; [ sort $c->get_method_modifier_list('after') ], [ 'bar', 'foo' ], '... got the right list of methods' - ); + ); is_deeply( [ sort $c->get_method_modifier_list('around') ], [ 'bar', 'baz', 'foo' ], '... got the right list of methods' - ); + ); } diff --git a/t/030_roles/033_role_exclusion_and_alias_bug.t b/t/030_roles/033_role_exclusion_and_alias_bug.t index 3fecf9d..097356b 100644 --- a/t/030_roles/033_role_exclusion_and_alias_bug.t +++ b/t/030_roles/033_role_exclusion_and_alias_bug.t @@ -9,18 +9,18 @@ use Test::Moose; { package My::Role; use Moose::Role; - + sub foo { "FOO" } - sub bar { "BAR" } + sub bar { "BAR" } } { package My::Class; use Moose; - + with 'My::Role' => { alias => { foo => 'baz', bar => 'gorch' }, - excludes => ['foo', 'bar'], + excludes => ['foo', 'bar'], }; } @@ -40,15 +40,15 @@ use Test::Moose; { package My::Role::Again; use Moose::Role; - + with 'My::Role' => { alias => { foo => 'baz', bar => 'gorch' }, - excludes => ['foo', 'bar'], + excludes => ['foo', 'bar'], }; - + package My::Class::Again; use Moose; - + with 'My::Role::Again'; } diff --git a/t/040_type_constraints/001_util_type_constraints.t b/t/040_type_constraints/001_util_type_constraints.t index b57a4e5..cf4e7e5 100644 --- a/t/040_type_constraints/001_util_type_constraints.t +++ b/t/040_type_constraints/001_util_type_constraints.t @@ -12,19 +12,19 @@ use Moose::Util::TypeConstraints; type Number => where { Scalar::Util::looks_like_number($_) }; -type String +type String => where { !ref($_) && !Number($_) } => message { "This is not a string ($_)" }; -subtype Natural - => as Number +subtype Natural + => as Number => where { $_ > 0 }; -subtype NaturalLessThanTen +subtype NaturalLessThanTen => as Natural => where { $_ < 10 } => message { "The number '$_' is not less than 10" }; - + Moose::Util::TypeConstraints->export_type_constraints_as_functions(); ok(Number(5), '... this is a Num'); @@ -45,9 +45,9 @@ ok(NaturalLessThanTen(5), '... this is a NaturalLessThanTen'); is(NaturalLessThanTen(12), undef, '... this is not a NaturalLessThanTen'); is(NaturalLessThanTen(-5), undef, '... this is not a NaturalLessThanTen'); is(NaturalLessThanTen('Foo'), undef, '... this is not a NaturalLessThanTen'); - -# anon sub-typing - + +# anon sub-typing + my $negative = subtype Number => where { $_ < 0 }; ok(defined $negative, '... got a value back from negative'); isa_ok($negative, 'Moose::Meta::TypeConstraint'); @@ -72,7 +72,7 @@ ok($negative2->is_subtype_of('Number'), '... $negative2 is a subtype of Number') ok(!$negative2->is_subtype_of('String'), '... $negative is not a subtype of String'); ok($negative2->has_message, '... it has a message'); -is($negative2->validate(2), +is($negative2->validate(2), '2 is not a negative number', '... validated unsuccessfully (got error)'); @@ -89,8 +89,8 @@ ok($natural_less_than_ten->has_message, '... it has a message'); ok(!defined($natural_less_than_ten->validate(5)), '... validated successfully (no error)'); -is($natural_less_than_ten->validate(15), - "The number '15' is not less than 10", +is($natural_less_than_ten->validate(15), + "The number '15' is not less than 10", '... validated unsuccessfully (got error)'); my $natural = find_type_constraint('Natural'); @@ -103,8 +103,8 @@ ok(!$natural->has_message, '... it does not have a message'); ok(!defined($natural->validate(5)), '... validated successfully (no error)'); -is($natural->validate(-5), - "Validation failed for 'Natural' failed with value -5", +is($natural->validate(-5), + "Validation failed for 'Natural' failed with value -5", '... validated unsuccessfully (got error)'); my $string = find_type_constraint('String'); @@ -114,8 +114,8 @@ ok($string->has_message, '... it does have a message'); ok(!defined($string->validate("Five")), '... validated successfully (no error)'); -is($string->validate(5), -"This is not a string (5)", +is($string->validate(5), +"This is not a string (5)", '... validated unsuccessfully (got error)'); lives_ok { Moose::Meta::Attribute->new('bob', isa => 'Spong') } diff --git a/t/040_type_constraints/003_util_std_type_constraints.t b/t/040_type_constraints/003_util_std_type_constraints.t index 65b7a08..2457d50 100644 --- a/t/040_type_constraints/003_util_std_type_constraints.t +++ b/t/040_type_constraints/003_util_std_type_constraints.t @@ -9,7 +9,7 @@ use Test::Exception; use Scalar::Util (); BEGIN { - use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Util::TypeConstraints'); } my $SCALAR_REF = \(my $var); diff --git a/t/040_type_constraints/004_util_find_type_constraint.t b/t/040_type_constraints/004_util_find_type_constraint.t index 5756cb8..4b6e764 100644 --- a/t/040_type_constraints/004_util_find_type_constraint.t +++ b/t/040_type_constraints/004_util_find_type_constraint.t @@ -12,7 +12,7 @@ BEGIN { foreach my $type_name (qw( Any - Item + Item Bool Undef Defined @@ -26,11 +26,11 @@ foreach my $type_name (qw( HashRef CodeRef RegexpRef - Object + Object Role )) { - is(find_type_constraint($type_name)->name, - $type_name, + is(find_type_constraint($type_name)->name, + $type_name, '... got the right name for ' . $type_name); } diff --git a/t/040_type_constraints/005_util_type_coercion.t b/t/040_type_constraints/005_util_type_coercion.t index 64e4684..86a158c 100644 --- a/t/040_type_constraints/005_util_type_coercion.t +++ b/t/040_type_constraints/005_util_type_coercion.t @@ -13,24 +13,24 @@ BEGIN { { package HTTPHeader; use Moose; - + has 'array' => (is => 'ro'); - has 'hash' => (is => 'ro'); + has 'hash' => (is => 'ro'); } -subtype Header => - => as Object +subtype Header => + => as Object => where { $_->isa('HTTPHeader') }; - -coerce Header - => from ArrayRef + +coerce Header + => from ArrayRef => via { HTTPHeader->new(array => $_[0]) } - => from HashRef + => from HashRef => via { HTTPHeader->new(hash => $_[0]) }; - -Moose::Util::TypeConstraints->export_type_constraints_as_functions(); - + +Moose::Util::TypeConstraints->export_type_constraints_as_functions(); + my $header = HTTPHeader->new(); isa_ok($header, 'HTTPHeader'); @@ -42,9 +42,9 @@ my $anon_type = subtype Object => where { $_->isa('HTTPHeader') }; lives_ok { coerce $anon_type - => from ArrayRef + => from ArrayRef => via { HTTPHeader->new(array => $_[0]) } - => from HashRef + => from HashRef => via { HTTPHeader->new(hash => $_[0]) }; } 'coercion of anonymous subtype succeeds'; @@ -54,35 +54,35 @@ foreach my $coercion ( ) { isa_ok($coercion, 'Moose::Meta::TypeCoercion'); - + { my $coerced = $coercion->coerce([ 1, 2, 3 ]); isa_ok($coerced, 'HTTPHeader'); - + is_deeply( $coerced->array(), [ 1, 2, 3 ], '... got the right array'); - is($coerced->hash(), undef, '... nothing assigned to the hash'); + is($coerced->hash(), undef, '... nothing assigned to the hash'); } - + { my $coerced = $coercion->coerce({ one => 1, two => 2, three => 3 }); isa_ok($coerced, 'HTTPHeader'); - + is_deeply( $coerced->hash(), { one => 1, two => 2, three => 3 }, '... got the right hash'); - is($coerced->array(), undef, '... nothing assigned to the array'); + is($coerced->array(), undef, '... nothing assigned to the array'); } - + { my $scalar_ref = \(my $var); my $coerced = $coercion->coerce($scalar_ref); is($coerced, $scalar_ref, '... got back what we put in'); } - + { my $coerced = $coercion->coerce("Foo"); is($coerced, "Foo", '... got back what we put in'); diff --git a/t/040_type_constraints/007_util_more_type_coercion.t b/t/040_type_constraints/007_util_more_type_coercion.t index 2bcafc1..cd29ea0 100644 --- a/t/040_type_constraints/007_util_more_type_coercion.t +++ b/t/040_type_constraints/007_util_more_type_coercion.t @@ -12,24 +12,24 @@ use Test::Exception; package HTTPHeader; use Moose; use Moose::Util::TypeConstraints; - + coerce 'HTTPHeader' - => from ArrayRef + => from ArrayRef => via { HTTPHeader->new(array => $_[0]) }; - + coerce 'HTTPHeader' - => from HashRef - => via { HTTPHeader->new(hash => $_[0]) }; - + => from HashRef + => via { HTTPHeader->new(hash => $_[0]) }; + has 'array' => (is => 'ro'); - has 'hash' => (is => 'ro'); + has 'hash' => (is => 'ro'); package Engine; use strict; use warnings; use Moose; - - has 'header' => (is => 'rw', isa => 'HTTPHeader', coerce => 1); + + has 'header' => (is => 'rw', isa => 'HTTPHeader', coerce => 1); } { @@ -63,11 +63,11 @@ use Test::Exception; ok(!defined($engine->header->array), '... no array value set'); dies_ok { - $engine->header("Foo"); + $engine->header("Foo"); } '... dies with the wrong type, even after coercion'; lives_ok { - $engine->header(HTTPHeader->new); + $engine->header(HTTPHeader->new); } '... lives with the right type, even after coercion'; } diff --git a/t/040_type_constraints/008_union_types.t b/t/040_type_constraints/008_union_types.t index 5c84661..e192b20 100644 --- a/t/040_type_constraints/008_union_types.t +++ b/t/040_type_constraints/008_union_types.t @@ -7,7 +7,7 @@ use Test::More tests => 35; use Test::Exception; BEGIN { - use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Util::TypeConstraints'); } my $Str = find_type_constraint('Str'); @@ -66,15 +66,15 @@ diag $HashOrArray->validate([]); ok(!defined($HashOrArray->validate([])), '... (ArrayRef | HashRef) can accept []'); ok(!defined($HashOrArray->validate({})), '... (ArrayRef | HashRef) can accept {}'); -like($HashOrArray->validate(\(my $var2)), -qr/Validation failed for \'ArrayRef\' failed with value SCALAR\(0x.+?\) and Validation failed for \'HashRef\' failed with value SCALAR\(0x.+?\) in \(ArrayRef\|HashRef\)/, +like($HashOrArray->validate(\(my $var2)), +qr/Validation failed for \'ArrayRef\' failed with value SCALAR\(0x.+?\) and Validation failed for \'HashRef\' failed with value SCALAR\(0x.+?\) in \(ArrayRef\|HashRef\)/, '... (ArrayRef | HashRef) cannot accept scalar refs'); -like($HashOrArray->validate(sub {}), -qr/Validation failed for \'ArrayRef\' failed with value CODE\(0x.+?\) and Validation failed for \'HashRef\' failed with value CODE\(0x.+?\) in \(ArrayRef\|HashRef\)/, +like($HashOrArray->validate(sub {}), +qr/Validation failed for \'ArrayRef\' failed with value CODE\(0x.+?\) and Validation failed for \'HashRef\' failed with value CODE\(0x.+?\) in \(ArrayRef\|HashRef\)/, '... (ArrayRef | HashRef) cannot accept code refs'); is($HashOrArray->validate(50), -'Validation failed for \'ArrayRef\' failed with value 50 and Validation failed for \'HashRef\' failed with value 50 in (ArrayRef|HashRef)', +'Validation failed for \'ArrayRef\' failed with value 50 and Validation failed for \'HashRef\' failed with value 50 in (ArrayRef|HashRef)', '... (ArrayRef | HashRef) cannot accept Numbers'); diff --git a/t/040_type_constraints/009_union_types_and_coercions.t b/t/040_type_constraints/009_union_types_and_coercions.t index 69254f5..20690d9 100644 --- a/t/040_type_constraints/009_union_types_and_coercions.t +++ b/t/040_type_constraints/009_union_types_and_coercions.t @@ -8,8 +8,8 @@ use Test::Exception; BEGIN { eval "use IO::String; use IO::File;"; - plan skip_all => "IO::String and IO::File are required for this test" if $@; - plan tests => 28; + plan skip_all => "IO::String and IO::File are required for this test" if $@; + plan tests => 28; } @@ -44,13 +44,13 @@ BEGIN { coerce 'IO::File' => from 'FileHandle' => via { bless $_, 'IO::File' }; - + # create the alias - + subtype 'IO::StringOrFile' => as 'IO::String | IO::File'; - + # attributes - + has 'raw_body' => ( is => 'rw', isa => 'IO::StringOrFile', @@ -70,90 +70,90 @@ BEGIN { isa_ok($email, 'Email::Moose'); isa_ok($email->raw_body, 'IO::String'); - + is($email->as_string, undef, '... got correct empty string'); } { my $email = Email::Moose->new(raw_body => '... this is my body ...'); isa_ok($email, 'Email::Moose'); - + isa_ok($email->raw_body, 'IO::String'); - - is($email->as_string, '... this is my body ...', '... got correct string'); - + + is($email->as_string, '... this is my body ...', '... got correct string'); + lives_ok { - $email->raw_body('... this is the next body ...'); + $email->raw_body('... this is the next body ...'); } '... this will coerce correctly'; - + isa_ok($email->raw_body, 'IO::String'); - - is($email->as_string, '... this is the next body ...', '... got correct string'); + + is($email->as_string, '... this is the next body ...', '... got correct string'); } { my $str = '... this is my body (ref) ...'; - + my $email = Email::Moose->new(raw_body => \$str); isa_ok($email, 'Email::Moose'); - + isa_ok($email->raw_body, 'IO::String'); - - is($email->as_string, $str, '... got correct string'); - - my $str2 = '... this is the next body (ref) ...'; - + + is($email->as_string, $str, '... got correct string'); + + my $str2 = '... this is the next body (ref) ...'; + lives_ok { - $email->raw_body(\$str2); + $email->raw_body(\$str2); } '... this will coerce correctly'; - + isa_ok($email->raw_body, 'IO::String'); - - is($email->as_string, $str2, '... got correct string'); + + is($email->as_string, $str2, '... got correct string'); } { my $io_str = IO::String->new('... this is my body (IO::String) ...'); - + my $email = Email::Moose->new(raw_body => $io_str); isa_ok($email, 'Email::Moose'); - + isa_ok($email->raw_body, 'IO::String'); is($email->raw_body, $io_str, '... and it is the one we expected'); - - is($email->as_string, '... this is my body (IO::String) ...', '... got correct string'); - - my $io_str2 = IO::String->new('... this is the next body (IO::String) ...'); - + + is($email->as_string, '... this is my body (IO::String) ...', '... got correct string'); + + my $io_str2 = IO::String->new('... this is the next body (IO::String) ...'); + lives_ok { - $email->raw_body($io_str2); + $email->raw_body($io_str2); } '... this will coerce correctly'; - + isa_ok($email->raw_body, 'IO::String'); is($email->raw_body, $io_str2, '... and it is the one we expected'); - - is($email->as_string, '... this is the next body (IO::String) ...', '... got correct string'); + + is($email->as_string, '... this is the next body (IO::String) ...', '... got correct string'); } { my $fh; - + open($fh, '<', $0) || die "Could not open $0"; - + my $email = Email::Moose->new(raw_body => $fh); isa_ok($email, 'Email::Moose'); - + isa_ok($email->raw_body, 'IO::File'); - + close($fh); } { my $fh = IO::File->new($0); - + my $email = Email::Moose->new(raw_body => $fh); isa_ok($email, 'Email::Moose'); - + isa_ok($email->raw_body, 'IO::File'); is($email->raw_body, $fh, '... and it is the one we expected'); } diff --git a/t/040_type_constraints/010_misc_type_tests.t b/t/040_type_constraints/010_misc_type_tests.t index 779bcf3..866c920 100644 --- a/t/040_type_constraints/010_misc_type_tests.t +++ b/t/040_type_constraints/010_misc_type_tests.t @@ -7,7 +7,7 @@ use Test::More tests => 8; use Test::Exception; BEGIN { - use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Util::TypeConstraints'); } # subtype 'aliasing' ... diff --git a/t/040_type_constraints/011_container_type_constraint.t b/t/040_type_constraints/011_container_type_constraint.t index 10b8ec9..c27d4b8 100644 --- a/t/040_type_constraints/011_container_type_constraint.t +++ b/t/040_type_constraints/011_container_type_constraint.t @@ -6,9 +6,9 @@ use warnings; use Test::More tests => 24; use Test::Exception; -BEGIN { - use_ok('Moose::Util::TypeConstraints'); - use_ok('Moose::Meta::TypeConstraint::Parameterized'); +BEGIN { + use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Meta::TypeConstraint::Parameterized'); } # Array of Ints diff --git a/t/040_type_constraints/012_container_type_coercion.t b/t/040_type_constraints/012_container_type_coercion.t index 693a16e..f6237e8 100644 --- a/t/040_type_constraints/012_container_type_coercion.t +++ b/t/040_type_constraints/012_container_type_coercion.t @@ -6,9 +6,9 @@ use warnings; use Test::More tests => 10; use Test::Exception; -BEGIN { - use_ok('Moose::Util::TypeConstraints'); - use_ok('Moose::Meta::TypeConstraint::Parameterized'); +BEGIN { + use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Meta::TypeConstraint::Parameterized'); } my $r = Moose::Util::TypeConstraints->get_type_constraint_registry; @@ -47,17 +47,17 @@ is(find_type_constraint('HashRef[Int]'), $hash_of_ints, '... found the type we j package Foo; use Moose; use Moose::Util::TypeConstraints; - + coerce 'ArrayRef[Int]' => from 'HashRef[Int]' => via { [ values %$_ ] }; - + has 'bar' => ( is => 'ro', isa => 'ArrayRef[Int]', coerce => 1, ); - + } my $foo = Foo->new(bar => { one => 1, two => 2, three => 3 }); diff --git a/t/040_type_constraints/013_advanced_type_creation.t b/t/040_type_constraints/013_advanced_type_creation.t index 2bf2273..0a40a9f 100644 --- a/t/040_type_constraints/013_advanced_type_creation.t +++ b/t/040_type_constraints/013_advanced_type_creation.t @@ -6,9 +6,9 @@ use warnings; use Test::More tests => 33; use Test::Exception; -BEGIN { - use_ok('Moose::Util::TypeConstraints'); - use_ok('Moose::Meta::TypeConstraint::Parameterized'); +BEGIN { + use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Meta::TypeConstraint::Parameterized'); } my $r = Moose::Util::TypeConstraints->get_type_constraint_registry; @@ -43,7 +43,7 @@ $r->add_type_constraint($array_of_ints_or_hash_ref); # union of Arrays of Str | Int or Arrays of Int | Hash -# we can't build this using the simplistic parser +# we can't build this using the simplistic parser # we have, so we have to do it by hand - SL my $pure_insanity = Moose::Util::TypeConstraints::create_type_constraint_union('ArrayRef[Int|Str] | ArrayRef[Int | HashRef]'); diff --git a/t/040_type_constraints/014_type_notation_parser.t b/t/040_type_constraints/014_type_notation_parser.t index 03d1d76..bf48b5f 100644 --- a/t/040_type_constraints/014_type_notation_parser.t +++ b/t/040_type_constraints/014_type_notation_parser.t @@ -18,17 +18,17 @@ Volunteers welcome :) ## check the containers -ok(Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_), +ok(Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_), '... this correctly detected a container (' . $_ . ')') for ( 'ArrayRef[Foo]', 'ArrayRef[Foo | Int]', - 'ArrayRef[ArrayRef[Int]]', - 'ArrayRef[ArrayRef[Int | Foo]]', - 'ArrayRef[ArrayRef[Int|Str]]', + 'ArrayRef[ArrayRef[Int]]', + 'ArrayRef[ArrayRef[Int | Foo]]', + 'ArrayRef[ArrayRef[Int|Str]]', ); -ok(!Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_), +ok(!Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_), '... this correctly detected a non-container (' . $_ . ')') for ( 'ArrayRef[]', @@ -39,12 +39,12 @@ ok(!Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_), my %split_tests = ( 'ArrayRef[Foo]' => [ 'ArrayRef', 'Foo' ], 'ArrayRef[Foo | Int]' => [ 'ArrayRef', 'Foo | Int' ], - 'ArrayRef[Foo|Int]' => [ 'ArrayRef', 'Foo|Int' ], - # these will get processed with recusion, + 'ArrayRef[Foo|Int]' => [ 'ArrayRef', 'Foo|Int' ], + # these will get processed with recusion, # so we only need to detect it once - 'ArrayRef[ArrayRef[Int]]' => [ 'ArrayRef', 'ArrayRef[Int]' ], + 'ArrayRef[ArrayRef[Int]]' => [ 'ArrayRef', 'ArrayRef[Int]' ], 'ArrayRef[ArrayRef[Int | Foo]]' => [ 'ArrayRef', 'ArrayRef[Int | Foo]' ], - 'ArrayRef[ArrayRef[Int|Str]]' => [ 'ArrayRef', 'ArrayRef[Int|Str]' ], + 'ArrayRef[ArrayRef[Int|Str]]' => [ 'ArrayRef', 'ArrayRef[Int|Str]' ], ); is_deeply( @@ -56,45 +56,45 @@ ok(!Moose::Util::TypeConstraints::_detect_parameterized_type_constraint($_), ## now for the unions -ok(Moose::Util::TypeConstraints::_detect_type_constraint_union($_), +ok(Moose::Util::TypeConstraints::_detect_type_constraint_union($_), '... this correctly detected union (' . $_ . ')') for ( 'Int | Str', - 'Int|Str', + 'Int|Str', 'ArrayRef[Foo] | Int', - 'ArrayRef[Foo]|Int', + 'ArrayRef[Foo]|Int', 'Int | ArrayRef[Foo]', - 'Int|ArrayRef[Foo]', + 'Int|ArrayRef[Foo]', 'ArrayRef[Foo | Int] | Str', - 'ArrayRef[Foo|Int]|Str', - 'Str | ArrayRef[Foo | Int]', - 'Str|ArrayRef[Foo|Int]', - 'Some|Silly|Name|With|Pipes | Int', - 'Some|Silly|Name|With|Pipes|Int', + 'ArrayRef[Foo|Int]|Str', + 'Str | ArrayRef[Foo | Int]', + 'Str|ArrayRef[Foo|Int]', + 'Some|Silly|Name|With|Pipes | Int', + 'Some|Silly|Name|With|Pipes|Int', ); -ok(!Moose::Util::TypeConstraints::_detect_type_constraint_union($_), +ok(!Moose::Util::TypeConstraints::_detect_type_constraint_union($_), '... this correctly detected a non-union (' . $_ . ')') for ( 'Int', 'ArrayRef[Foo | Int]', - 'ArrayRef[Foo|Int]', + 'ArrayRef[Foo|Int]', ); { my %split_tests = ( 'Int | Str' => [ 'Int', 'Str' ], - 'Int|Str' => [ 'Int', 'Str' ], + 'Int|Str' => [ 'Int', 'Str' ], 'ArrayRef[Foo] | Int' => [ 'ArrayRef[Foo]', 'Int' ], - 'ArrayRef[Foo]|Int' => [ 'ArrayRef[Foo]', 'Int' ], + 'ArrayRef[Foo]|Int' => [ 'ArrayRef[Foo]', 'Int' ], 'Int | ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ], - 'Int|ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ], + 'Int|ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ], 'ArrayRef[Foo | Int] | Str' => [ 'ArrayRef[Foo | Int]', 'Str' ], - 'ArrayRef[Foo|Int]|Str' => [ 'ArrayRef[Foo|Int]', 'Str' ], - 'Str | ArrayRef[Foo | Int]' => [ 'Str', 'ArrayRef[Foo | Int]' ], - 'Str|ArrayRef[Foo|Int]' => [ 'Str', 'ArrayRef[Foo|Int]' ], - 'Some|Silly|Name|With|Pipes | Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ], - 'Some|Silly|Name|With|Pipes|Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ], + 'ArrayRef[Foo|Int]|Str' => [ 'ArrayRef[Foo|Int]', 'Str' ], + 'Str | ArrayRef[Foo | Int]' => [ 'Str', 'ArrayRef[Foo | Int]' ], + 'Str|ArrayRef[Foo|Int]' => [ 'Str', 'ArrayRef[Foo|Int]' ], + 'Some|Silly|Name|With|Pipes | Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ], + 'Some|Silly|Name|With|Pipes|Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ], ); is_deeply( diff --git a/t/040_type_constraints/016_subtyping_parameterized_types.t b/t/040_type_constraints/016_subtyping_parameterized_types.t index 8f1855e..81d7ff1 100644 --- a/t/040_type_constraints/016_subtyping_parameterized_types.t +++ b/t/040_type_constraints/016_subtyping_parameterized_types.t @@ -38,7 +38,7 @@ lives_ok { } lives_ok { - subtype 'MySpecialHashExtended' + subtype 'MySpecialHashExtended' => as 'HashRef[Int]' => where { # all values are less then 10 @@ -96,7 +96,7 @@ lives_ok { ## never a real problem since you are likely to use Moose somewhere when you ## are creating type constraints. use Moose (); - + my $MyArrayRefInt = subtype 'MyArrayRefInt', as 'ArrayRef[Int]'; @@ -106,16 +106,16 @@ lives_ok { my $SubOfMyArrayRef = subtype 'SubOfMyArrayRef', as 'MyArrayRefInt[BiggerInt]'; - + ok $MyArrayRefInt->check([1,2,3]), '[1,2,3] is okay'; - ok ! $MyArrayRefInt->check(["a","b"]), '["a","b"] is not'; + ok ! $MyArrayRefInt->check(["a","b"]), '["a","b"] is not'; ok $BiggerInt->check(100), '100 is big enough'; - ok ! $BiggerInt->check(5), '5 is big enough'; + ok ! $BiggerInt->check(5), '5 is big enough'; ok $SubOfMyArrayRef->check([15,20,25]), '[15,20,25] is a bunch of big ints'; ok ! $SubOfMyArrayRef->check([15,5,25]), '[15,5,25] is NOT a bunch of big ints'; - + throws_ok sub { my $SubOfMyArrayRef = subtype 'SubSubOfMyArrayRef', - as 'SubOfMyArrayRef[Str]'; + as 'SubOfMyArrayRef[Str]'; }, qr/Str is not a subtype of BiggerInt/, 'Failed to parameterize with a bad type parameter'; } diff --git a/t/040_type_constraints/017_subtyping_union_types.t b/t/040_type_constraints/017_subtyping_union_types.t index 44ffd95..626a4bb 100644 --- a/t/040_type_constraints/017_subtyping_union_types.t +++ b/t/040_type_constraints/017_subtyping_union_types.t @@ -27,19 +27,19 @@ lives_ok { is($p->name, 'ArrayRef|HashRef', '... parent name is correct'); ok($t->check([]), '... validated it correctly'); - ok($t->check({}), '... validated it correctly'); + ok($t->check({}), '... validated it correctly'); ok(!$t->check(1), '... validated it correctly'); } lives_ok { - subtype 'MyCollectionsExtended' + subtype 'MyCollectionsExtended' => as 'ArrayRef|HashRef' => where { if (ref($_) eq 'ARRAY') { return if scalar(@$_) < 2; } elsif (ref($_) eq 'HASH') { - return if scalar(keys(%$_)) < 2; + return if scalar(keys(%$_)) < 2; } 1; }; @@ -58,11 +58,11 @@ lives_ok { is($p->name, 'ArrayRef|HashRef', '... parent name is correct'); ok(!$t->check([]), '... validated it correctly'); - ok($t->check([1, 2]), '... validated it correctly'); - - ok(!$t->check({}), '... validated it correctly'); - ok($t->check({ one => 1, two => 2 }), '... validated it correctly'); - + ok($t->check([1, 2]), '... validated it correctly'); + + ok(!$t->check({}), '... validated it correctly'); + ok($t->check({ one => 1, two => 2 }), '... validated it correctly'); + ok(!$t->check(1), '... validated it correctly'); } diff --git a/t/040_type_constraints/021_maybe_type_constraint.t b/t/040_type_constraints/021_maybe_type_constraint.t index a8db74c..233a17f 100644 --- a/t/040_type_constraints/021_maybe_type_constraint.t +++ b/t/040_type_constraints/021_maybe_type_constraint.t @@ -32,8 +32,8 @@ ok(!$type->check([]), '... checked type correctly (fail)'); package Foo; use Moose; use Moose::Util::TypeConstraints; - - has 'arr' => (is => 'rw', isa => 'Maybe[ArrayRef]', required => 1); + + has 'arr' => (is => 'rw', isa => 'Maybe[ArrayRef]', required => 1); has 'bar' => (is => 'rw', isa => class_type('Bar')); has 'maybe_bar' => (is => 'rw', isa => maybe_type(class_type('Bar'))); } @@ -80,10 +80,10 @@ dies_ok { use Moose; has 'Maybe_Int' => (is=>'rw', isa=>'Maybe[Int]'); - has 'Maybe_ArrayRef' => (is=>'rw', isa=>'Maybe[ArrayRef]'); - has 'Maybe_HashRef' => (is=>'rw', isa=>'Maybe[HashRef]'); - has 'Maybe_ArrayRefInt' => (is=>'rw', isa=>'Maybe[ArrayRef[Int]]'); - has 'Maybe_HashRefInt' => (is=>'rw', isa=>'Maybe[HashRef[Int]]'); + has 'Maybe_ArrayRef' => (is=>'rw', isa=>'Maybe[ArrayRef]'); + has 'Maybe_HashRef' => (is=>'rw', isa=>'Maybe[HashRef]'); + has 'Maybe_ArrayRefInt' => (is=>'rw', isa=>'Maybe[ArrayRef[Int]]'); + has 'Maybe_HashRefInt' => (is=>'rw', isa=>'Maybe[HashRef[Int]]'); } ok my $obj = Test::MooseX::Types::Maybe->new @@ -93,13 +93,13 @@ ok my $obj = Test::MooseX::Types::Maybe->new ok my $Maybe_Int = Moose::Util::TypeConstraints::find_or_parse_type_constraint('Maybe[Int]') => 'made TC Maybe[Int]'; - + ok $Maybe_Int->check(1) => 'passed (1)'; - + ok $obj->Maybe_Int(1) => 'assigned (1)'; - + ok $Maybe_Int->check() => 'passed ()'; @@ -111,23 +111,23 @@ ok $Maybe_Int->check(0) ok defined $obj->Maybe_Int(0) => 'assigned (0)'; - + ok $Maybe_Int->check(undef) => 'passed (undef)'; - + ok sub {$obj->Maybe_Int(undef); 1}->() => 'assigned (undef)'; - + ok !$Maybe_Int->check("") => 'failed ("")'; - -throws_ok sub { $obj->Maybe_Int("") }, + +throws_ok sub { $obj->Maybe_Int("") }, qr/Attribute \(Maybe_Int\) does not pass the type constraint/ => 'failed assigned ("")'; ok !$Maybe_Int->check("a") => 'failed ("a")'; -throws_ok sub { $obj->Maybe_Int("a") }, +throws_ok sub { $obj->Maybe_Int("a") }, qr/Attribute \(Maybe_Int\) does not pass the type constraint/ => 'failed assigned ("a")'; diff --git a/t/040_type_constraints/023_types_and_undef.t b/t/040_type_constraints/023_types_and_undef.t index f20ee2e..ca36bdb 100644 --- a/t/040_type_constraints/023_types_and_undef.t +++ b/t/040_type_constraints/023_types_and_undef.t @@ -46,21 +46,21 @@ ok(!Int(undef), '... undef is NOT a Int'); ok(!Number(undef), '... undef is NOT a Number'); ok(!Str(undef), '... undef is NOT a Str'); ok(!String(undef), '... undef is NOT a String'); - + ok(!Undef(5), '... 5 is a NOT a Undef'); ok(Defined(5), '... 5 is a Defined'); ok(Int(5), '... 5 is a Int'); ok(Number(5), '... 5 is a Number'); -ok(Str(5), '... 5 is a Str'); +ok(Str(5), '... 5 is a Str'); ok(!String(5), '... 5 is NOT a String'); - + ok(!Undef(0.5), '... 0.5 is a NOT a Undef'); ok(Defined(0.5), '... 0.5 is a Defined'); ok(!Int(0.5), '... 0.5 is NOT a Int'); ok(Number(0.5), '... 0.5 is a Number'); ok(Str(0.5), '... 0.5 is a Str'); ok(!String(0.5), '... 0.5 is NOT a String'); - + ok(!Undef('Foo'), '... "Foo" is NOT a Undef'); ok(Defined('Foo'), '... "Foo" is a Defined'); ok(!Int('Foo'), '... "Foo" is NOT a Int'); @@ -73,16 +73,16 @@ my $foo = Foo->new; lives_ok { $foo->vUndef(undef) } '... undef is a Foo->Undef'; dies_ok { $foo->vDefined(undef) } '... undef is NOT a Foo->Defined'; -dies_ok { $foo->vInt(undef) } '... undef is NOT a Foo->Int'; -dies_ok { $foo->vNumber(undef) } '... undef is NOT a Foo->Number'; -dies_ok { $foo->vStr(undef) } '... undef is NOT a Foo->Str'; -dies_ok { $foo->vString(undef) } '... undef is NOT a Foo->String'; +dies_ok { $foo->vInt(undef) } '... undef is NOT a Foo->Int'; +dies_ok { $foo->vNumber(undef) } '... undef is NOT a Foo->Number'; +dies_ok { $foo->vStr(undef) } '... undef is NOT a Foo->Str'; +dies_ok { $foo->vString(undef) } '... undef is NOT a Foo->String'; dies_ok { $foo->vUndef(5) } '... 5 is NOT a Foo->Undef'; lives_ok { $foo->vDefined(5) } '... 5 is a Foo->Defined'; lives_ok { $foo->vInt(5) } '... 5 is a Foo->Int'; lives_ok { $foo->vNumber(5) } '... 5 is a Foo->Number'; -lives_ok { $foo->vStr(5) } '... 5 is a Foo->Str'; +lives_ok { $foo->vStr(5) } '... 5 is a Foo->Str'; dies_ok { $foo->vString(5) } '... 5 is NOT a Foo->String'; dies_ok { $foo->vUndef(0.5) } '... 0.5 is NOT a Foo->Undef'; @@ -99,14 +99,14 @@ dies_ok { $foo->vNumber('Foo') } '... "Foo" is NOT a Foo->Number'; lives_ok { $foo->vStr('Foo') } '... "Foo" is a Foo->Str'; lives_ok { $foo->vString('Foo') } '... "Foo" is a Foo->String'; -# the lazy tests +# the lazy tests lives_ok { $foo->v_lazy_Undef() } '... undef is a Foo->Undef'; dies_ok { $foo->v_lazy_Defined() } '... undef is NOT a Foo->Defined'; -dies_ok { $foo->v_lazy_Int() } '... undef is NOT a Foo->Int'; -dies_ok { $foo->v_lazy_Number() } '... undef is NOT a Foo->Number'; -dies_ok { $foo->v_lazy_Str() } '... undef is NOT a Foo->Str'; -dies_ok { $foo->v_lazy_String() } '... undef is NOT a Foo->String'; +dies_ok { $foo->v_lazy_Int() } '... undef is NOT a Foo->Int'; +dies_ok { $foo->v_lazy_Number() } '... undef is NOT a Foo->Number'; +dies_ok { $foo->v_lazy_Str() } '... undef is NOT a Foo->Str'; +dies_ok { $foo->v_lazy_String() } '... undef is NOT a Foo->String'; diff --git a/t/040_type_constraints/025_type_coersion_on_lazy_attributes.t b/t/040_type_constraints/025_type_coersion_on_lazy_attributes.t index ebe9d33..3af0b5c 100644 --- a/t/040_type_constraints/025_type_coersion_on_lazy_attributes.t +++ b/t/040_type_constraints/025_type_coersion_on_lazy_attributes.t @@ -14,8 +14,8 @@ use Test::More tests => 2; => where { /^6$/ }; subtype 'TextSix' => as 'Str' => where { /Six/i }; - coerce 'TextSix' - => from 'DigitSix' + coerce 'TextSix' + => from 'DigitSix' => via { confess("Cannot live without 6 ($_)") unless /^6$/; 'Six' }; has foo => ( diff --git a/t/040_type_constraints/026_normalize_type_name.t b/t/040_type_constraints/026_normalize_type_name.t index 4393fa8..6379db3 100644 --- a/t/040_type_constraints/026_normalize_type_name.t +++ b/t/040_type_constraints/026_normalize_type_name.t @@ -7,7 +7,7 @@ use Test::More tests => 37; use Test::Exception; BEGIN { - use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Util::TypeConstraints'); } ## First, we check that the new regex parsing works diff --git a/t/040_type_constraints/027_parameterize_from.t b/t/040_type_constraints/027_parameterize_from.t index f917e28..3fd85f7 100644 --- a/t/040_type_constraints/027_parameterize_from.t +++ b/t/040_type_constraints/027_parameterize_from.t @@ -7,7 +7,7 @@ use Test::More tests => 12; use Test::Exception; BEGIN { - use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Util::TypeConstraints'); } # testing the parameterize method diff --git a/t/040_type_constraints/030_class_subtypes.t b/t/040_type_constraints/030_class_subtypes.t index 196fdf2..95ef25e 100644 --- a/t/040_type_constraints/030_class_subtypes.t +++ b/t/040_type_constraints/030_class_subtypes.t @@ -16,7 +16,7 @@ use Moose::Meta::TypeConstraint; package Test::Moose::Meta::TypeConstraint::AnySubType; use Moose; extends 'Moose::Meta::TypeConstraint'; - + sub my_custom_method { return 1; } diff --git a/t/050_metaclasses/001_custom_attr_meta_with_roles.t b/t/050_metaclasses/001_custom_attr_meta_with_roles.t index ba18c69..2d89151 100644 --- a/t/050_metaclasses/001_custom_attr_meta_with_roles.t +++ b/t/050_metaclasses/001_custom_attr_meta_with_roles.t @@ -11,14 +11,14 @@ use Test::Exception; { package My::Custom::Meta::Attr; use Moose; - + extends 'Moose::Meta::Attribute'; } { package My::Fancy::Role; use Moose::Role; - + has 'bling_bling' => ( metaclass => 'My::Custom::Meta::Attr', is => 'rw', @@ -29,7 +29,7 @@ use Test::Exception; { package My::Class; use Moose; - + with 'My::Fancy::Role'; } diff --git a/t/050_metaclasses/002_custom_attr_meta_as_role.t b/t/050_metaclasses/002_custom_attr_meta_as_role.t index 6c0fbfe..96c0f38 100644 --- a/t/050_metaclasses/002_custom_attr_meta_as_role.t +++ b/t/050_metaclasses/002_custom_attr_meta_as_role.t @@ -16,7 +16,7 @@ lives_ok { lives_ok { package Moose::Meta::Attribute::Custom::Test; use Moose; - + extends 'Moose::Meta::Attribute'; with 'MooseX::Attribute::Test'; } 'custom attribute metaclass extending role is okay'; diff --git a/t/050_metaclasses/003_moose_w_metaclass.t b/t/050_metaclasses/003_moose_w_metaclass.t index 55576ba..2a880d9 100644 --- a/t/050_metaclasses/003_moose_w_metaclass.t +++ b/t/050_metaclasses/003_moose_w_metaclass.t @@ -10,11 +10,11 @@ use Test::Exception; =pod -This test demonstrates that Moose will respect -a metaclass previously set with the metaclass -pragma. +This test demonstrates that Moose will respect +a metaclass previously set with the metaclass +pragma. -It also checks an error condition where that +It also checks an error condition where that metaclass must be a Moose::Meta::Class subclass in order to work. @@ -27,7 +27,7 @@ in order to work. use warnings; use base 'Moose::Meta::Class'; - + package Foo; use strict; use warnings; @@ -41,16 +41,16 @@ isa_ok(Foo->meta, 'Foo::Meta'); package Bar::Meta; use strict; use warnings; - + use base 'Class::MOP::Class'; - + package Bar; use strict; use warnings; use metaclass 'Bar::Meta'; eval 'use Moose;'; ::ok($@, '... could not load moose without correct metaclass'); - ::like($@, + ::like($@, qr/^Bar already has a metaclass, but it does not inherit Moose::Meta::Class/, '... got the right error too'); } diff --git a/t/050_metaclasses/004_moose_for_meta.t b/t/050_metaclasses/004_moose_for_meta.t index d355dbc..003e2f7 100644 --- a/t/050_metaclasses/004_moose_for_meta.t +++ b/t/050_metaclasses/004_moose_for_meta.t @@ -18,9 +18,9 @@ Moose meta-level classes using Moose itself. { package My::Meta::Class; use Moose; - + extends 'Moose::Meta::Class'; - + around 'create_anon_class' => sub { my $next = shift; my ($self, %options) = @_; @@ -36,23 +36,23 @@ isa_ok($anon, 'Moose::Meta::Class'); isa_ok($anon, 'Class::MOP::Class'); is_deeply( - [ $anon->superclasses ], - [ 'Moose::Object' ], + [ $anon->superclasses ], + [ 'Moose::Object' ], '... got the default superclasses'); { package My::Meta::Attribute::DefaultReadOnly; use Moose; - + extends 'Moose::Meta::Attribute'; - + around 'new' => sub { my $next = shift; my ($self, $name, %options) = @_; - $options{is} = 'ro' + $options{is} = 'ro' unless exists $options{is}; $next->($self, $name, %options); - }; + }; } { diff --git a/t/050_metaclasses/010_extending_and_embedding_back_compat.t b/t/050_metaclasses/010_extending_and_embedding_back_compat.t index 9771a73..6ec3a5a 100644 --- a/t/050_metaclasses/010_extending_and_embedding_back_compat.t +++ b/t/050_metaclasses/010_extending_and_embedding_back_compat.t @@ -11,12 +11,12 @@ use Test::Exception; BEGIN { package MyFramework::Base; use Moose; - + package MyFramework::Meta::Base; - use Moose; - - extends 'Moose::Meta::Class'; - + use Moose; + + extends 'Moose::Meta::Class'; + package MyFramework; use Moose; @@ -25,7 +25,7 @@ BEGIN { strict->import; warnings->import; - + return if $CALLER eq 'main'; Moose::init_meta( $CALLER, 'MyFramework::Base', 'MyFramework::Meta::Base' ); Moose->import({ into => $CALLER }); @@ -34,10 +34,10 @@ BEGIN { } } -{ +{ package MyClass; BEGIN { MyFramework->import } - + has 'foo' => (is => 'rw'); } diff --git a/t/050_metaclasses/015_metarole.t b/t/050_metaclasses/015_metarole.t index a7c4c07..365db0c 100644 --- a/t/050_metaclasses/015_metarole.t +++ b/t/050_metaclasses/015_metarole.t @@ -517,7 +517,7 @@ use Moose::Util::MetaRole; shift; my %p = @_; Moose->init_meta(%p); - return Moose::Util::MetaRole::apply_metaclass_roles( + return Moose::Util::MetaRole::apply_metaclass_roles( for_class => $p{for_class}, # Causes us to recurse through init_meta, as we have to # load MyMetaclassRole from disk. diff --git a/t/060_compat/001_module_refresh_compat.t b/t/060_compat/001_module_refresh_compat.t index ab139a0..93857cd 100644 --- a/t/060_compat/001_module_refresh_compat.t +++ b/t/060_compat/001_module_refresh_compat.t @@ -10,26 +10,26 @@ use Test::Exception; BEGIN { eval "use Module::Refresh;"; - plan skip_all => "Module::Refresh is required for this test" if $@; - plan tests => 23; + plan skip_all => "Module::Refresh is required for this test" if $@; + plan tests => 23; } =pod First lets test some of our simple example modules ... -=cut +=cut my @modules = qw[Foo Bar MyMooseA MyMooseB MyMooseObject]; do { use_ok($_); - + is($_->meta->name, $_, '... initialized the meta correctly'); - + lives_ok { Module::Refresh->new->refresh_module($_ . '.pm') - } '... successfully refreshed ' . $_; + } '... successfully refreshed ' . $_; } foreach @modules; =pod @@ -57,7 +57,7 @@ has 'foo' => (is => 'rw', isa => 'Int'); |; { - open FILE, ">", $test_module_file + open FILE, ">", $test_module_file || die "Could not open $test_module_file because $!"; print FILE $test_module_source_1; close FILE; @@ -69,7 +69,7 @@ ok(TestBaz->meta->has_attribute('foo'), '... it has the foo attribute as well'); ok(!TestBaz->isa('Foo'), '... TestBaz is not a Foo'); { - open FILE, ">", $test_module_file + open FILE, ">", $test_module_file || die "Could not open $test_module_file because $!"; print FILE $test_module_source_2; close FILE; diff --git a/t/060_compat/002_moose_respects_base.t b/t/060_compat/002_moose_respects_base.t index e146561..2e37c9d 100644 --- a/t/060_compat/002_moose_respects_base.t +++ b/t/060_compat/002_moose_respects_base.t @@ -10,11 +10,11 @@ use Test::Exception; =pod -This test demonstrates that Moose will respect -a previously set @ISA using use base, and not -try to add Moose::Object to it. +This test demonstrates that Moose will respect +a previously set @ISA using use base, and not +try to add Moose::Object to it. -However, this is extremely order sensitive as +However, this is extremely order sensitive as this test also demonstrates. =cut @@ -23,18 +23,18 @@ this test also demonstrates. package Foo; use strict; use warnings; - + sub foo { 'Foo::foo' } - - package Bar; + + package Bar; use base 'Foo'; use Moose; - - sub new { (shift)->meta->new_object(@_) } - + + sub new { (shift)->meta->new_object(@_) } + package Baz; - use Moose; - use base 'Foo'; + use Moose; + use base 'Foo'; } my $bar = Bar->new; diff --git a/t/100_bugs/001_subtype_quote_bug.t b/t/100_bugs/001_subtype_quote_bug.t index a97e2d1..f605e30 100644 --- a/t/100_bugs/001_subtype_quote_bug.t +++ b/t/100_bugs/001_subtype_quote_bug.t @@ -13,20 +13,20 @@ The code: subtype Stuff => as Object => where { ... } - -will break if the Object:: namespace exists. So the + +will break if the Object:: namespace exists. So the solution is to quote 'Object', like so: subtype Stuff => as 'Object' => where { ... } -Moose 0.03 did this, now it doesn't, so all should -be well from now on. +Moose 0.03 did this, now it doesn't, so all should +be well from now on. =cut { package Object::Test; } package Foo; -::use_ok('Moose'); +::use_ok('Moose'); diff --git a/t/100_bugs/004_subclass_use_base_bug.t b/t/100_bugs/004_subclass_use_base_bug.t index 689cc21..4684ab3 100644 --- a/t/100_bugs/004_subclass_use_base_bug.t +++ b/t/100_bugs/004_subclass_use_base_bug.t @@ -9,20 +9,20 @@ use Test::More tests => 2; =pod -This just makes sure that the Bar gets +This just makes sure that the Bar gets a metaclass initialized for it correctly. =cut { - package Foo; - use Moose; + package Foo; + use Moose; - package Bar; + package Bar; use strict; use warnings; - - use base 'Foo'; + + use base 'Foo'; } my $bar = Bar->new; diff --git a/t/100_bugs/005_inline_reader_bug.t b/t/100_bugs/005_inline_reader_bug.t index 2e67750..cc0c01e 100644 --- a/t/100_bugs/005_inline_reader_bug.t +++ b/t/100_bugs/005_inline_reader_bug.t @@ -10,7 +10,7 @@ use Test::Exception; =pod -This was a bug, but it is fixed now. This +This was a bug, but it is fixed now. This test makes sure it does not creep back in. =cut @@ -18,14 +18,14 @@ test makes sure it does not creep back in. { package Foo; use Moose; - + ::lives_ok { has 'bar' => ( - is => 'ro', + is => 'ro', isa => 'Int', lazy => 1, default => 10, ); } '... this didnt die'; } - + diff --git a/t/100_bugs/006_handles_foreign_class_bug.t b/t/100_bugs/006_handles_foreign_class_bug.t index b4db4c7..dc162f5 100644 --- a/t/100_bugs/006_handles_foreign_class_bug.t +++ b/t/100_bugs/006_handles_foreign_class_bug.t @@ -9,10 +9,10 @@ use Test::Exception; { package Foo; - sub new { - bless({}, 'Foo') + sub new { + bless({}, 'Foo') } - + sub a { 'Foo::a' } } @@ -29,7 +29,7 @@ use Test::Exception; handles => qr/^a$/, ); } '... can create the attribute with delegations'; - + } my $bar; @@ -55,7 +55,7 @@ $SIG{__WARN__} = sub { push @w, "@_" }; handles => qr/.*/, ); } '... can create the attribute with delegations'; - + } is(@w, 0, "no warnings"); @@ -88,7 +88,7 @@ is($baz->a, 'Foo::a', '... got the right delgated value'); handles => [qw(a new)], ); } '... can create the attribute with delegations'; - + } { diff --git a/t/100_bugs/007_reader_precedence_bug.t b/t/100_bugs/007_reader_precedence_bug.t index c36721f..1aa0abd 100644 --- a/t/100_bugs/007_reader_precedence_bug.t +++ b/t/100_bugs/007_reader_precedence_bug.t @@ -7,14 +7,14 @@ use Test::More tests => 3; { package Foo; - use Moose; + use Moose; has 'foo' => ( is => 'ro', reader => 'get_foo' ); } { my $foo = Foo->new(foo => 10); my $reader = $foo->meta->get_attribute('foo')->reader; - is($reader, 'get_foo', + is($reader, 'get_foo', 'reader => "get_foo" has correct presedence'); can_ok($foo, 'get_foo'); is($foo->$reader, 10, "Reader works as expected"); diff --git a/t/100_bugs/011_DEMOLISH_eats_exceptions.t b/t/100_bugs/011_DEMOLISH_eats_exceptions.t index 5813892..4180fe6 100644 --- a/t/100_bugs/011_DEMOLISH_eats_exceptions.t +++ b/t/100_bugs/011_DEMOLISH_eats_exceptions.t @@ -115,32 +115,32 @@ sub check_em { ::is( $obj, undef, "... the object is undef" ); } { - local $@; + local $@; my $obj = eval { $pkg->new ( notanattr => 1 ); }; ::like( $@, qr/is required/, "... $pkg undef" ); ::is( $obj, undef, "... the object is undef" ); } { - local $@; + local $@; my $obj = eval { $pkg->new ( %param ); }; ::like( $@, qr/is required/, "... $pkg undef param" ); ::is( $obj, undef, "... the object is undef" ); } { - local $@; + local $@; my $obj = eval { $pkg->new ( path => '/' ); }; ::like( $@, qr/does not pass the type constraint/, "... $pkg root path forbidden" ); ::is( $obj, undef, "... the object is undef" ); } { - local $@; + local $@; my $obj = eval { $pkg->new ( path => '/this_path/does/not_exist' ); }; ::like( $@, qr/does not exist/, "... $pkg non existing path" ); ::is( $obj, undef, "... the object is undef" ); } { - local $@; + local $@; my $obj = eval { $pkg->new ( path => $FindBin::Bin ); }; ::is( $@, '', "... $pkg no error" ); ::isa_ok( $obj, $pkg ); diff --git a/t/100_bugs/012_DEMOLISH_eats_mini.t b/t/100_bugs/012_DEMOLISH_eats_mini.t index 5773a60..58ec76b 100644 --- a/t/100_bugs/012_DEMOLISH_eats_mini.t +++ b/t/100_bugs/012_DEMOLISH_eats_mini.t @@ -21,7 +21,7 @@ use Test::Exception; # if no call to ANY Moose::Object->new was done before. sub DEMOLISH { my ( $self ) = @_; - # ... Moose (kinda) eats exceptions in DESTROY/DEMOLISH"; + # ... Moose (kinda) eats exceptions in DESTROY/DEMOLISH"; } } @@ -33,7 +33,7 @@ use Test::Exception; { package Bar; - + sub new { die "Bar died"; } sub DESTROY { diff --git a/t/100_bugs/016_inheriting_from_roles.t b/t/100_bugs/016_inheriting_from_roles.t index 2fa0357..aa6a86b 100644 --- a/t/100_bugs/016_inheriting_from_roles.t +++ b/t/100_bugs/016_inheriting_from_roles.t @@ -15,9 +15,9 @@ use Test::Exception; { package My::Class; use Moose; - + ::throws_ok { extends 'My::Role'; - } qr/You cannot inherit from a Moose Role \(My\:\:Role\)/, + } qr/You cannot inherit from a Moose Role \(My\:\:Role\)/, '... this croaks correctly'; } diff --git a/t/100_bugs/017_type_constraint_messages.t b/t/100_bugs/017_type_constraint_messages.t index eecfad5..e5bee1e 100644 --- a/t/100_bugs/017_type_constraint_messages.t +++ b/t/100_bugs/017_type_constraint_messages.t @@ -21,7 +21,7 @@ use Test::Exception; subtype 'MyArrayRef' => as 'ArrayRef' => where { defined $_->[0] } - => message { ref $_ ? "ref: ". ref $_ : 'scalar' } # stringy + => message { ref $_ ? "ref: ". ref $_ : 'scalar' } # stringy ; subtype 'MyObjectType' diff --git a/t/100_bugs/018_immutable_metaclass_does_role.t b/t/100_bugs/018_immutable_metaclass_does_role.t index be4f016..eccb1d9 100644 --- a/t/100_bugs/018_immutable_metaclass_does_role.t +++ b/t/100_bugs/018_immutable_metaclass_does_role.t @@ -18,8 +18,8 @@ BEGIN { use Moose qw(extends with); extends 'Moose::Meta::Class'; with 'MyRole'; - - sub foo { 'i am foo' } + + sub foo { 'i am foo' } } { diff --git a/t/100_bugs/019_moose_octal_defaults.t b/t/100_bugs/019_moose_octal_defaults.t index dc97e20..63614af 100644 --- a/t/100_bugs/019_moose_octal_defaults.t +++ b/t/100_bugs/019_moose_octal_defaults.t @@ -33,7 +33,7 @@ use lib qw(lib); has id => ( isa => 'Str', is => 'ro', - default => 017600, + default => 017600, ); no Moose; @@ -56,7 +56,7 @@ use lib qw(lib); has id => ( isa => 'Str', is => 'ro', - default => 0xFF, + default => 0xFF, ); no Moose; @@ -79,7 +79,7 @@ use lib qw(lib); has id => ( isa => 'Str', is => 'ro', - default => '0xFF', + default => '0xFF', ); no Moose; @@ -102,7 +102,7 @@ use lib qw(lib); has id => ( isa => 'Str', is => 'ro', - default => '0 but true', + default => '0 but true', ); no Moose; diff --git a/t/200_examples/001_example.t b/t/200_examples/001_example.t index 473da12..d7dd836 100644 --- a/t/200_examples/001_example.t +++ b/t/200_examples/001_example.t @@ -20,16 +20,16 @@ use Test::Exception; my $c = shift; my ($self, $field) = @_; return undef if $c->($self, $self->validation_value($field)); - return $self->error_message; + return $self->error_message; }; - + sub validation_value { my ($self, $field) = @_; return $field; } - + sub error_message { confess "Abstract method!" } - + package Constraint::OnLength; use Moose::Role; @@ -42,11 +42,11 @@ use Test::Exception; override 'error_message' => sub { my $self = shift; return super() . ' ' . $self->units; - }; + }; } -## Classes +## Classes { package Constraint::AtLeast; @@ -78,12 +78,12 @@ use Test::Exception; extends 'Constraint::NoMoreThan'; with 'Constraint::OnLength'; - + package Constraint::LengthAtLeast; use Moose; - + extends 'Constraint::AtLeast'; - with 'Constraint::OnLength'; + with 'Constraint::OnLength'; } my $no_more_than_10 = Constraint::NoMoreThan->new(value => 10); @@ -112,8 +112,8 @@ ok($no_more_than_10_chars->does('Constraint'), '... Constraint::LengthNoMoreThan ok($no_more_than_10_chars->does('Constraint::OnLength'), '... Constraint::LengthNoMoreThan does Constraint::OnLength'); ok(!defined($no_more_than_10_chars->validate('foo')), '... validated correctly'); -is($no_more_than_10_chars->validate('foooooooooo'), - 'must be no more than 10 chars', +is($no_more_than_10_chars->validate('foooooooooo'), + 'must be no more than 10 chars', '... validation failed correctly'); my $at_least_10_chars = Constraint::LengthAtLeast->new(value => 10, units => 'chars'); diff --git a/t/200_examples/002_example_Moose_POOP.t b/t/200_examples/002_example_Moose_POOP.t index 79c864c..68ed49a 100644 --- a/t/200_examples/002_example_Moose_POOP.t +++ b/t/200_examples/002_example_Moose_POOP.t @@ -7,10 +7,10 @@ use Test::More; BEGIN { eval "use DBM::Deep 1.0003;"; - plan skip_all => "DBM::Deep 1.0003 (or greater) is required for this test" if $@; + plan skip_all => "DBM::Deep 1.0003 (or greater) is required for this test" if $@; eval "use DateTime::Format::MySQL;"; - plan skip_all => "DateTime::Format::MySQL is required for this test" if $@; - plan tests => 88; + plan skip_all => "DateTime::Format::MySQL is required for this test" if $@; + plan tests => 88; } use Test::Exception; @@ -28,23 +28,23 @@ END { =pod -This example creates a very basic Object Database which -links in the instances created with a backend store +This example creates a very basic Object Database which +links in the instances created with a backend store (a DBM::Deep hash). It is by no means to be taken seriously -as a real-world ODB, but is a proof of concept of the flexibility -of the ::Instance protocol. +as a real-world ODB, but is a proof of concept of the flexibility +of the ::Instance protocol. =cut BEGIN { - + package Moose::POOP::Meta::Instance; use Moose; - + use DBM::Deep; - + extends 'Moose::Meta::Instance'; - + { my %INSTANCE_COUNTERS; @@ -53,56 +53,56 @@ BEGIN { autobless => 1, locking => 1, }); - + sub _reload_db { #use Data::Dumper; - #warn Dumper $db; + #warn Dumper $db; $db = undef; $db = DBM::Deep->new({ file => "newswriter.db", autobless => 1, locking => 1, - }); + }); } - + sub create_instance { my $self = shift; my $class = $self->associated_metaclass->name; my $oid = ++$INSTANCE_COUNTERS{$class}; - + $db->{$class}->[($oid - 1)] = {}; - + bless { oid => $oid, instance => $db->{$class}->[($oid - 1)] }, $class; } - + sub find_instance { my ($self, $oid) = @_; - my $instance = $db->{$self->associated_metaclass->name}->[($oid - 1)]; + my $instance = $db->{$self->associated_metaclass->name}->[($oid - 1)]; bless { oid => $oid, instance => $instance, }, $self->associated_metaclass->name; - } - + } + sub clone_instance { my ($self, $instance) = @_; - + my $class = $self->{meta}->name; my $oid = ++$INSTANCE_COUNTERS{$class}; - + my $clone = tied($instance)->clone; - + bless { oid => $oid, instance => $clone, }, $class; - } + } } - + sub get_instance_oid { my ($self, $instance) = @_; $instance->{oid}; @@ -125,34 +125,34 @@ BEGIN { sub weaken_slot_value { confess "Not sure how well DBM::Deep plays with weak refs, Rob says 'Write a test'"; - } - + } + sub inline_slot_access { my ($self, $instance, $slot_name) = @_; sprintf "%s->{instance}->{%s}", $instance, $slot_name; } - + package Moose::POOP::Meta::Class; - use Moose; - - extends 'Moose::Meta::Class'; - + use Moose; + + extends 'Moose::Meta::Class'; + override '_construct_instance' => sub { my $class = shift; my $params = @_ == 1 ? $_[0] : {@_}; - return $class->get_meta_instance->find_instance($params->{oid}) + return $class->get_meta_instance->find_instance($params->{oid}) if $params->{oid}; super(); }; } -{ +{ package Moose::POOP::Object; use metaclass 'Moose::POOP::Meta::Class' => ( instance_metaclass => 'Moose::POOP::Meta::Instance' - ); + ); use Moose; - + sub oid { my $self = shift; $self->meta @@ -161,80 +161,80 @@ BEGIN { } } -{ +{ package Newswriter::Author; use Moose; - + extends 'Moose::POOP::Object'; - + has 'first_name' => (is => 'rw', isa => 'Str'); - has 'last_name' => (is => 'rw', isa => 'Str'); - - package Newswriter::Article; + has 'last_name' => (is => 'rw', isa => 'Str'); + + package Newswriter::Article; use Moose; - use Moose::Util::TypeConstraints; - + use Moose::Util::TypeConstraints; + use DateTime::Format::MySQL; - - extends 'Moose::POOP::Object'; + + extends 'Moose::POOP::Object'; subtype 'Headline' => as 'Str' => where { length($_) < 100 }; - + subtype 'Summary' => as 'Str' => where { length($_) < 255 }; - + subtype 'DateTimeFormatString' => as 'Str' => where { DateTime::Format::MySQL->parse_datetime($_) }; - + enum 'Status' => qw(draft posted pending archive); - + has 'headline' => (is => 'rw', isa => 'Headline'); - has 'summary' => (is => 'rw', isa => 'Summary'); - has 'article' => (is => 'rw', isa => 'Str'); - + has 'summary' => (is => 'rw', isa => 'Summary'); + has 'article' => (is => 'rw', isa => 'Str'); + has 'start_date' => (is => 'rw', isa => 'DateTimeFormatString'); - has 'end_date' => (is => 'rw', isa => 'DateTimeFormatString'); - - has 'author' => (is => 'rw', isa => 'Newswriter::Author'); - + has 'end_date' => (is => 'rw', isa => 'DateTimeFormatString'); + + has 'author' => (is => 'rw', isa => 'Newswriter::Author'); + has 'status' => (is => 'rw', isa => 'Status'); - + around 'start_date', 'end_date' => sub { my $c = shift; my $self = shift; - $c->($self, DateTime::Format::MySQL->format_datetime($_[0])) if @_; + $c->($self, DateTime::Format::MySQL->format_datetime($_[0])) if @_; DateTime::Format::MySQL->parse_datetime($c->($self) || return undef); - }; + }; } { # check the meta stuff first isa_ok(Moose::POOP::Object->meta, 'Moose::POOP::Meta::Class'); - isa_ok(Moose::POOP::Object->meta, 'Moose::Meta::Class'); - isa_ok(Moose::POOP::Object->meta, 'Class::MOP::Class'); - - is(Moose::POOP::Object->meta->instance_metaclass, - 'Moose::POOP::Meta::Instance', + isa_ok(Moose::POOP::Object->meta, 'Moose::Meta::Class'); + isa_ok(Moose::POOP::Object->meta, 'Class::MOP::Class'); + + is(Moose::POOP::Object->meta->instance_metaclass, + 'Moose::POOP::Meta::Instance', '... got the right instance metaclass name'); - - isa_ok(Moose::POOP::Object->meta->get_meta_instance, 'Moose::POOP::Meta::Instance'); - + + isa_ok(Moose::POOP::Object->meta->get_meta_instance, 'Moose::POOP::Meta::Instance'); + my $base = Moose::POOP::Object->new; - isa_ok($base, 'Moose::POOP::Object'); - isa_ok($base, 'Moose::Object'); - + isa_ok($base, 'Moose::POOP::Object'); + isa_ok($base, 'Moose::Object'); + isa_ok($base->meta, 'Moose::POOP::Meta::Class'); - isa_ok($base->meta, 'Moose::Meta::Class'); - isa_ok($base->meta, 'Class::MOP::Class'); - - is($base->meta->instance_metaclass, - 'Moose::POOP::Meta::Instance', + isa_ok($base->meta, 'Moose::Meta::Class'); + isa_ok($base->meta, 'Class::MOP::Class'); + + is($base->meta->instance_metaclass, + 'Moose::POOP::Meta::Instance', '... got the right instance metaclass name'); - - isa_ok($base->meta->get_meta_instance, 'Moose::POOP::Meta::Instance'); + + isa_ok($base->meta->get_meta_instance, 'Moose::POOP::Meta::Instance'); } my $article_oid; @@ -246,35 +246,35 @@ my $article_ref; headline => 'Home Office Redecorated', summary => 'The home office was recently redecorated to match the new company colors', article => '...', - + author => Newswriter::Author->new( first_name => 'Truman', last_name => 'Capote' ), - + status => 'pending' ); } '... created my article successfully'; isa_ok($article, 'Newswriter::Article'); - isa_ok($article, 'Moose::POOP::Object'); - + isa_ok($article, 'Moose::POOP::Object'); + lives_ok { $article->start_date(DateTime->new(year => 2006, month => 6, day => 10)); $article->end_date(DateTime->new(year => 2006, month => 6, day => 17)); } '... add the article date-time stuff'; - + ## check some meta stuff - + isa_ok($article->meta, 'Moose::POOP::Meta::Class'); - isa_ok($article->meta, 'Moose::Meta::Class'); - isa_ok($article->meta, 'Class::MOP::Class'); - - is($article->meta->instance_metaclass, - 'Moose::POOP::Meta::Instance', + isa_ok($article->meta, 'Moose::Meta::Class'); + isa_ok($article->meta, 'Class::MOP::Class'); + + is($article->meta->instance_metaclass, + 'Moose::POOP::Meta::Instance', '... got the right instance metaclass name'); - - isa_ok($article->meta->get_meta_instance, 'Moose::POOP::Meta::Instance'); - + + isa_ok($article->meta->get_meta_instance, 'Moose::POOP::Meta::Instance'); + ok($article->oid, '... got a oid for the article'); $article_oid = $article->oid; @@ -286,8 +286,8 @@ my $article_ref; is($article->summary, 'The home office was recently redecorated to match the new company colors', '... got the right summary'); - is($article->article, '...', '... got the right article'); - + is($article->article, '...', '... got the right article'); + isa_ok($article->start_date, 'DateTime'); isa_ok($article->end_date, 'DateTime'); @@ -309,29 +309,29 @@ my $article2_ref; headline => 'Company wins Lottery', summary => 'An email was received today that informed the company we have won the lottery', article => 'WoW', - + author => Newswriter::Author->new( first_name => 'Katie', last_name => 'Couric' ), - + status => 'posted' ); } '... created my article successfully'; isa_ok($article2, 'Newswriter::Article'); isa_ok($article2, 'Moose::POOP::Object'); - + $article2_oid = $article2->oid; $article2_ref = "$article2"; - + is($article2->headline, 'Company wins Lottery', '... got the right headline'); is($article2->summary, 'An email was received today that informed the company we have won the lottery', '... got the right summary'); - is($article2->article, 'WoW', '... got the right article'); - + is($article2->article, 'WoW', '... got the right article'); + ok(!$article2->start_date, '... these two dates are unassigned'); ok(!$article2->end_date, '... these two dates are unassigned'); @@ -340,18 +340,18 @@ my $article2_ref; is($article2->author->last_name, 'Couric', '... got the right author last name'); is($article2->status, 'posted', '... got the right status'); - + ## orig-article - + my $article; lives_ok { $article = Newswriter::Article->new(oid => $article_oid); } '... (re)-created my article successfully'; isa_ok($article, 'Newswriter::Article'); - isa_ok($article, 'Moose::POOP::Object'); - + isa_ok($article, 'Moose::POOP::Object'); + is($article->oid, $article_oid, '... got a oid for the article'); - isnt($article_ref, "$article", '... got a new article instance'); + isnt($article_ref, "$article", '... got a new article instance'); is($article->headline, 'Home Office Redecorated', @@ -359,22 +359,22 @@ my $article2_ref; is($article->summary, 'The home office was recently redecorated to match the new company colors', '... got the right summary'); - is($article->article, '...', '... got the right article'); - + is($article->article, '...', '... got the right article'); + isa_ok($article->start_date, 'DateTime'); isa_ok($article->end_date, 'DateTime'); isa_ok($article->author, 'Newswriter::Author'); is($article->author->first_name, 'Truman', '... got the right author first name'); is($article->author->last_name, 'Capote', '... got the right author last name'); - + lives_ok { $article->author->first_name('Dan'); - $article->author->last_name('Rather'); + $article->author->last_name('Rather'); } '... changed the value ok'; - + is($article->author->first_name, 'Dan', '... got the changed author first name'); - is($article->author->last_name, 'Rather', '... got the changed author last name'); + is($article->author->last_name, 'Rather', '... got the changed author last name'); is($article->status, 'pending', '... got the right status'); } @@ -387,10 +387,10 @@ Moose::POOP::Meta::Instance->_reload_db(); $article = Newswriter::Article->new(oid => $article_oid); } '... (re)-created my article successfully'; isa_ok($article, 'Newswriter::Article'); - isa_ok($article, 'Moose::POOP::Object'); - + isa_ok($article, 'Moose::POOP::Object'); + is($article->oid, $article_oid, '... got a oid for the article'); - isnt($article_ref, "$article", '... got a new article instance'); + isnt($article_ref, "$article", '... got a new article instance'); is($article->headline, 'Home Office Redecorated', @@ -398,26 +398,26 @@ Moose::POOP::Meta::Instance->_reload_db(); is($article->summary, 'The home office was recently redecorated to match the new company colors', '... got the right summary'); - is($article->article, '...', '... got the right article'); - + is($article->article, '...', '... got the right article'); + isa_ok($article->start_date, 'DateTime'); isa_ok($article->end_date, 'DateTime'); isa_ok($article->author, 'Newswriter::Author'); is($article->author->first_name, 'Dan', '... got the changed author first name'); - is($article->author->last_name, 'Rather', '... got the changed author last name'); + is($article->author->last_name, 'Rather', '... got the changed author last name'); is($article->status, 'pending', '... got the right status'); - + my $article2; lives_ok { $article2 = Newswriter::Article->new(oid => $article2_oid); } '... (re)-created my article successfully'; isa_ok($article2, 'Newswriter::Article'); - isa_ok($article2, 'Moose::POOP::Object'); - + isa_ok($article2, 'Moose::POOP::Object'); + is($article2->oid, $article2_oid, '... got a oid for the article'); - isnt($article2_ref, "$article2", '... got a new article instance'); + isnt($article2_ref, "$article2", '... got a new article instance'); is($article2->headline, 'Company wins Lottery', @@ -425,8 +425,8 @@ Moose::POOP::Meta::Instance->_reload_db(); is($article2->summary, 'An email was received today that informed the company we have won the lottery', '... got the right summary'); - is($article2->article, 'WoW', '... got the right article'); - + is($article2->article, 'WoW', '... got the right article'); + ok(!$article2->start_date, '... these two dates are unassigned'); ok(!$article2->end_date, '... these two dates are unassigned'); @@ -434,7 +434,7 @@ Moose::POOP::Meta::Instance->_reload_db(); is($article2->author->first_name, 'Katie', '... got the right author first name'); is($article2->author->last_name, 'Couric', '... got the right author last name'); - is($article2->status, 'posted', '... got the right status'); - + is($article2->status, 'posted', '... got the right status'); + } diff --git a/t/200_examples/003_example.t b/t/200_examples/003_example.t index 9e1c530..1745839 100644 --- a/t/200_examples/003_example.t +++ b/t/200_examples/003_example.t @@ -19,36 +19,36 @@ sub Y { { package List; use Moose::Role; - + has '_list' => ( is => 'ro', - isa => 'ArrayRef', + isa => 'ArrayRef', init_arg => '::', default => sub { [] } ); - + sub head { (shift)->_list->[0] } sub tail { my $self = shift; $self->new( - '::' => [ - @{$self->_list}[1 .. $#{$self->_list}] + '::' => [ + @{$self->_list}[1 .. $#{$self->_list}] ] ); - } - + } + sub print { join ", " => @{$_[0]->_list}; - } - + } + package List::Immutable; use Moose::Role; - + requires 'head'; - requires 'tail'; - + requires 'tail'; + sub is_empty { not defined ($_[0]->head) } - + sub length { my $self = shift; (::Y(sub { @@ -60,38 +60,38 @@ sub Y { } }))->($self, 0); } - + sub apply { my ($self, $function) = @_; (::Y(sub { my $redo = shift; sub { my ($list, $func, $acc) = @_; - return $list->new('::' => $acc) + return $list->new('::' => $acc) if $list->is_empty; $redo->( - $list->tail, + $list->tail, $func, [ @{$acc}, $func->($list->head) ] ); } - }))->($self, $function, []); + }))->($self, $function, []); } - + package My::List1; use Moose; - + ::lives_ok { with 'List', 'List::Immutable'; } '... successfully composed roles together'; - + package My::List2; - use Moose; - + use Moose; + ::lives_ok { with 'List::Immutable', 'List'; - } '... successfully composed roles together'; - + } '... successfully composed roles together'; + } { @@ -102,7 +102,7 @@ sub Y { ok($coll->does('List::Immutable'), '... $coll does List::Immutable'); ok($coll->is_empty, '... we have an empty collection'); - is($coll->length, 0, '... we have a length of 1 for the collection'); + is($coll->length, 0, '... we have a length of 1 for the collection'); } { @@ -113,7 +113,7 @@ sub Y { ok($coll->does('List::Immutable'), '... $coll does List::Immutable'); ok($coll->is_empty, '... we have an empty collection'); - is($coll->length, 0, '... we have a length of 1 for the collection'); + is($coll->length, 0, '... we have a length of 1 for the collection'); } { @@ -124,15 +124,15 @@ sub Y { ok($coll->does('List::Immutable'), '... $coll does List::Immutable'); ok(!$coll->is_empty, '... we do not have an empty collection'); - is($coll->length, 10, '... we have a length of 10 for the collection'); - + is($coll->length, 10, '... we have a length of 10 for the collection'); + is($coll->print, '1, 2, 3, 4, 5, 6, 7, 8, 9, 10', '... got the right printed value'); my $coll2 = $coll->apply(sub { $_[0] * $_[0] }); isa_ok($coll2, 'My::List1'); - - is($coll->print, '1, 2, 3, 4, 5, 6, 7, 8, 9, 10', '... original is still the same'); - is($coll2->print, '1, 4, 9, 16, 25, 36, 49, 64, 81, 100', '... new collection is changed'); + + is($coll->print, '1, 2, 3, 4, 5, 6, 7, 8, 9, 10', '... original is still the same'); + is($coll2->print, '1, 4, 9, 16, 25, 36, 49, 64, 81, 100', '... new collection is changed'); } { @@ -143,15 +143,15 @@ sub Y { ok($coll->does('List::Immutable'), '... $coll does List::Immutable'); ok(!$coll->is_empty, '... we do not have an empty collection'); - is($coll->length, 10, '... we have a length of 10 for the collection'); - + is($coll->length, 10, '... we have a length of 10 for the collection'); + is($coll->print, '1, 2, 3, 4, 5, 6, 7, 8, 9, 10', '... got the right printed value'); my $coll2 = $coll->apply(sub { $_[0] * $_[0] }); isa_ok($coll2, 'My::List2'); - - is($coll->print, '1, 2, 3, 4, 5, 6, 7, 8, 9, 10', '... original is still the same'); - is($coll2->print, '1, 4, 9, 16, 25, 36, 49, 64, 81, 100', '... new collection is changed'); + + is($coll->print, '1, 2, 3, 4, 5, 6, 7, 8, 9, 10', '... original is still the same'); + is($coll2->print, '1, 4, 9, 16, 25, 36, 49, 64, 81, 100', '... new collection is changed'); } diff --git a/t/200_examples/004_example_w_DCS.t b/t/200_examples/004_example_w_DCS.t index e9edc2e..335a45e 100644 --- a/t/200_examples/004_example_w_DCS.t +++ b/t/200_examples/004_example_w_DCS.t @@ -7,8 +7,8 @@ use Test::More; =pod -This tests how well Moose type constraints -play with Declare::Constraints::Simple. +This tests how well Moose type constraints +play with Declare::Constraints::Simple. Pretty well if I do say so myself :) @@ -16,8 +16,8 @@ Pretty well if I do say so myself :) BEGIN { eval "use Declare::Constraints::Simple;"; - plan skip_all => "Declare::Constraints::Simple is required for this test" if $@; - plan tests => 9; + plan skip_all => "Declare::Constraints::Simple is required for this test" if $@; + plan tests => 9; } use Test::Exception; @@ -41,7 +41,7 @@ use Test::Exception; is => 'rw', isa => 'HashOfArrayOfObjects', ); - + # inline the constraints as anon-subtypes has 'baz' => ( is => 'rw', @@ -54,7 +54,7 @@ use Test::Exception; my $hash_of_arrays_of_objs = { foo1 => [ Bar->new ], - foo2 => [ Bar->new, Bar->new ], + foo2 => [ Bar->new, Bar->new ], }; my $array_of_ints = [ 1 .. 10 ]; @@ -64,7 +64,7 @@ lives_ok { $foo = Foo->new( 'bar' => $hash_of_arrays_of_objs, 'baz' => $array_of_ints, - ); + ); } '... construction succeeded'; isa_ok($foo, 'Foo'); diff --git a/t/200_examples/005_example_w_TestDeep.t b/t/200_examples/005_example_w_TestDeep.t index cd33fa9..47bef7e 100644 --- a/t/200_examples/005_example_w_TestDeep.t +++ b/t/200_examples/005_example_w_TestDeep.t @@ -7,18 +7,18 @@ use Test::More; =pod -This tests how well Moose type constraints -play with Test::Deep. +This tests how well Moose type constraints +play with Test::Deep. -Its not as pretty as Declare::Constraints::Simple, +Its not as pretty as Declare::Constraints::Simple, but it is not completely horrid either. =cut BEGIN { eval "use Test::Deep;"; - plan skip_all => "Test::Deep is required for this test" if $@; - plan tests => 5; + plan skip_all => "Test::Deep is required for this test" if $@; + plan tests => 5; } use Test::Exception; @@ -31,11 +31,11 @@ use Test::Exception; use Test::Deep qw[ eq_deeply array_each subhashof ignore ]; - + # define your own type ... - type 'ArrayOfHashOfBarsAndRandomNumbers' + type 'ArrayOfHashOfBarsAndRandomNumbers' => where { - eq_deeply($_, + eq_deeply($_, array_each( subhashof({ bar => Test::Deep::isa('Bar'), @@ -43,8 +43,8 @@ use Test::Exception; }) ) ) - }; - + }; + has 'bar' => ( is => 'rw', isa => 'ArrayOfHashOfBarsAndRandomNumbers', @@ -56,12 +56,12 @@ use Test::Exception; my $array_of_hashes = [ { bar => Bar->new, random_number => 10 }, - { bar => Bar->new }, + { bar => Bar->new }, ]; my $foo; lives_ok { - $foo = Foo->new('bar' => $array_of_hashes); + $foo = Foo->new('bar' => $array_of_hashes); } '... construction succeeded'; isa_ok($foo, 'Foo'); diff --git a/t/200_examples/006_example_Protomoose.t b/t/200_examples/006_example_Protomoose.t index 123d785..8b3d3cf 100644 --- a/t/200_examples/006_example_Protomoose.t +++ b/t/200_examples/006_example_Protomoose.t @@ -7,10 +7,10 @@ use Test::More tests => 28; =pod -This is an example of making Moose behave +This is an example of making Moose behave more like a prototype based object system. -Why? +Why? Well cause merlyn asked if it could :) @@ -22,9 +22,9 @@ Well cause merlyn asked if it could :) { package ProtoMoose::Meta::Instance; use Moose; - + BEGIN { extends 'Moose::Meta::Instance' }; - + # NOTE: # do not let things be inlined by # the attribute or accessor generator @@ -34,18 +34,18 @@ Well cause merlyn asked if it could :) { package ProtoMoose::Meta::Method::Accessor; use Moose; - + BEGIN { extends 'Moose::Meta::Method::Accessor' }; - - # customize the accessors to always grab + + # customize the accessors to always grab # the correct instance in the accessors - + sub find_instance { my ($self, $candidate, $accessor_type) = @_; - + my $instance = $candidate; my $attr = $self->associated_attribute; - + # if it is a class calling it ... unless (blessed($instance)) { # then grab the class prototype @@ -53,49 +53,49 @@ Well cause merlyn asked if it could :) } # if its an instance ... else { - # and there is no value currently - # associated with the instance and + # and there is no value currently + # associated with the instance and # we are trying to read it, then ... if ($accessor_type eq 'r' && !defined($attr->get_value($instance))) { - # again, defer the prototype in + # again, defer the prototype in # the class in which is was defined $instance = $attr->associated_class->prototype_instance; } - # otherwise, you want to assign + # otherwise, you want to assign # to your local copy ... } return $instance; } - + sub _generate_accessor_method { my $self = shift; - my $attr = $self->associated_attribute; + my $attr = $self->associated_attribute; return sub { if (scalar(@_) == 2) { $attr->set_value( - $self->find_instance($_[0], 'w'), + $self->find_instance($_[0], 'w'), $_[1] ); - } + } $attr->get_value($self->find_instance($_[0], 'r')); }; } sub _generate_reader_method { my $self = shift; - my $attr = $self->associated_attribute; + my $attr = $self->associated_attribute; return sub { confess "Cannot assign a value to a read-only accessor" if @_ > 1; $attr->get_value($self->find_instance($_[0], 'r')); - }; + }; } sub _generate_writer_method { my $self = shift; - my $attr = $self->associated_attribute; + my $attr = $self->associated_attribute; return sub { $attr->set_value( - $self->find_instance($_[0], 'w'), + $self->find_instance($_[0], 'w'), $_[1] ); }; @@ -103,14 +103,14 @@ Well cause merlyn asked if it could :) # deal with these later ... sub generate_predicate_method {} - sub generate_clearer_method {} - + sub generate_clearer_method {} + } { package ProtoMoose::Meta::Attribute; use Moose; - + BEGIN { extends 'Moose::Meta::Attribute' }; sub accessor_metaclass { 'ProtoMoose::Meta::Method::Accessor' } @@ -119,9 +119,9 @@ Well cause merlyn asked if it could :) { package ProtoMoose::Meta::Class; use Moose; - + BEGIN { extends 'Moose::Meta::Class' }; - + has 'prototype_instance' => ( is => 'rw', isa => 'Object', @@ -129,41 +129,41 @@ Well cause merlyn asked if it could :) lazy => 1, default => sub { (shift)->new_object } ); - + sub initialize { # NOTE: - # I am not sure why 'around' does + # I am not sure why 'around' does # not work here, have to investigate # it later - SL - (shift)->SUPER::initialize(@_, + (shift)->SUPER::initialize(@_, instance_metaclass => 'ProtoMoose::Meta::Instance', - attribute_metaclass => 'ProtoMoose::Meta::Attribute', + attribute_metaclass => 'ProtoMoose::Meta::Attribute', ); } - + around 'construct_instance' => sub { my $next = shift; my $self = shift; # NOTE: # we actually have to do this here - # to tie-the-knot, if you take it - # out, then you get deep recursion + # to tie-the-knot, if you take it + # out, then you get deep recursion # several levels deep :) - $self->prototype_instance($next->($self, @_)) + $self->prototype_instance($next->($self, @_)) unless $self->has_prototypical_instance; return $self->prototype_instance; }; - + } { package ProtoMoose::Object; use metaclass 'ProtoMoose::Meta::Class'; use Moose; - + sub new { - my $prototype = blessed($_[0]) - ? $_[0] + my $prototype = blessed($_[0]) + ? $_[0] : $_[0]->meta->prototype_instance; my (undef, %params) = @_; my $self = $prototype->meta->clone_object($prototype, %params); @@ -178,18 +178,18 @@ Well cause merlyn asked if it could :) { package Foo; use Moose; - + extends 'ProtoMoose::Object'; - + has 'bar' => (is => 'rw'); } { package Bar; use Moose; - + extends 'Foo'; - + has 'baz' => (is => 'rw'); } @@ -199,16 +199,16 @@ Well cause merlyn asked if it could :) ## Check that metaclasses are working/inheriting properly foreach my $class (qw/ProtoMoose::Object Foo Bar/) { - isa_ok($class->meta, - 'ProtoMoose::Meta::Class', + isa_ok($class->meta, + 'ProtoMoose::Meta::Class', '... got the right metaclass for ' . $class . ' ->'); - is($class->meta->instance_metaclass, - 'ProtoMoose::Meta::Instance', + is($class->meta->instance_metaclass, + 'ProtoMoose::Meta::Instance', '... got the right instance meta for ' . $class); - is($class->meta->attribute_metaclass, - 'ProtoMoose::Meta::Attribute', + is($class->meta->attribute_metaclass, + 'ProtoMoose::Meta::Attribute', '... got the right attribute meta for ' . $class); } @@ -222,13 +222,13 @@ isa_ok($foo_prototype, 'Foo'); $foo_prototype->bar(100); is($foo_prototype->bar, 100, '... got the value stored in the prototype'); -# the "class" defers to the -# the prototype when asked +# the "class" defers to the +# the prototype when asked # about attributes is(Foo->bar, 100, '... got the value stored in the prototype (through the Foo class)'); -# now make an instance, which -# is basically a clone of the +# now make an instance, which +# is basically a clone of the # prototype my $foo = Foo->new; isa_ok($foo, 'Foo'); @@ -239,8 +239,8 @@ isnt($foo, $foo_prototype, '... got a new instance of Foo'); # but it has the same values ... is($foo->bar, 100, '... got the value stored in the instance (inherited from the prototype)'); -# we can even change the values -# in the instance +# we can even change the values +# in the instance $foo->bar(300); is($foo->bar, 300, '... got the value stored in the instance (overwriting the one inherited from the prototype)'); @@ -248,10 +248,10 @@ is($foo->bar, 300, '... got the value stored in the instance (overwriting the on is($foo_prototype->bar, 100, '... got the value stored in the prototype'); is(Foo->bar, 100, '... got the value stored in the prototype (through the Foo class)'); -## subclasses +## subclasses # now we can check that the subclass -# will seek out the correct prototypical +# will seek out the correct prototypical # value from it's "parent" is(Bar->bar, 100, '... got the value stored in the Foo prototype (through the Bar class)'); @@ -273,8 +273,8 @@ is($bar->baz, 50, '... got the value stored in the instance (inherited from the $bar->bar(200); is($bar->bar, 200, '... got the value stored in the instance (overriding the one inherited from the Foo prototype)'); -# and all our original and -# prototypical values are still +# and all our original and +# prototypical values are still # the same is($foo->bar, 300, '... still got the original value stored in the instance (inherited from the prototype)'); is(Foo->bar, 100, '... still got the original value stored in the prototype (through the Foo class)'); diff --git a/t/200_examples/007_Child_Parent_attr_inherit.t b/t/200_examples/007_Child_Parent_attr_inherit.t index 07f9426..a2c8e92 100644 --- a/t/200_examples/007_Child_Parent_attr_inherit.t +++ b/t/200_examples/007_Child_Parent_attr_inherit.t @@ -7,7 +7,7 @@ use Test::More tests => 23; =pod -Some examples of triggers and how they can +Some examples of triggers and how they can be used to manage parent-child relationships. =cut diff --git a/t/200_examples/008_record_set_iterator.t b/t/200_examples/008_record_set_iterator.t index 00eac6b..0ae80f3 100644 --- a/t/200_examples/008_record_set_iterator.t +++ b/t/200_examples/008_record_set_iterator.t @@ -11,32 +11,32 @@ use Test::Exception; { package Record; use Moose; - + has 'first_name' => (is => 'ro', isa => 'Str'); - has 'last_name' => (is => 'ro', isa => 'Str'); - + has 'last_name' => (is => 'ro', isa => 'Str'); + package RecordSet; use Moose; - + has 'data' => ( is => 'ro', - isa => 'ArrayRef[Record]', + isa => 'ArrayRef[Record]', default => sub { [] }, ); - + has 'index' => ( is => 'rw', - isa => 'Int', + isa => 'Int', default => sub { 0 }, ); - + sub next { my $self = shift; my $i = $self->index; $self->index($i + 1); return $self->data->[$i]; } - + package RecordSetIterator; use Moose; @@ -45,13 +45,13 @@ use Test::Exception; isa => 'RecordSet', ); - # list the fields you want to + # list the fields you want to # fetch from the current record my @fields = Record->meta->get_attribute_list; has 'current_record' => ( is => 'rw', - isa => 'Record', + isa => 'Record', lazy => 1, default => sub { my $self = shift; @@ -59,23 +59,23 @@ use Test::Exception; }, trigger => sub { my $self = shift; - # whenever this attribute is - # updated, it will clear all + # whenever this attribute is + # updated, it will clear all # the fields for you. $self->$_() for map { '_clear_' . $_ } @fields; } ); - # define the attributes + # define the attributes # for all the fields. for my $field (@fields) { has $field => ( is => 'ro', - isa => 'Any', + isa => 'Any', lazy => 1, - default => sub { + default => sub { my $self = shift; - # fetch the value from + # fetch the value from # the current record $self->current_record->$field(); }, @@ -93,8 +93,8 @@ use Test::Exception; my $rs = RecordSet->new( data => [ Record->new(first_name => 'Bill', last_name => 'Smith'), - Record->new(first_name => 'Bob', last_name => 'Jones'), - Record->new(first_name => 'Jim', last_name => 'Johnson'), + Record->new(first_name => 'Bob', last_name => 'Jones'), + Record->new(first_name => 'Jim', last_name => 'Johnson'), ] ); isa_ok($rs, 'RecordSet'); diff --git a/t/300_immutable/002_apply_roles_to_immutable.t b/t/300_immutable/002_apply_roles_to_immutable.t index e373311..718c6bd 100644 --- a/t/300_immutable/002_apply_roles_to_immutable.t +++ b/t/300_immutable/002_apply_roles_to_immutable.t @@ -11,8 +11,8 @@ use Test::Exception; { package My::Role; use Moose::Role; - - around 'baz' => sub { + + around 'baz' => sub { my $next = shift; 'My::Role::baz(' . $next->(@_) . ')'; }; @@ -21,9 +21,9 @@ use Test::Exception; { package Foo; use Moose; - + sub baz { 'Foo::baz' } - + __PACKAGE__->meta->make_immutable(debug => 0); } diff --git a/t/300_immutable/003_immutable_meta_class.t b/t/300_immutable/003_immutable_meta_class.t index d8b1c75..c53aae3 100644 --- a/t/300_immutable/003_immutable_meta_class.t +++ b/t/300_immutable/003_immutable_meta_class.t @@ -15,13 +15,13 @@ use Test::Exception; extends 'Moose::Meta::Class'; - has 'meta_size' => ( + has 'meta_size' => ( is => 'rw', isa => 'Int', ); } -lives_ok { - My::Meta->meta()->make_immutable(debug => 0) +lives_ok { + My::Meta->meta()->make_immutable(debug => 0) } '... can make a meta class immutable'; diff --git a/t/300_immutable/004_inlined_constructors_n_types.t b/t/300_immutable/004_inlined_constructors_n_types.t index 9f276d6..587a3a8 100644 --- a/t/300_immutable/004_inlined_constructors_n_types.t +++ b/t/300_immutable/004_inlined_constructors_n_types.t @@ -9,8 +9,8 @@ use Test::Exception; =pod This tests to make sure that the inlined constructor -has all the type constraints in order, even in the -cases when there is no type constraint available, such +has all the type constraints in order, even in the +cases when there is no type constraint available, such as with a Class::MOP::Attribute object. =cut @@ -19,10 +19,10 @@ as with a Class::MOP::Attribute object. package Foo; use Moose; use Moose::Util::TypeConstraints; - + coerce 'Int' => from 'Str' => via { length $_ ? $_ : 69 }; - has 'foo' => (is => 'rw', isa => 'Int'); + has 'foo' => (is => 'rw', isa => 'Int'); has 'baz' => (is => 'rw', isa => 'Int'); has 'zot' => (is => 'rw', isa => 'Int', init_arg => undef); has 'moo' => (is => 'rw', isa => 'Int', coerce => 1, default => '', required => 1); diff --git a/t/300_immutable/007_immutable_trigger_from_constructor.t b/t/300_immutable/007_immutable_trigger_from_constructor.t index cab557f..d02d5c9 100644 --- a/t/300_immutable/007_immutable_trigger_from_constructor.t +++ b/t/300_immutable/007_immutable_trigger_from_constructor.t @@ -16,12 +16,12 @@ use Test::Exception; has 'foo' => (is => 'rw', isa => 'Maybe[Str]', trigger => sub { die "Pulling the Foo trigger\n" }); - - has 'bar' => (is => 'rw', isa => 'Maybe[Str]'); - + + has 'bar' => (is => 'rw', isa => 'Maybe[Str]'); + has 'baz' => (is => 'rw', isa => 'Maybe[Str]', trigger => sub { die "Pulling the Baz trigger\n" - }); + }); __PACKAGE__->meta->make_immutable; #(debug => 1); diff --git a/t/300_immutable/009_buildargs.t b/t/300_immutable/009_buildargs.t index 6c1ca33..b8a7527 100644 --- a/t/300_immutable/009_buildargs.t +++ b/t/300_immutable/009_buildargs.t @@ -10,7 +10,7 @@ use Test::More tests => 14; use Moose; has bar => ( is => "rw" ); - has baz => ( is => "rw" ); + has baz => ( is => "rw" ); sub BUILDARGS { my ( $self, @args ) = @_; @@ -24,7 +24,7 @@ use Test::More tests => 14; use Moose; extends qw(Foo); - + __PACKAGE__->meta->make_immutable; } @@ -41,7 +41,7 @@ foreach my $class qw(Foo Bar) { my $o = $class->new(42, baz => 47); is($o->bar, 42, '... got the right bar'); is($o->baz, 47, '... got the right bar'); - } + } } diff --git a/t/500_test_moose/003_test_moose_has_attribute_ok.t b/t/500_test_moose/003_test_moose_has_attribute_ok.t index e8e3869..957ad33 100644 --- a/t/500_test_moose/003_test_moose_has_attribute_ok.t +++ b/t/500_test_moose/003_test_moose_has_attribute_ok.t @@ -13,17 +13,17 @@ BEGIN { { package Foo; use Moose; - + has 'foo'; } { package Bar; use Moose; - + extends 'Foo'; - - has 'bar'; + + has 'bar'; } diff --git a/t/600_todo_tests/001_exception_reflects_failed_constraint.t b/t/600_todo_tests/001_exception_reflects_failed_constraint.t index db7fe69..8e89d9a 100644 --- a/t/600_todo_tests/001_exception_reflects_failed_constraint.t +++ b/t/600_todo_tests/001_exception_reflects_failed_constraint.t @@ -11,7 +11,7 @@ use Test::More tests => 4; use Test::Exception; BEGIN { - use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Util::TypeConstraints'); } lives_ok { diff --git a/t/600_todo_tests/002_various_role_shit.t b/t/600_todo_tests/002_various_role_shit.t index 7a44274..62e978e 100644 --- a/t/600_todo_tests/002_various_role_shit.t +++ b/t/600_todo_tests/002_various_role_shit.t @@ -10,9 +10,9 @@ sub req_or_has ($$) { my ( $role, $method ) = @_; local $Test::Builder::Level = $Test::Builder::Level + 1; if ( $role ) { - ok( - $role->has_method($method) || $role->requires_method($method), - $role->name . " has or requires method $method" + ok( + $role->has_method($method) || $role->requires_method($method), + $role->name . " has or requires method $method" ); } else { fail("role has or requires method $method"); @@ -122,12 +122,12 @@ sub req_or_has ($$) { package Tree; use Moose::Role; - + has bark => ( is => "rw" ); package Dog; use Moose::Role; - + sub bark { warn "woof!" }; package EntPuppy; diff --git a/t/600_todo_tests/003_immutable_n_around.t b/t/600_todo_tests/003_immutable_n_around.t index a0ae5d5..2364a5e 100644 --- a/t/600_todo_tests/003_immutable_n_around.t +++ b/t/600_todo_tests/003_immutable_n_around.t @@ -31,7 +31,7 @@ use Test::More tests => 20; package Zoink; use Moose; - + extends qw(Gorch); } diff --git a/t/600_todo_tests/005_moose_and_threads.t b/t/600_todo_tests/005_moose_and_threads.t index b56a90f..be3dd26 100644 --- a/t/600_todo_tests/005_moose_and_threads.t +++ b/t/600_todo_tests/005_moose_and_threads.t @@ -15,21 +15,21 @@ See this for some details: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=476579 Here is the basic test case, it segfaults, so I am going -to leave it commented out. Basically it seems that there -is some bad interaction between the ??{} construct that +to leave it commented out. Basically it seems that there +is some bad interaction between the ??{} construct that is used in the "parser" for type definitions and threading so probably the fix would involve removing the ??{} usage for something else. -use threads; +use threads; { - package Foo; - use Moose; - has "bar" => (is => 'rw', isa => "Str | Num"); + package Foo; + use Moose; + has "bar" => (is => 'rw', isa => "Str | Num"); } -my $thr = threads->create(sub {}); +my $thr = threads->create(sub {}); $thr->join(); =cut