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