diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-09-04 19:38:21 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-09-04 19:47:11 -0400 |
commit | 8bf5e6931a1bd96df0cdb1ceb94bbb3e578a8126 (patch) | |
tree | 2e659a8f07ea1cca3091a9c0578bbd8e53c20c11 /t/22-replaced-constructor.t | |
parent | 8e0b4f219f2d8d94cb6937ef47168ac5fac03cd9 (diff) | |
download | moosex-nonmoose-8bf5e6931a1bd96df0cdb1ceb94bbb3e578a8126.tar.gz moosex-nonmoose-8bf5e6931a1bd96df0cdb1ceb94bbb3e578a8126.zip |
packaging
Diffstat (limited to 't/22-replaced-constructor.t')
-rw-r--r-- | t/22-replaced-constructor.t | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/t/22-replaced-constructor.t b/t/22-replaced-constructor.t deleted file mode 100644 index 3362bc2..0000000 --- a/t/22-replaced-constructor.t +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; - -our $foo_constructed = 0; - -package Foo; - -sub new { - my $class = shift; - bless {}, $class; -} - -package Foo::Moose; -use Moose; -use MooseX::NonMoose; -extends 'Foo'; - -after new => sub { - $main::foo_constructed = 1; -}; - -package Foo::Moose2; -use Moose; -use MooseX::NonMoose; -extends 'Foo'; - -sub new { - my $class = shift; - $main::foo_constructed = 1; - return $class->meta->new_object(@_); -} - -package main; -my $method = Foo::Moose->meta->get_method('new'); -isa_ok($method, 'Class::MOP::Method::Wrapped'); -my $foo = Foo::Moose->new; -ok($foo_constructed, 'method modifier called for the constructor'); -$foo_constructed = 0; -{ - # we don't care about the warning that moose isn't going to inline our - # constructor - this is the behavior we're testing - local $SIG{__WARN__} = sub {}; - Foo::Moose->meta->make_immutable; -} -is($method, Foo::Moose->meta->get_method('new'), - 'make_immutable doesn\'t overwrite constructor with method modifiers'); -$foo = Foo::Moose->new; -ok($foo_constructed, 'method modifier called for the constructor (immutable)'); - -$foo_constructed = 0; -$method = Foo::Moose2->meta->get_method('new'); -$foo = Foo::Moose2->new; -ok($foo_constructed, 'custom constructor called'); -$foo_constructed = 0; -# still need to specify inline_constructor => 0 when overriding new manually -Foo::Moose2->meta->make_immutable(inline_constructor => 0); -is($method, Foo::Moose2->meta->get_method('new'), - 'make_immutable doesn\'t overwrite custom constructor'); -$foo = Foo::Moose2->new; -ok($foo_constructed, 'custom constructor called (immutable)'); - -done_testing; |