Bread-Board-Declare
view release on metacpan or search on metacpan
t/inheritance.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Moose;
use Test::Fatal;
{
package Parent;
use Moose;
use Bread::Board::Declare;
has foo => (
is => 'ro',
isa => 'Str',
value => 'FOO',
);
has bar => (
is => 'ro',
isa => 'Str',
block => sub {
my $s = shift;
return $s->param('foo') . 'BAR';
},
dependencies => ['foo'],
);
}
{
package Child;
use Moose;
use Bread::Board::Declare;
extends 'Parent';
has baz => (
is => 'ro',
isa => 'Str',
value => 'BAZ',
);
has quux => (
is => 'ro',
isa => 'Str',
block => sub {
my $s = shift;
return $s->param('foo')
. $s->param('bar')
. $s->param('baz')
. 'QUUX';
},
dependencies => ['foo', 'bar', 'baz'],
);
}
with_immutable {
{
my $parent = Parent->new;
ok($parent->has_service('foo'), "parent has foo");
ok($parent->has_service('bar'), "parent has bar");
my $child = Child->new;
ok($child->has_service('foo'), "child has foo");
ok($child->has_service('bar'), "child has bar");
ok($child->has_service('baz'), "child has baz");
( run in 1.405 second using v1.01-cache-2.11-cpan-54e63673c56 )