Make generators private
[gitmo/Mouse.git] / t / 029-new.t
CommitLineData
39d38928 1#!/usr/bin/env perl
2use strict;
3use warnings;
c9aefe26 4use Test::More tests => 7;
eab81545 5use Test::Exception;
39d38928 6
7do {
8 package Class;
9 use Mouse;
10
11 has 'x';
12
13 has y => (
14 is => 'ro',
15 );
16
17 has z => (
18 is => 'rw',
19 );
20};
21
22my $object = Class->new({x => 1, y => 2, z => 3});
23is($object->{x}, 1);
24is($object->y, 2);
25is($object->z, 3);
26
27throws_ok {
28 Class->new('non-hashref scalar');
29} qr/Single parameters to new\(\) must be a HASH ref/;
30
c9aefe26 31throws_ok {
069668c4 32 Class->new(undef);
c9aefe26 33} qr/Single parameters to new\(\) must be a HASH ref/;
34
35Class->meta->make_immutable;
36
37throws_ok {
38 Class->new('non-hashref scalar');
39} qr/Single parameters to new\(\) must be a HASH ref/;
069668c4 40
c9aefe26 41throws_ok {
42 Class->new(undef);
43} qr/Single parameters to new\(\) must be a HASH ref/;