Commit | Line | Data |
ee5e6a03 |
1 | use strict; |
2 | # This is automatically generated by author/import-moose-test.pl. |
3 | # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! |
4 | use t::lib::MooseCompat; |
5 | use warnings; |
6 | |
7 | use Test::More; |
8 | use Test::Exception; |
9 | use 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 | |
24 | with_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 | |
41 | done_testing; |