From 3eb2caa01ccada44a35efea3f80d5a7254b1ef8d Mon Sep 17 00:00:00 2001 From: doy Date: Sat, 11 Apr 2009 17:24:44 -0500 Subject: add more tests for inheriting from moose classes --- t/005-moose.t | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 't/005-moose.t') diff --git a/t/005-moose.t b/t/005-moose.t index 59a0106..86578cb 100644 --- a/t/005-moose.t +++ b/t/005-moose.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 14; package Foo; use Moose; @@ -27,6 +27,31 @@ $_->meta->make_immutable for qw(Foo Foo::Sub); $foo_sub = Foo::Sub->new; isa_ok $foo_sub, 'Foo'; -is $foo_sub->foo, 'FOO', 'inheritance works'; +is $foo_sub->foo, 'FOO', 'inheritance works (immutable)'; is(Foo::Sub->meta->get_method('new'), undef, - 'Foo::Sub doesn\'t have its own new method'); + 'Foo::Sub doesn\'t have its own new method (immutable)'); + +package Foo::OtherSub; +use Moose; +use MooseX::NonMoose; +extends 'Foo'; + +package main; +my $foo_othersub = Foo::OtherSub->new; +isa_ok $foo_othersub, 'Foo'; +is $foo_othersub->foo, 'FOO', 'inheritance works (immutable when extending)'; +ok(Foo::OtherSub->meta->get_method('new'), + 'Foo::OtherSub has its own inlined constructor (immutable when extending)'); +ok(!(Foo::OtherSub->meta->get_method('new')->can('does_role') + && Foo::OtherSub->meta->get_method('new')->does_role('MooseX::NonMoose::Meta::Role::Constructor')), + 'Foo::OtherSub\'s inlined constructor is from Moose, not MooseX::NonMoose (immutable when extending)'); + +Foo::OtherSub->meta->make_immutable; +$foo_othersub = Foo::OtherSub->new; +isa_ok $foo_othersub, 'Foo'; +is $foo_othersub->foo, 'FOO', 'inheritance works (all immutable)'; +ok(Foo::OtherSub->meta->get_method('new'), + 'Foo::OtherSub has its own inlined constructor (immutable when extending)'); +ok(!(Foo::OtherSub->meta->get_method('new')->can('does_role') + && Foo::OtherSub->meta->get_method('new')->does_role('MooseX::NonMoose::Meta::Role::Constructor')), + 'Foo::OtherSub\'s inlined constructor is from Moose, not MooseX::NonMoose (immutable when extending)'); -- cgit v1.2.3-54-g00ecf