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 skip_all => "mouse doesn't support Maybe[] yet"; |
10 | plan tests => 3; |
fc1d8369 |
11 | |
12 | { |
13 | package AClass; |
14 | |
b0000b3d |
15 | use Mouse; |
fc1d8369 |
16 | |
17 | has 'foo' => (is => 'rw', isa => 'Maybe[Str]', trigger => sub { |
18 | die "Pulling the Foo trigger\n" |
19 | }); |
20 | |
21 | has 'bar' => (is => 'rw', isa => 'Maybe[Str]'); |
22 | |
23 | has 'baz' => (is => 'rw', isa => 'Maybe[Str]', trigger => sub { |
24 | die "Pulling the Baz trigger\n" |
25 | }); |
26 | |
27 | __PACKAGE__->meta->make_immutable; #(debug => 1); |
28 | |
b0000b3d |
29 | no Mouse; |
fc1d8369 |
30 | } |
31 | |
32 | eval { AClass->new(foo => 'bar') }; |
33 | like ($@, qr/^Pulling the Foo trigger/, "trigger from immutable constructor"); |
34 | |
35 | eval { AClass->new(baz => 'bar') }; |
36 | like ($@, qr/^Pulling the Baz trigger/, "trigger from immutable constructor"); |
37 | |
38 | lives_ok { AClass->new(bar => 'bar') } '... no triggers called'; |
39 | |
40 | |
41 | |