Skip tests for strict constructor on Moose
[gitmo/Mouse.git] / t / 001_mouse / 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
74be9f76 11 has x => (
12 is => 'bare',
13 );
39d38928 14
15 has y => (
16 is => 'ro',
17 );
18
19 has z => (
20 is => 'rw',
21 );
22};
23
24my $object = Class->new({x => 1, y => 2, z => 3});
25is($object->{x}, 1);
26is($object->y, 2);
27is($object->z, 3);
28
29throws_ok {
30 Class->new('non-hashref scalar');
31} qr/Single parameters to new\(\) must be a HASH ref/;
32
c9aefe26 33throws_ok {
069668c4 34 Class->new(undef);
c9aefe26 35} qr/Single parameters to new\(\) must be a HASH ref/;
36
37Class->meta->make_immutable;
38
39throws_ok {
a09601ab 40 Class->new([]);
c9aefe26 41} qr/Single parameters to new\(\) must be a HASH ref/;
069668c4 42
c9aefe26 43throws_ok {
a09601ab 44 Class->new(Class->new);
c9aefe26 45} qr/Single parameters to new\(\) must be a HASH ref/;