adding new test
[gitmo/Moose.git] / t / 300_immutable / 007_inlined_constructor_modified_new.t
CommitLineData
b363712c 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 7;
7
8my ($around_new);
9{
10 package Foo;
11 use Moose;
12
13 around new => sub { my $o = shift; $around_new = 1; $o->(@_); };
14 has 'foo' => (is => 'rw', isa => 'Int');
15}
16
17my $orig_new = Foo->meta->find_method_by_name('new');
18isa_ok($orig_new, 'Class::MOP::Method::Wrapped');
19$orig_new = $orig_new->get_original_method;
20isa_ok($orig_new, 'Moose::Meta::Method');
21
22Foo->meta->make_immutable(debug => 0);
23my $inlined_new = Foo->meta->find_method_by_name('new');
24isa_ok($inlined_new, 'Class::MOP::Method::Wrapped');
25$inlined_new = $inlined_new->get_original_method;
26isa_ok($inlined_new, 'Moose::Meta::Method::Constructor');
27
28my $foo = Foo->new(foo => 100);
29ok($around_new, 'around new called');
30