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