Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 300_immutable / 008_immutable_constructor_error.t
1 #!/usr/bin/perl
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
6 use strict;
7 use warnings;
8
9 use Test::More;
10 use Test::Exception;
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 Mouse;
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 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';
37
38 done_testing;