summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-04-20 01:07:49 -0500
committerdoy <doy@tozt.net>2009-04-20 01:07:49 -0500
commit2a93aac1a9697e29b20be64cd1da7b0c9e3a2390 (patch)
tree92998c012cdc257bd38e93b4c9bd415ddbc3b254 /t
parent6211b6b4cb7f9ccd741f99d3177a0048547a3046 (diff)
downloadmoosex-nonmoose-2a93aac1a9697e29b20be64cd1da7b0c9e3a2390.tar.gz
moosex-nonmoose-2a93aac1a9697e29b20be64cd1da7b0c9e3a2390.zip
add failing test for method modifiers on the constructor
Diffstat (limited to 't')
-rw-r--r--t/022-method-modifiers-new.t34
1 files changed, 34 insertions, 0 deletions
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)');