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