Hide remove_keywords a bit, rename it to _remove_keywords. Warn about it maybe being...
[gitmo/Moose.git] / t / 300_immutable / 004_inlined_constructors_n_types.t
CommitLineData
238b424d 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
7ff56534 6use Test::More tests => 3;
238b424d 7use Test::Exception;
8
7ff56534 9
238b424d 10
11=pod
12
13This tests to make sure that the inlined constructor
14has all the type constraints in order, even in the
15cases when there is no type constraint available, such
16as with a Class::MOP::Attribute object.
17
18=cut
19
20{
21 package Foo;
22 use Moose;
23
24 has 'foo' => (is => 'rw', isa => 'Int');
25 has 'baz' => (is => 'rw', isa => 'Int');
84981146 26 has 'zot' => (is => 'rw', isa => 'Int', init_arg => undef);
238b424d 27
28 Foo->meta->add_attribute(
29 Class::MOP::Attribute->new(
30 'bar' => (
31 accessor => 'bar',
32 )
33 )
34 );
35
36 Foo->meta->make_immutable(debug => 0);
37}
38
39lives_ok {
84981146 40 Foo->new(foo => 10, bar => "Hello World", baz => 10, zot => 4);
238b424d 41} '... this passes the constuctor correctly';
42
84981146 43lives_ok {
44 Foo->new(foo => 10, bar => "Hello World", baz => 10, zot => "not an int");
45} "... the constructor doesn't care about 'zot'";
46
238b424d 47dies_ok {
48 Foo->new(foo => "Hello World", bar => 100, baz => "Hello World");
49} '... this fails the constuctor correctly';
50
51
52
53