DEATH TO ALL zionist ELLIPSES
[gitmo/Moose.git] / t / 300_immutable / 007_immutable_trigger_from_constructor.t
CommitLineData
1b55c340 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
7ff56534 6use Test::More tests => 3;
1b55c340 7use Test::Exception;
8
7ff56534 9
1b55c340 10
11{
12 package AClass;
13
14 use Moose;
15
16 has 'foo' => (is => 'rw', isa => 'Maybe[Str]', trigger => sub {
17 die "Pulling the Foo trigger\n"
18 });
d03bd989 19
20 has 'bar' => (is => 'rw', isa => 'Maybe[Str]');
21
1b55c340 22 has 'baz' => (is => 'rw', isa => 'Maybe[Str]', trigger => sub {
23 die "Pulling the Baz trigger\n"
d03bd989 24 });
1b55c340 25
26 __PACKAGE__->meta->make_immutable; #(debug => 1);
27
28 no Moose;
29}
30
31eval { AClass->new(foo => 'bar') };
32like ($@, qr/^Pulling the Foo trigger/, "trigger from immutable constructor");
33
34eval { AClass->new(baz => 'bar') };
35like ($@, qr/^Pulling the Baz trigger/, "trigger from immutable constructor");
36
1808c2da 37lives_ok { AClass->new(bar => 'bar') } 'no triggers called';
1b55c340 38
39
40