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 ++
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};
}
|| 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";
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 4;
use Test::Exception;
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;