Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 300_immutable / 007_immutable_trigger_from_constructor.t
CommitLineData
fc1d8369 1#!/usr/bin/perl
16504b15 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
fc1d8369 5
6use strict;
7use warnings;
8
b0000b3d 9use Test::More;
fc1d8369 10use Test::Exception;
11
fc1d8369 12
13{
14 package AClass;
15
b0000b3d 16 use Mouse;
fc1d8369 17
18 has 'foo' => (is => 'rw', isa => 'Maybe[Str]', trigger => sub {
19 die "Pulling the Foo trigger\n"
20 });
16504b15 21
22 has 'bar' => (is => 'rw', isa => 'Maybe[Str]');
23
fc1d8369 24 has 'baz' => (is => 'rw', isa => 'Maybe[Str]', trigger => sub {
25 die "Pulling the Baz trigger\n"
16504b15 26 });
fc1d8369 27
28 __PACKAGE__->meta->make_immutable; #(debug => 1);
29
b0000b3d 30 no Mouse;
fc1d8369 31}
32
33eval { AClass->new(foo => 'bar') };
34like ($@, qr/^Pulling the Foo trigger/, "trigger from immutable constructor");
35
36eval { AClass->new(baz => 'bar') };
37like ($@, qr/^Pulling the Baz trigger/, "trigger from immutable constructor");
38
39lives_ok { AClass->new(bar => 'bar') } '... no triggers called';
40
16504b15 41done_testing;