From 571bfa3b91ff5567338948776b6fce84d3ede09e Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 15 Jun 2010 00:53:14 -0500 Subject: fix inlined nonmoose constructors which call other methods (woosley) --- t/025-constructor-method-calls.t | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 t/025-constructor-method-calls.t (limited to 't') diff --git a/t/025-constructor-method-calls.t b/t/025-constructor-method-calls.t new file mode 100644 index 0000000..7806b44 --- /dev/null +++ b/t/025-constructor-method-calls.t @@ -0,0 +1,47 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Moose qw(with_immutable); + +my ($foo, $foosub); +{ + package Foo; + + sub new { + my $class = shift; + my $obj = bless {}, $class; + $obj->init; + $obj; + } + + sub init { + $foo++ + } +} + +{ + package Foo::Sub; + use base 'Foo'; + + sub init { + $foosub++; + shift->SUPER::init; + } +} + +{ + package Foo::Sub::Sub; + use Moose; + use MooseX::NonMoose; + extends 'Foo::Sub'; +} + +with_immutable { + ($foo, $foosub) = (0, 0); + Foo::Sub::Sub->new; + is($foo, 1, "Foo::init called"); + is($foosub, 1, "Foo::Sub::init called"); +} 'Foo::Sub::Sub'; + +done_testing; -- cgit v1.2.3-54-g00ecf