Commit | Line | Data |
b363712c |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More tests => 7; |
7 | |
8 | my ($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 | |
17 | my $orig_new = Foo->meta->find_method_by_name('new'); |
18 | isa_ok($orig_new, 'Class::MOP::Method::Wrapped'); |
19 | $orig_new = $orig_new->get_original_method; |
20 | isa_ok($orig_new, 'Moose::Meta::Method'); |
21 | |
22 | Foo->meta->make_immutable(debug => 0); |
23 | my $inlined_new = Foo->meta->find_method_by_name('new'); |
24 | isa_ok($inlined_new, 'Class::MOP::Method::Wrapped'); |
25 | $inlined_new = $inlined_new->get_original_method; |
26 | isa_ok($inlined_new, 'Moose::Meta::Method::Constructor'); |
27 | |
28 | my $foo = Foo->new(foo => 100); |
29 | ok($around_new, 'around new called'); |
30 | |