Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 300_immutable / 008_immutable_constructor_error.t
CommitLineData
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!!!
4use t::lib::MooseCompat;
fc1d8369 5
6use strict;
7use warnings;
8
16504b15 9use Test::More;
fc1d8369 10use Test::Exception;
11
12
fc1d8369 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;
b0000b3d 23 use Mouse;
fc1d8369 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';
16504b15 35throws_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 38done_testing;