Support modifier by regexp
[gitmo/Mouse.git] / t / 300_immutable / 008_immutable_constructor_error.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 2;
7 use Test::Exception;
8
9
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 Mouse;
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';
33