If the constructor in a parent class has method modifiers, we will not
[gitmo/Moose.git] / t / 600_todo_tests / 004_inlined_constructor_modified_new.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 6;
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     package Bar;
17     use Moose;
18     extends 'Foo';
19     Bar->meta->make_immutable;
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;
31
32 TODO:
33 {
34     local $TODO = 'but it isa Moose::Meta::Method instead';
35     isa_ok($inlined_new, 'Moose::Meta::Method::Constructor');
36 }
37
38 Foo->new(foo => 100);
39 ok($around_new, 'around new called');
40
41 $around_new = 0;
42 Bar->new(foo => 100);
43
44 TODO:
45 {
46     local $TODO = 'but it is not called';
47     ok($around_new, 'around new called');
48 }