Merge 'trunk' into 'method_generation_cleanup'
Matt S Trout [Fri, 12 Dec 2008 00:49:50 +0000 (00:49 +0000)]
r26263@agaton (orig r6884):  marcus | 2008-12-05 13:11:32 +0000
Bump dependency for MoreUtils
r26266@agaton (orig r6887):  marcus | 2008-12-05 14:53:43 +0000
Revert unwanted MMM::Accessor change
r26267@agaton (orig r6888):  autarch | 2008-12-05 14:59:04 +0000
update MANIFEST for test changes
r26268@agaton (orig r6889):  autarch | 2008-12-05 15:01:31 +0000
Don't call get_all_package_symbols in list context

r26269@agaton (orig r6890):  autarch | 2008-12-05 16:48:07 +0000
Spell coerce like a proper Merkan

r26272@agaton (orig r6893):  autarch | 2008-12-05 16:57:18 +0000
Handle defaults with quote-breaking values correctly by using
quotemeta. Added tests for this.
r26278@agaton (orig r6899):  autarch | 2008-12-05 19:21:54 +0000
bump version and update Changes
r26281@agaton (orig r6902):  autarch | 2008-12-05 19:30:39 +0000
require latest CMOP
r26288@agaton (orig r6909):  jnapiorkowski | 2008-12-05 21:49:20 +0000
changes to the way Moose::Meta::TypeConstraint passed arguments to the compiled type constraint coderef so that I can support MooseX::Types::Structured::Optional
r26289@agaton (orig r6910):  thepler | 2008-12-05 22:36:27 +0000
more tests for metaclass traits with required attributes
r26535@agaton (orig r6926):  sartak | 2008-12-07 01:29:56 +0000
 r76625@onn:  sartak | 2008-12-06 20:26:31 -0500
 Failing test for passing parameters to role->create (fix will go in Class::MOP)

r26557@agaton (orig r6948):  autarch | 2008-12-07 18:45:18 +0000
Remove an unneeded "the"

r26559@agaton (orig r6950):  autarch | 2008-12-07 18:50:19 +0000
Fix some unintended bugs in the "standard" P5 code.

r26560@agaton (orig r6951):  autarch | 2008-12-07 18:53:41 +0000
Small tweaks to some of the text.

r26586@agaton (orig r6977):  autarch | 2008-12-08 17:09:21 +0000
Add changes for 0.63

r26589@agaton (orig r6980):  autarch | 2008-12-08 17:11:18 +0000
update manifest
r26590@agaton (orig r6981):  autarch | 2008-12-08 17:12:33 +0000
No point in keeping this todo test for parameterized roles in the
Moose distro now that we have an MX module for it.
r26591@agaton (orig r6982):  autarch | 2008-12-08 17:14:17 +0000
bump version to 0.63
r26599@agaton (orig r6990):  autarch | 2008-12-08 22:21:44 +0000
I was channeling stevan and misspeled declaratively

r26600@agaton (orig r6991):  perigrin | 2008-12-08 22:25:12 +0000
zero or more Roles
r26628@agaton (orig r7019):  sartak | 2008-12-09 06:39:26 +0000
 r76787@onn:  sartak | 2008-12-09 01:39:11 -0500
 Always inline predicate and clearer methods

r26693@agaton (orig r7050):  autarch | 2008-12-11 06:23:32 +0000
Doh, we really need CMOP 0.72

53 files changed:
Changes
MANIFEST
Makefile.PL
README
lib/Moose.pm
lib/Moose/Error/Confess.pm
lib/Moose/Error/Croak.pm
lib/Moose/Error/Default.pm
lib/Moose/Exporter.pm
lib/Moose/Intro.pod
lib/Moose/Meta/Attribute.pm
lib/Moose/Meta/Class.pm
lib/Moose/Meta/Instance.pm
lib/Moose/Meta/Method.pm
lib/Moose/Meta/Method/Accessor.pm
lib/Moose/Meta/Method/Augmented.pm
lib/Moose/Meta/Method/Constructor.pm
lib/Moose/Meta/Method/Delegation.pm
lib/Moose/Meta/Method/Destructor.pm
lib/Moose/Meta/Method/Overriden.pm
lib/Moose/Meta/Role.pm
lib/Moose/Meta/Role/Application.pm
lib/Moose/Meta/Role/Application/RoleSummation.pm
lib/Moose/Meta/Role/Application/ToClass.pm
lib/Moose/Meta/Role/Application/ToInstance.pm
lib/Moose/Meta/Role/Application/ToRole.pm
lib/Moose/Meta/Role/Composite.pm
lib/Moose/Meta/Role/Method.pm
lib/Moose/Meta/Role/Method/Required.pm
lib/Moose/Meta/TypeCoercion.pm
lib/Moose/Meta/TypeCoercion/Union.pm
lib/Moose/Meta/TypeConstraint.pm
lib/Moose/Meta/TypeConstraint/Class.pm
lib/Moose/Meta/TypeConstraint/Enum.pm
lib/Moose/Meta/TypeConstraint/Parameterizable.pm
lib/Moose/Meta/TypeConstraint/Parameterized.pm
lib/Moose/Meta/TypeConstraint/Registry.pm
lib/Moose/Meta/TypeConstraint/Role.pm
lib/Moose/Meta/TypeConstraint/Union.pm
lib/Moose/Object.pm
lib/Moose/Role.pm
lib/Moose/Unsweetened.pod
lib/Moose/Util.pm
lib/Moose/Util/MetaRole.pm
lib/Moose/Util/TypeConstraints.pm
lib/Moose/Util/TypeConstraints/OptimizedConstraints.pm
lib/Test/Moose.pm
lib/oose.pm
t/030_roles/030_role_parameterized.t [deleted file]
t/030_roles/037_create_role_subclass.t [new file with mode: 0644]
t/050_metaclasses/019_create_anon_with_required_attr.t
t/300_immutable/004_inlined_constructors_n_types.t
t/300_immutable/012_default_values.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index b2664f6..5afd507 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,15 @@
 Revision history for Perl extension Moose
 
-0.63
+0.64
+    * Moose::Meta::Method::Accessor
+      - Always inline predicate and clearer methods (Sartak)
+
+0.63 Mon, December 8, 2008
+    * Moose::Unsweetened
+      - Some small grammar tweaks and bug fixes in non-Moose example
+        code. (Dave Rolsky)
+
+0.62_02 Fri, December 5, 2008
     * Moose::Meta::Role::Application::ToClass
       - When a class does not provide all of a role's required
         methods, the error thrown now mentions all of the missing
@@ -14,6 +23,9 @@ Revision history for Perl extension Moose
         inlining anyway, pass "replace_constructor => 1" to
         make_immutable. Addresses RT #40968, reported by Jon
         Swartz. (Dave Rolsky)
+      - The quoting of default values could be broken if the default
+        contained a single quote ('). Now we use quotemeta to escape
+        anything potentially dangerous in the defaults. (Dave Rolsky)
 
 0.62_01 Wed, December 3, 2008
     * Moose::Object
index 0c33453..b1a2daf 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -165,13 +165,13 @@ t/030_roles/023_role_composition_attributes.t
 t/030_roles/024_role_composition_methods.t
 t/030_roles/025_role_composition_override.t
 t/030_roles/026_role_composition_method_mods.t
-t/030_roles/030_role_parameterized.t
 t/030_roles/031_roles_applied_in_create.t
 t/030_roles/032_roles_and_method_cloning.t
 t/030_roles/033_role_exclusion_and_alias_bug.t
 t/030_roles/034_create_role.t
 t/030_roles/035_anonymous_roles.t
 t/030_roles/036_free_anonymous_roles.t
+t/030_roles/037_create_role_subclass.t
 t/040_type_constraints/001_util_type_constraints.t
 t/040_type_constraints/002_util_type_constraints_export.t
 t/040_type_constraints/003_util_std_type_constraints.t
@@ -249,10 +249,12 @@ t/300_immutable/002_apply_roles_to_immutable.t
 t/300_immutable/003_immutable_meta_class.t
 t/300_immutable/004_inlined_constructors_n_types.t
 t/300_immutable/005_multiple_demolish_inline.t
-t/300_immutable/006_immutable_nonmoose_subclass.t
 t/300_immutable/007_immutable_trigger_from_constructor.t
 t/300_immutable/008_immutable_constructor_error.t
 t/300_immutable/009_buildargs.t
+t/300_immutable/010_constructor_is_not_moose.t
+t/300_immutable/011_constructor_is_wrapped.t
+t/300_immutable/012_default_values.t
 t/400_moose_util/001_moose_util.t
 t/400_moose_util/002_moose_util_does_role.t
 t/400_moose_util/003_moose_util_search_class_by_role.t
@@ -264,7 +266,6 @@ t/500_test_moose/004_test_moose_meta_ok.t
 t/600_todo_tests/001_exception_reflects_failed_constraint.t
 t/600_todo_tests/002_various_role_shit.t
 t/600_todo_tests/003_immutable_n_around.t
-t/600_todo_tests/004_inlined_constructor_modified_new.t
 t/600_todo_tests/005_moose_and_threads.t
 t/lib/Bar.pm
 t/lib/Foo.pm
index c3c4137..34efc5c 100644 (file)
@@ -12,8 +12,8 @@ license 'perl';
 requires 'perl'             => '5.008';
 requires 'Scalar::Util'     => '1.19';
 requires 'Carp';
-requires 'Class::MOP'       => '0.71_01';
-requires 'List::MoreUtils';
+requires 'Class::MOP'       => '0.72';
+requires 'List::MoreUtils'  => '0.12';
 requires 'Sub::Exporter'    => '0.972';
 requires 'Task::Weaken'     => '0';
 
diff --git a/README b/README
index 1f66b48..e668f17 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Moose version 0.62_01
+Moose version 0.63
 ===========================
 
 See the individual module documentation for more information
index 2c00224..43432c2 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 
 use 5.008;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -15,7 +15,7 @@ use Carp         'confess', 'croak', 'cluck';
 
 use Moose::Exporter;
 
-use Class::MOP 0.71;
+use Class::MOP 0.72;
 
 use Moose::Meta::Class;
 use Moose::Meta::TypeConstraint;
index 145f59b..d05ce8c 100644 (file)
@@ -3,7 +3,7 @@ package Moose::Error::Confess;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 5aeb87b..1fb6a0c 100644 (file)
@@ -3,7 +3,7 @@ package Moose::Error::Croak;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 398667d..67f6245 100644 (file)
@@ -3,7 +3,7 @@ package Moose::Error::Default;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 80dad46..40e98b3 100644 (file)
@@ -3,7 +3,7 @@ package Moose::Exporter;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 5090f51..57472de 100644 (file)
@@ -14,7 +14,7 @@ language, and you don't care how they are implemented.
 
 Moose aims to do the same thing for Perl 5 OO. We can't actually
 create new keywords, but we do offer "sugar" that looks a lot like
-them. More importantly, with Moose, you I<declaritively define> your
+them. More importantly, with Moose, you I<declaratively define> your
 class, without needing to know about blessed hashrefs, accessor
 methods, and so on.
 
@@ -139,7 +139,7 @@ A class I<has> zero or more B<method modifiers>. These modifiers can
 apply to its own methods or methods that are inherited from its
 ancestors.
 
-A class may I<do> one or more B<roles>.
+A class may I<do> zero or more B<roles>.
 
 A class I<has> a B<constructor> and a B<destructor>. These are
 provided for you "for free" by Moose.
@@ -343,7 +343,7 @@ With Moose, you get well-defined declaration and introspection.
 Hand-written accessor methods, symbol table hackery, or a helper
 module like C<Class::Accessor>.
 
-With Moose, these are declaritively defined, and distinct from
+With Moose, these are declaratively defined, and distinct from
 methods.
 
 =item * Method
@@ -531,7 +531,7 @@ on and read the Meta and Extending recipes, but those are mostly there
 for people who want to be Moose wizards and change how Moose works.
 
 If you want to see how Moose would translate directly old school Perl
-5 OO code, check out the L<Moose::Unsweetened>.
+5 OO code, check out L<Moose::Unsweetened>.
 
 =head1 AUTHOR
 
index 0409a90..1f7e017 100644 (file)
@@ -7,7 +7,7 @@ use warnings;
 use Scalar::Util 'blessed', 'weaken';
 use overload     ();
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 our $AUTHORITY = 'cpan:STEVAN';
 
 use Moose::Meta::Method::Accessor;
index 61f339f..9e3e1df 100644 (file)
@@ -11,7 +11,7 @@ use List::Util qw( first );
 use List::MoreUtils qw( any all uniq );
 use Scalar::Util 'weaken', 'blessed';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index b8eaa68..2050411 100644 (file)
@@ -4,7 +4,7 @@ package Moose::Meta::Instance;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 1475dab..9685215 100644 (file)
@@ -3,7 +3,7 @@ package Moose::Meta::Method;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index d93e080..3d40db8 100644 (file)
@@ -4,7 +4,7 @@ package Moose::Meta::Method::Accessor;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -113,6 +113,8 @@ sub _value_needs_copy {
 sub generate_reader_method { shift->generate_reader_method_inline(@_) }
 sub generate_writer_method { shift->generate_writer_method_inline(@_) }
 sub generate_accessor_method { shift->generate_accessor_method_inline(@_) }
+sub generate_predicate_method { shift->generate_predicate_method_inline(@_) }
+sub generate_clearer_method { shift->generate_clearer_method_inline(@_) }
 
 sub _inline_pre_body  { '' }
 sub _inline_post_body { '' }
@@ -313,6 +315,10 @@ role in the optimization strategy we are currently following.
 
 =item B<generate_writer_method>
 
+=item B<generate_predicate_method>
+
+=item B<generate_clearer_method>
+
 =item B<generate_accessor_method_inline>
 
 =item B<generate_reader_method_inline>
index c533a32..10b1707 100644 (file)
@@ -3,7 +3,7 @@ package Moose::Meta::Method::Augmented;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index a52937b..e420b5a 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 
 use Scalar::Util 'blessed', 'weaken', 'looks_like_number';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 our $AUTHORITY = 'cpan:STEVAN';
 
 use base 'Moose::Meta::Method',
@@ -389,10 +389,7 @@ sub _generate_default_value {
         return '$attrs->[' . $index . ']->default($instance)';
     }
     else {
-        my $default = $attr->default;
-        # make sure to quote strings ...
-        return "'$default'";
-        
+        return q{"} . quotemeta( $attr->default ) . q{"};
     }
 }
 
@@ -419,6 +416,8 @@ not particularly useful.
 
 =item B<new>
 
+=item B<can_be_inlined>
+
 =item B<attributes>
 
 =item B<meta_instance>
index 0852f7e..d08d358 100644 (file)
@@ -7,7 +7,7 @@ use warnings;
 use Carp         'confess';
 use Scalar::Util 'blessed', 'weaken';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 018bb29..e8687f2 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 
 use Scalar::Util 'blessed', 'weaken';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 2800578..3100d58 100644 (file)
@@ -3,7 +3,7 @@ package Moose::Meta::Method::Overriden;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 463951b..dea001d 100644 (file)
@@ -8,7 +8,7 @@ use metaclass;
 use Scalar::Util 'blessed';
 use Carp         'confess';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -311,10 +311,10 @@ sub get_method_map {
     my $role_name        = $self->name;
     my $method_metaclass = $self->method_metaclass;
 
-    my %all_code = $self->get_all_package_symbols('CODE');
+    my $all_code = $self->get_all_package_symbols('CODE');
 
-    foreach my $symbol (keys %all_code) {
-        my $code = $all_code{$symbol};
+    foreach my $symbol (keys %{ $all_code }) {
+        my $code = $all_code->{$symbol};
 
         next if exists  $map->{$symbol} &&
                 defined $map->{$symbol} &&
index 0e49b26..5733ec4 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use metaclass;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 029bc58..6842781 100644 (file)
@@ -8,7 +8,7 @@ use Scalar::Util    'blessed';
 
 use Moose::Meta::Role::Composite;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index a29a9fe..798ae51 100644 (file)
@@ -7,7 +7,7 @@ use metaclass;
 use Moose::Util  'english_list';
 use Scalar::Util 'blessed';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 53d8665..7cb772f 100644 (file)
@@ -6,7 +6,7 @@ use metaclass;
 
 use Scalar::Util 'blessed';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 9b87876..3530320 100644 (file)
@@ -6,7 +6,7 @@ use metaclass;
 
 use Scalar::Util    'blessed';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index f698790..291cbb2 100644 (file)
@@ -6,7 +6,7 @@ use metaclass;
 
 use Scalar::Util 'blessed';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 988f972..7821735 100644 (file)
@@ -4,7 +4,7 @@ package Moose::Meta::Role::Method;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 29e3c88..9200645 100644 (file)
@@ -4,7 +4,7 @@ package Moose::Meta::Role::Method::Required;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 150d82f..480b202 100644 (file)
@@ -8,7 +8,7 @@ use metaclass;
 use Moose::Meta::Attribute;
 use Moose::Util::TypeConstraints ();
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index a196298..e75eef0 100644 (file)
@@ -7,7 +7,7 @@ use metaclass;
 
 use Scalar::Util 'blessed';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index a908634..1a3417c 100644 (file)
@@ -12,7 +12,7 @@ use Scalar::Util qw(blessed refaddr);
 
 use base qw(Class::MOP::Object);
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -72,7 +72,13 @@ sub new {
 
 
 sub coerce   { ((shift)->coercion || Moose->throw_error("Cannot coerce without a type coercion"))->coerce(@_) }
-sub check    { $_[0]->_compiled_type_constraint->($_[1]) ? 1 : undef }
+
+sub check {
+    my ($self, @args) = @_;
+    my $constraint_subref = $self->_compiled_type_constraint;
+    return $constraint_subref->(@args) ? 1 : undef;
+}
+
 sub validate {
     my ($self, $value) = @_;
     if ($self->_compiled_type_constraint->($value)) {
@@ -210,8 +216,9 @@ sub _compile_subtype {
         } else {
             return Class::MOP::subname($self->name, sub {
                 return undef unless $optimized_parent->($_[0]);
-                local $_ = $_[0];
-                $check->($_[0]);
+                my (@args) = @_;
+                local $_ = $args[0];
+                $check->(@args);
             });
         }
     } else {
@@ -219,9 +226,10 @@ sub _compile_subtype {
         my @checks = @parents;
         push @checks, $check if $check != $null_constraint;
         return Class::MOP::subname($self->name => sub {
-            local $_ = $_[0];
+            my (@args) = @_;
+            local $_ = $args[0];
             foreach my $check (@checks) {
-                return undef unless $check->($_[0]);
+                return undef unless $check->(@args);
             }
             return 1;
         });
@@ -234,8 +242,9 @@ sub _compile_type {
     return $check if $check == $null_constraint; # Item, Any
 
     return Class::MOP::subname($self->name => sub {
-        local $_ = $_[0];
-        $check->($_[0]);
+        my (@args) = @_;
+        local $_ = $args[0];
+        $check->(@args);
     });
 }
 
index 1881b8e..c0b8257 100644 (file)
@@ -7,7 +7,7 @@ use metaclass;
 use Scalar::Util 'blessed';
 use Moose::Util::TypeConstraints ();
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 14a643b..2447525 100644 (file)
@@ -6,7 +6,7 @@ use metaclass;
 
 use Moose::Util::TypeConstraints ();
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index e12f7db..65db947 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use metaclass;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 566d96c..42b949e 100644 (file)
@@ -8,7 +8,7 @@ use Scalar::Util 'blessed';
 use Moose::Util::TypeConstraints;
 use Moose::Meta::TypeConstraint::Parameterizable;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 8b0ea77..949a1aa 100644 (file)
@@ -8,7 +8,7 @@ use metaclass;
 use Scalar::Util 'blessed';
 use Carp         'confess'; # FIXME Moose->throw_error
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 01e2be8..dae1a66 100644 (file)
@@ -7,7 +7,7 @@ use metaclass;
 use Scalar::Util 'blessed';
 use Moose::Util::TypeConstraints ();
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 9cf6786..a6dc545 100644 (file)
@@ -7,7 +7,7 @@ use metaclass;
 
 use Moose::Meta::TypeCoercion::Union;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 2f06b5a..c395b60 100644 (file)
@@ -7,7 +7,7 @@ use warnings;
 use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class';
 use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index a86515a..61aff67 100644 (file)
@@ -10,7 +10,7 @@ use Carp         'croak';
 use Data::OptList;
 use Sub::Exporter;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 8f2b5be..6837728 100644 (file)
@@ -108,18 +108,15 @@ helpers like C<Class::Accessor>.
       exists $p{birth_date}
           or confess 'birth_date is a required attribute';
 
-      $p{birth_date} = $class->_coerce_birth_date($date );
-      $class->_validate_birth_date( $date );
+      $p{birth_date} = $class->_coerce_birth_date( $p{birth_date} );
+      $class->_validate_birth_date( $p{birth_date} );
 
       $p{shirt_size} = 'l'
           unless exists $p{shirt_size}:
 
       $class->_validate_shirt_size( $p{shirt_size} );
 
-      my %self = map { $_ => $p{$_} } qw( name shirt_size );
-      $self{birth_date} = $date;
-
-      return bless \%self, $class;
+      return bless \%p, $class;
   }
 
   sub _validate_name {
@@ -216,22 +213,23 @@ helpers like C<Class::Accessor>.
 
 Wow, that was a mouthful! One thing to note is just how much space the
 data validation code consumes. As a result, it's pretty common for
-Perl 5 programmers to just not bother, which results in much more
-fragile code.
+Perl 5 programmers to just not bother. Unfortunately, not validating
+arguments leads to surprises down the line ("why is birth_date an
+email address?").
 
-Did you spot the (intentional) bug?
+Also, did you spot the (intentional) bug?
 
 It's in the C<_validate_birth_date()> method. We should check that
 that value in C<$birth_date> is actually defined and object before we
 go and call C<isa()> on it! Leaving out those checks means our data
 validation code could actually cause our program to die. Oops.
 
-Also note that if we add a superclass to Person we'll have to change
-the constructor to account for that.
+Note that if we add a superclass to Person we'll have to change the
+constructor to account for that.
 
 (As an aside, getting all the little details of what Moose does for
-you just right in this code was not easy, which just emphasizes the
-point, that Moose saves you a lot of work!)
+you just right in this example was really not easy, which emphasizes
+the point of the example. Moose saves you a lot of work!)
 
 Now let's see User:
 
index 5f72b9f..3f6c00c 100644 (file)
@@ -7,7 +7,7 @@ use Sub::Exporter;
 use Scalar::Util 'blessed';
 use Class::MOP   0.60;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index e1abff3..74b8547 100644 (file)
@@ -3,7 +3,7 @@ package Moose::Util::MetaRole;
 use strict;
 use warnings;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index d50936b..37eeccc 100644 (file)
@@ -9,7 +9,7 @@ use List::MoreUtils qw( all );
 use Scalar::Util 'blessed';
 use Moose::Exporter;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 2e4dc2f..aec496e 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 use Scalar::Util 'blessed', 'looks_like_number';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 72bb312..7e72e87 100644 (file)
@@ -8,7 +8,7 @@ use Test::Builder;
 
 use Moose::Util 'does_role', 'find_meta';
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
index 169cd87..836eb4f 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 use Class::MOP;
 
-our $VERSION   = '0.62_01';
+our $VERSION   = '0.63';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
diff --git a/t/030_roles/030_role_parameterized.t b/t/030_roles/030_role_parameterized.t
deleted file mode 100644 (file)
index 997520b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use Test::More skip_all => 'The feature this test exercises is not yet written';
-use Test::Exception;
-
-
-{
-    package Scalar;
-    use Moose::Role; 
-    
-    BEGIN { parameter T => { isa => 'Moose::Meta::TypeConstraint' } };
-
-    has 'val' => (is => 'ro', isa => T);
-    
-    requires 'eq';
-    
-    sub not_eq { ! (shift)->eq(shift) }
-}
-
-is_deeply(
-    Scalar->meta->parameters,
-    { T => { isa => 'Moose::Meta::TypeConstraint' } },
-    '... got the right parameters in the role'
-);
-
-{
-    package Integers;
-    use Moose;
-    use Moose::Util::TypeConstraints;
-
-    with Scalar => { T => find_type_constraint('Int') };
-    
-    sub eq { shift == shift }
-}
diff --git a/t/030_roles/037_create_role_subclass.t b/t/030_roles/037_create_role_subclass.t
new file mode 100644 (file)
index 0000000..ff436f6
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 2;
+use Moose ();
+
+do {
+    package My::Meta::Role;
+    use Moose;
+    extends 'Moose::Meta::Role';
+
+    has test_serial => (
+        is      => 'ro',
+        isa     => 'Int',
+        default => 1,
+    );
+
+    no Moose;
+};
+
+my $role = My::Meta::Role->create_anon_role;
+is($role->test_serial, 1, "default value for the serial attribute");
+
+my $nine_role = My::Meta::Role->create_anon_role(test_serial => 9);
+is($nine_role->test_serial, 9, "parameter value for the serial attribute");
+
index 37e340c..5603e1a 100644 (file)
@@ -1,9 +1,12 @@
 #!/usr/bin/perl
 
+# this functionality may be pushing toward parametric roles/classes
+# it's off in a corner and may not be that important
+
 use strict;
 use warnings;
 
-use Test::More tests => 3;
+use Test::More tests => 15;
 use Test::Exception;
 
 {
@@ -29,7 +32,56 @@ package main;
 my $anon;
 lives_ok {
     $anon = My::Metaclass->create_anon_class( foo => 'this' );
-} 'create anon class';
+} 'create anon class with required attr';
 isa_ok( $anon, 'My::Metaclass' );
 cmp_ok( $anon->foo, 'eq', 'this', 'foo is this' );
+dies_ok {
+    $anon = My::Metaclass->create_anon_class();
+} 'failed to create anon class without required attr';
+
+my $meta;
+lives_ok {
+    $meta
+        = My::Metaclass->initialize( 'Class::Name1' => ( foo => 'that' ) );
+} 'initialize a class with required attr';
+isa_ok( $meta, 'My::Metaclass' );
+cmp_ok( $meta->foo,  'eq', 'that',        'foo is that' );
+cmp_ok( $meta->name, 'eq', 'Class::Name1', 'for the correct class' );
+dies_ok {
+    $meta
+        = My::Metaclass->initialize( 'Class::Name2' );
+} 'failed to initialize a class without required attr';
+
+lives_ok {
+    eval qq{
+        package Class::Name3;
+        use metaclass 'My::Metaclass' => (
+            foo => 'another',
+        );
+        use Moose;
+    };
+    die $@ if $@;
+} 'use metaclass with required attr';
+$meta = Class::Name3->meta;
+isa_ok( $meta, 'My::Metaclass' );
+cmp_ok( $meta->foo,  'eq', 'another',        'foo is another' );
+cmp_ok( $meta->name, 'eq', 'Class::Name3', 'for the correct class' );
+dies_ok {
+    eval qq{
+        package Class::Name4;
+        use metaclass 'My::Metaclass';
+        use Moose;
+    };
+    die $@ if $@;
+} 'failed to use metaclass without required attr';
+
+
+# how do we pass a required attribute to -traits?
+dies_ok {
+    eval qq{
+        package Class::Name5;
+        use Moose -traits => 'HasFoo';
+    };
+    die $@ if $@;
+} 'failed to use trait without required attr';
 
index ec942e2..9f276d6 100644 (file)
@@ -44,8 +44,8 @@ for (1..2) {
     my $mutable_string = $is_immutable ? 'immutable' : 'mutable';
     lives_ok {
         my $f = Foo->new(foo => 10, bar => "Hello World", baz => 10, zot => 4);
-        is($f->moo, 69, "Type coersion works as expected on default ($mutable_string)");
-        is($f->boo, 69, "Type coersion works as expected on builder ($mutable_string)");
+        is($f->moo, 69, "Type coercion works as expected on default ($mutable_string)");
+        is($f->boo, 69, "Type coercion works as expected on builder ($mutable_string)");
     } "... this passes the constuctor correctly ($mutable_string)";
 
     lives_ok {
diff --git a/t/300_immutable/012_default_values.t b/t/300_immutable/012_default_values.t
new file mode 100644 (file)
index 0000000..f74a694
--- /dev/null
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 12;
+use Test::Exception;
+
+{
+
+    package Foo;
+    use Moose;
+
+    has 'foo' => ( is => 'rw', default => q{'} );
+    has 'bar' => ( is => 'rw', default => q{\\} );
+    has 'baz' => ( is => 'rw', default => q{"} );
+    has 'buz' => ( is => 'rw', default => q{"'\\} );
+    has 'faz' => ( is => 'rw', default => qq{\0} );
+
+    ::lives_ok {  __PACKAGE__->meta->make_immutable }
+        'no errors making a package immutable when it has default values that could break quoting';
+}
+
+my $foo = Foo->new;
+is( $foo->foo, q{'},
+    'default value for foo attr' );
+is( $foo->bar, q{\\},
+    'default value for bar attr' );
+is( $foo->baz, q{"},
+    'default value for baz attr' );
+is( $foo->buz, q{"'\\},
+    'default value for buz attr' );
+is( $foo->faz, qq{\0},
+    'default value for faz attr' );
+
+
+# Lazy attrs were never broken, but it doesn't hurt to test that they
+# won't be broken by any future changes.
+{
+
+    package Bar;
+    use Moose;
+
+    has 'foo' => ( is => 'rw', default => q{'}, lazy => 1 );
+    has 'bar' => ( is => 'rw', default => q{\\}, lazy => 1 );
+    has 'baz' => ( is => 'rw', default => q{"}, lazy => 1 );
+    has 'buz' => ( is => 'rw', default => q{"'\\}, lazy => 1 );
+    has 'faz' => ( is => 'rw', default => qq{\0}, lazy => 1 );
+
+    ::lives_ok {  __PACKAGE__->meta->make_immutable }
+        'no errors making a package immutable when it has lazy default values that could break quoting';
+}
+
+my $bar = Bar->new;
+is( $bar->foo, q{'},
+    'default value for foo attr' );
+is( $bar->bar, q{\\},
+    'default value for bar attr' );
+is( $bar->baz, q{"},
+    'default value for baz attr' );
+is( $bar->buz, q{"'\\},
+    'default value for buz attr' );
+is( $bar->faz, qq{\0},
+    'default value for faz attr' );