Require Dist::Zilla 4.200016+
[gitmo/Moose.git] / t / attributes / bad_coerce.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 use Test::Requires {
7     'Test::Output' => '0.01', # skip all if not installed
8 };
9
10 {
11     package Foo;
12
13     use Moose;
14
15     ::stderr_like{ has foo => (
16             is     => 'ro',
17             isa    => 'Str',
18             coerce => 1,
19         );
20         }
21         qr/\QYou cannot coerce an attribute (foo) unless its type (Str) has a coercion/,
22         'Cannot coerce unless the type has a coercion';
23
24     ::stderr_like{ has bar => (
25             is     => 'ro',
26             isa    => 'Str',
27             coerce => 1,
28         );
29         }
30         qr/\QYou cannot coerce an attribute (bar) unless its type (Str) has a coercion/,
31         'Cannot coerce unless the type has a coercion - different attribute';
32 }
33
34 done_testing;