From 11dd3a027efbefeaae5ca483296781fa2bc5684d Mon Sep 17 00:00:00 2001 From: Jason May Date: Wed, 6 May 2009 13:12:50 -0400 Subject: test for FOREIGNBUILDARGS --- t/023-FOREIGNBUILDARGS.t | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 t/023-FOREIGNBUILDARGS.t (limited to 't') diff --git a/t/023-FOREIGNBUILDARGS.t b/t/023-FOREIGNBUILDARGS.t new file mode 100644 index 0000000..8f93b79 --- /dev/null +++ b/t/023-FOREIGNBUILDARGS.t @@ -0,0 +1,36 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 2; + +package Foo; + +sub new { + my $class = shift; + bless { foo => $_[0] }, $class; +} + +sub foo { shift->{foo} } + +package Foo::Moose; +use Moose; +use MooseX::NonMoose; +extends 'Foo'; + +has foo => ( + is => 'rw', +); + +sub FOREIGNBUILDARGS { + my $class = shift; + my %args = @_; + return $args{foo}; +} + +package main; + +my $foo = Foo::Moose->new(foo => 'bar'); +is($foo->foo, 'bar', 'subclass constructor gets the right args'); +Foo::Moose->meta->make_immutable; +$foo = Foo::Moose->new(foo => 'bar'); +is($foo->foo, 'bar', 'subclass constructor gets the right args (immutable)'); -- cgit v1.2.3-54-g00ecf