type coercion does not work well together with AllErrors...
Subject: | 03_type_coercion.t |
use strict;
use warnings;
use Test::More;
use Test::Exception;
{
use Moose::Util::TypeConstraints;
use MooseX::Types::Moose qw/:all/;
use MooseX::Types::DateTimeX qw/ DateTime /;
subtype 'Date', as 'DateTime';
coerce 'Date', from 'HashRef', via {
DateTime::->new(
$_
);
};
no Moose::Util::TypeConstraints;
}
{
package Foo;
use Moose;
has date => (
is => 'ro',
isa => 'Date',
coerce => 1,
);
Foo->meta->make_immutable;
}
{
package Bar;
use Moose;
use MooseX::Constructor::AllErrors;
has date => (
is => 'ro',
isa => 'Date',
coerce => 1,
);
Bar->meta->make_immutable;
}
use DateTime;
lives_ok{
Foo->new(
date => {
year => 2005,
month => 2,
day => 4,
hour => 12,
minute => 20,
second => 50,
})
} 'Instance of Test Class with coercion w/o AllErrors lives';
lives_ok{
Bar->new(
date => {
year => 2005,
month => 2,
day => 4,
hour => 12,
minute => 20,
second => 50,
})
} 'Instance of Test Class with coercion with AllErrors lives';
my $e = $@;
explain "$e" if $e ;
done_testing;