Commit | Line | Data |
fc1d8369 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
b0000b3d |
6 | use Test::More; |
fc1d8369 |
7 | use Test::Exception; |
8 | |
b0000b3d |
9 | plan tests => 3; |
fc1d8369 |
10 | |
11 | { |
12 | package AClass; |
13 | |
b0000b3d |
14 | use Mouse; |
fc1d8369 |
15 | |
16 | has 'foo' => (is => 'rw', isa => 'Maybe[Str]', trigger => sub { |
17 | die "Pulling the Foo trigger\n" |
18 | }); |
19 | |
20 | has 'bar' => (is => 'rw', isa => 'Maybe[Str]'); |
21 | |
22 | has 'baz' => (is => 'rw', isa => 'Maybe[Str]', trigger => sub { |
23 | die "Pulling the Baz trigger\n" |
24 | }); |
25 | |
26 | __PACKAGE__->meta->make_immutable; #(debug => 1); |
27 | |
b0000b3d |
28 | no Mouse; |
fc1d8369 |
29 | } |
30 | |
31 | eval { AClass->new(foo => 'bar') }; |
32 | like ($@, qr/^Pulling the Foo trigger/, "trigger from immutable constructor"); |
33 | |
34 | eval { AClass->new(baz => 'bar') }; |
35 | like ($@, qr/^Pulling the Baz trigger/, "trigger from immutable constructor"); |
36 | |
37 | lives_ok { AClass->new(bar => 'bar') } '... no triggers called'; |
38 | |
39 | |
40 | |