Commit | Line | Data |
b363712c |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6d97bf02 |
6 | use Test::More tests => 6; |
b363712c |
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'); |
21158859 |
15 | |
16 | package Bar; |
17 | use Moose; |
18 | extends 'Foo'; |
19 | Bar->meta->make_immutable; |
b363712c |
20 | } |
21 | |
22 | my $orig_new = Foo->meta->find_method_by_name('new'); |
23 | isa_ok($orig_new, 'Class::MOP::Method::Wrapped'); |
24 | $orig_new = $orig_new->get_original_method; |
25 | isa_ok($orig_new, 'Moose::Meta::Method'); |
26 | |
27 | Foo->meta->make_immutable(debug => 0); |
28 | my $inlined_new = Foo->meta->find_method_by_name('new'); |
29 | isa_ok($inlined_new, 'Class::MOP::Method::Wrapped'); |
30 | $inlined_new = $inlined_new->get_original_method; |
6d97bf02 |
31 | |
32 | TODO: |
33 | { |
34 | local $TODO = 'but it isa Moose::Meta::Method instead'; |
35 | isa_ok($inlined_new, 'Moose::Meta::Method::Constructor'); |
36 | } |
b363712c |
37 | |
21158859 |
38 | Foo->new(foo => 100); |
b363712c |
39 | ok($around_new, 'around new called'); |
40 | |
21158859 |
41 | $around_new = 0; |
42 | Bar->new(foo => 100); |
6d97bf02 |
43 | |
44 | TODO: |
45 | { |
46 | local $TODO = 'but it is not called'; |
47 | ok($around_new, 'around new called'); |
48 | } |