init_arg can be undef
[gitmo/Moose.git] / t / 300_immutable / 004_inlined_constructors_n_types.t
CommitLineData
238b424d 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 the inlined constructor
16has all the type constraints in order, even in the
17cases when there is no type constraint available, such
18as with a Class::MOP::Attribute object.
19
20=cut
21
22{
23 package Foo;
24 use Moose;
25
26 has 'foo' => (is => 'rw', isa => 'Int');
27 has 'baz' => (is => 'rw', isa => 'Int');
28
29 Foo->meta->add_attribute(
30 Class::MOP::Attribute->new(
31 'bar' => (
32 accessor => 'bar',
33 )
34 )
35 );
36
37 Foo->meta->make_immutable(debug => 0);
38}
39
40lives_ok {
41 Foo->new(foo => 10, bar => "Hello World", baz => 10);
42} '... this passes the constuctor correctly';
43
44dies_ok {
45 Foo->new(foo => "Hello World", bar => 100, baz => "Hello World");
46} '... this fails the constuctor correctly';
47
48
49
50