Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 100_bugs / 030_coerce_without_coercion.t
CommitLineData
ee5e6a03 1use strict;
2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
5use warnings;
6
7use Test::More;
8use Test::Exception;
9use Test::Mouse;
10
11{
12 package Foo;
13
14 use Mouse::Deprecated -api_version => '1.07';
15 use Mouse;
16
17 has x => (
18 is => 'rw',
19 isa => 'HashRef',
20 coerce => 1,
21 );
22}
23
24with_immutable {
25 lives_ok { Foo->new( x => {} ) }
26 'Setting coerce => 1 without a coercion on the type does not cause an error in the constructor';
27
28 lives_ok { Foo->new->x( {} ) }
29 'Setting coerce => 1 without a coercion on the type does not cause an error when setting the attribut';
30
31 throws_ok { Foo->new( x => 42 ) }
32 qr/\QAttribute (x) does not pass the type constraint because/,
33 'Attempting to provide an invalid value to the constructor for this attr still fails';
34
35 throws_ok { Foo->new->x(42) }
36 qr/\QAttribute (x) does not pass the type constraint because/,
37 'Attempting to provide an invalid value to the accessor for this attr still fails';
38}
39'Foo';
40
41done_testing;