Skip the recipe 11 tests, they don't work yet :(
[gitmo/Moose.git] / t / 300_immutable / 004_inlined_constructors_n_types.t
CommitLineData
238b424d 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
84981146 6use Test::More tests => 4;
238b424d 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');
84981146 28 has 'zot' => (is => 'rw', isa => 'Int', init_arg => undef);
238b424d 29
30 Foo->meta->add_attribute(
31 Class::MOP::Attribute->new(
32 'bar' => (
33 accessor => 'bar',
34 )
35 )
36 );
37
38 Foo->meta->make_immutable(debug => 0);
39}
40
41lives_ok {
84981146 42 Foo->new(foo => 10, bar => "Hello World", baz => 10, zot => 4);
238b424d 43} '... this passes the constuctor correctly';
44
84981146 45lives_ok {
46 Foo->new(foo => 10, bar => "Hello World", baz => 10, zot => "not an int");
47} "... the constructor doesn't care about 'zot'";
48
238b424d 49dies_ok {
50 Foo->new(foo => "Hello World", bar => 100, baz => "Hello World");
51} '... this fails the constuctor correctly';
52
53
54
55