From 2a93aac1a9697e29b20be64cd1da7b0c9e3a2390 Mon Sep 17 00:00:00 2001 From: doy Date: Mon, 20 Apr 2009 01:07:49 -0500 Subject: add failing test for method modifiers on the constructor --- t/022-method-modifiers-new.t | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 t/022-method-modifiers-new.t (limited to 't') diff --git a/t/022-method-modifiers-new.t b/t/022-method-modifiers-new.t new file mode 100644 index 0000000..0d17b7a --- /dev/null +++ b/t/022-method-modifiers-new.t @@ -0,0 +1,34 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 4; + +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 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; +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)'); -- cgit v1.2.3-54-g00ecf