Commit | Line | Data |
fc1d8369 |
1 | #!/usr/bin/perl |
16504b15 |
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; |
fc1d8369 |
5 | |
6 | use strict; |
7 | use warnings; |
8 | |
16504b15 |
9 | use Test::More; |
fc1d8369 |
10 | use Test::Exception; |
11 | |
12 | |
fc1d8369 |
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; |
b0000b3d |
23 | use Mouse; |
fc1d8369 |
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'; |
16504b15 |
35 | throws_ok { Foo->new(undef) } qr/\QSingle parameters to new() must be a HASH ref/, |
36 | 'undef provided to immutable constructor gives useful error message'; |
fc1d8369 |
37 | |
16504b15 |
38 | done_testing; |