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