more detailed messages for tag and release commit
[gitmo/Moose.git] / t / immutable / immutable_trigger_from_constructor.t
CommitLineData
1b55c340 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
a28e50e4 6use Test::More;
b10dde3a 7use 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
30eval { AClass->new(foo => 'bar') };
31like ($@, qr/^Pulling the Foo trigger/, "trigger from immutable constructor");
32
33eval { AClass->new(baz => 'bar') };
34like ($@, qr/^Pulling the Baz trigger/, "trigger from immutable constructor");
35
b10dde3a 36is( exception { AClass->new(bar => 'bar') }, undef, '... no triggers called' );
1b55c340 37
a28e50e4 38done_testing;