Commit | Line | Data |
93e98578 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
a62dcd43 |
6 | use Test::More tests => 3; |
93e98578 |
7 | use Test::Exception; |
8 | |
7ff56534 |
9 | |
93e98578 |
10 | |
11 | =pod |
12 | |
13 | This tests to make sure that we provide the same error messages from |
14 | an immutable constructor as is provided by a non-immutable |
15 | constructor. |
16 | |
17 | =cut |
18 | |
19 | { |
20 | package Foo; |
21 | use Moose; |
22 | |
23 | has 'foo' => (is => 'rw', isa => 'Int'); |
24 | |
25 | Foo->meta->make_immutable(debug => 0); |
26 | } |
27 | |
28 | my $scalar = 1; |
29 | throws_ok { Foo->new($scalar) } qr/\QSingle parameters to new() must be a HASH ref/, |
30 | 'Non-ref provided to immutable constructor gives useful error message'; |
31 | throws_ok { Foo->new(\$scalar) } qr/\QSingle parameters to new() must be a HASH ref/, |
32 | 'Scalar ref provided to immutable constructor gives useful error message'; |
a62dcd43 |
33 | throws_ok { Foo->new(undef) } qr/\QSingle parameters to new() must be a HASH ref/, |
34 | 'undef provided to immutable constructor gives useful error message'; |
93e98578 |
35 | |