Perltidy this code a bit.
[gitmo/Moose.git] / t / 300_immutable / 008_immutable_constructor_error.t
CommitLineData
93e98578 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 3;
7use Test::Exception;
8
9BEGIN {
10 use_ok('Moose');
11}
12
13=pod
14
15This tests to make sure that we provide the same error messages from
16an immutable constructor as is provided by a non-immutable
17constructor.
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
30my $scalar = 1;
31throws_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';
33throws_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