Commit | Line | Data |
238b424d |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More tests => 3; |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
10 | use_ok('Moose'); |
11 | } |
12 | |
13 | =pod |
14 | |
15 | This tests to make sure that the inlined constructor |
16 | has all the type constraints in order, even in the |
17 | cases when there is no type constraint available, such |
18 | as 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 | |
40 | lives_ok { |
41 | Foo->new(foo => 10, bar => "Hello World", baz => 10); |
42 | } '... this passes the constuctor correctly'; |
43 | |
44 | dies_ok { |
45 | Foo->new(foo => "Hello World", bar => 100, baz => "Hello World"); |
46 | } '... this fails the constuctor correctly'; |
47 | |
48 | |
49 | |
50 | |