From ecb22620b5015884ca97db98a4247d89f5d3e2c7 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 6 May 2009 17:25:39 -0500 Subject: add tests for using both BUILDARGS and FOREIGNBUILDARGS --- t/023-FOREIGNBUILDARGS.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/023-FOREIGNBUILDARGS.t b/t/023-FOREIGNBUILDARGS.t index 408e493..1434c76 100644 --- a/t/023-FOREIGNBUILDARGS.t +++ b/t/023-FOREIGNBUILDARGS.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 8; package Foo; @@ -27,12 +27,38 @@ sub FOREIGNBUILDARGS { return "$args{foo}_base"; } +package Bar::Moose; +use Moose; +use MooseX::NonMoose; +extends 'Foo'; + +has bar => ( + is => 'rw', +); + +sub FOREIGNBUILDARGS { + my $class = shift; + return "$_[0]_base"; +} + +sub BUILDARGS { + my $class = shift; + return { bar => shift }; +} + package main; my $foo = Foo::Moose->new(foo => 'bar'); is($foo->foo, 'bar', 'subclass constructor gets the right args'); is($foo->foo_base, 'bar_base', 'subclass constructor gets the right args'); +my $bar = Bar::Moose->new('baz'); +is($bar->bar, 'baz', 'subclass constructor gets the right args'); +is($bar->foo_base, 'baz_base', 'subclass constructor gets the right args'); Foo::Moose->meta->make_immutable; +Bar::Moose->meta->make_immutable; $foo = Foo::Moose->new(foo => 'bar'); +$bar = Bar::Moose->new('baz'); is($foo->foo, 'bar', 'subclass constructor gets the right args (immutable)'); is($foo->foo_base, 'bar_base', 'subclass constructor gets the right args (immutable)'); +is($bar->bar, 'baz', 'subclass constructor gets the right args (immutable)'); +is($bar->foo_base, 'baz_base', 'subclass constructor gets the right args (immutable)'); -- cgit v1.2.3