summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-05-06 17:25:39 -0500
committerJesse Luehrs <doy@tozt.net>2009-05-06 17:25:39 -0500
commitecb22620b5015884ca97db98a4247d89f5d3e2c7 (patch)
tree10277bf3ff53f3b3ee29225f5f1ce5625e79b1b7 /t
parent9383dbbb73b64be0254a4b59a1bb61fb7fc783b7 (diff)
downloadmoosex-nonmoose-ecb22620b5015884ca97db98a4247d89f5d3e2c7.tar.gz
moosex-nonmoose-ecb22620b5015884ca97db98a4247d89f5d3e2c7.zip
add tests for using both BUILDARGS and FOREIGNBUILDARGS
Diffstat (limited to 't')
-rw-r--r--t/023-FOREIGNBUILDARGS.t28
1 files changed, 27 insertions, 1 deletions
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)');