From: Stevan Little Date: Mon, 9 Oct 2006 23:57:24 +0000 (+0000) Subject: fixing X-Git-Tag: 0_14^0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0142be3698ef3a5f8d447d39b36008a990b75244;p=gitmo%2FMoose.git fixing --- diff --git a/Changes b/Changes index 351e50f..180c77a 100644 --- a/Changes +++ b/Changes @@ -1,11 +1,15 @@ Revision history for Perl extension Moose -0.14 +0.14 Mon. Oct. 9, 2006 * Moose::Meta::Attribute - fixed lazy attributes which were not getting checked with the type constraint (thanks ashley) - added tests for this + - removed the over-enthusiastic DWIMery of the + automatic ArrayRef and HashRef defaults, it + broke predicates in an ugly way. + - removed tests for this 0.13 Sat. Sept. 30, 2006 ++ NOTE ++ diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 437a0b0..f94c875 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -165,9 +165,7 @@ sub _process_options { if (exists $options->{coerce} && $options->{coerce}) { (exists $options->{type_constraint}) - || confess "You cannot have coercion without specifying a type constraint"; - #(!$options->{type_constraint}->isa('Moose::Meta::TypeConstraint::Union')) - # || confess "You cannot have coercion with a type constraint union"; + || confess "You cannot have coercion without specifying a type constraint"; confess "You cannot have a weak reference to a coerced value" if $options->{weak_ref}; } @@ -180,15 +178,6 @@ sub _process_options { || confess "You cannot auto-dereference anything other than a ArrayRef or HashRef"; } - if (exists $options->{type_constraint} && - ($options->{type_constraint}->is_a_type_of('ArrayRef') || - $options->{type_constraint}->is_a_type_of('HashRef') )) { - unless (exists $options->{default}) { - $options->{default} = sub { [] } if $options->{type_constraint}->name eq 'ArrayRef'; - $options->{default} = sub { {} } if $options->{type_constraint}->name eq 'HashRef'; - } - } - if (exists $options->{lazy} && $options->{lazy}) { (exists $options->{default}) || confess "You cannot have lazy attribute without specifying a default value for it"; diff --git a/t/071_misc_attribute_tests.t b/t/071_misc_attribute_tests.t index c2ddfaf..c28b4a7 100644 --- a/t/071_misc_attribute_tests.t +++ b/t/071_misc_attribute_tests.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 4; use Test::Exception; BEGIN { @@ -12,32 +12,6 @@ BEGIN { { { - package Test::TheDefaultFor::ArrayRef::and::HashRef; - use Moose; - - has 'array_ref' => (is => 'rw', isa => 'ArrayRef'); - has 'hash_ref' => (is => 'rw', isa => 'HashRef'); - - } - - my $test = Test::TheDefaultFor::ArrayRef::and::HashRef->new; - isa_ok($test, 'Test::TheDefaultFor::ArrayRef::and::HashRef'); - - is_deeply($test->array_ref, [], '.... got the right default value'); - is_deeply($test->hash_ref, {}, '.... got the right default value'); - - my $test2 = Test::TheDefaultFor::ArrayRef::and::HashRef->new( - array_ref => [ 1, 2, [] ], - hash_ref => { one => 1, two => 2, three => {} }, - ); - isa_ok($test2, 'Test::TheDefaultFor::ArrayRef::and::HashRef'); - - is_deeply($test2->array_ref, [ 1, 2, [] ], '.... got the right default value'); - is_deeply($test2->hash_ref, { one => 1, two => 2, three => {} }, '.... got the right default value'); -} - -{ - { package Test::For::Lazy::TypeConstraint; use Moose; use Moose::Util::TypeConstraints;