Remove our (now broken) dzil GatherDir subclass
[gitmo/Moose.git] / t / bugs / coerce_without_coercion.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Fatal;
6 use Test::Moose;
7
8 {
9     package Foo;
10
11     use Moose::Deprecated -api_version => '1.07';
12     use Moose;
13
14     has x => (
15         is     => 'rw',
16         isa    => 'HashRef',
17         coerce => 1,
18     );
19 }
20
21 with_immutable {
22     is( exception { Foo->new( x => {} ) }, undef, 'Setting coerce => 1 without a coercion on the type does not cause an error in the constructor' );
23
24     is( exception { Foo->new->x( {} ) }, undef, 'Setting coerce => 1 without a coercion on the type does not cause an error when setting the attribut' );
25
26     like( exception { Foo->new( x => 42 ) }, qr/\QAttribute (x) does not pass the type constraint because/, 'Attempting to provide an invalid value to the constructor for this attr still fails' );
27
28     like( exception { Foo->new->x(42) }, qr/\QAttribute (x) does not pass the type constraint because/, 'Attempting to provide an invalid value to the accessor for this attr still fails' );
29 }
30 'Foo';
31
32 done_testing;