summaryrefslogtreecommitdiffstats
path: root/t/04-block.t
blob: c0f9badacafad7b0c8da8380d2529f71856c5df6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

{
    package Foo;
    use Moose;
    use MooseX::Bread::Board;

    has foo => (
        is      => 'ro',
        isa     => 'Str',
        default => 'FOO',
    );

    has bar => (
        is    => 'ro',
        isa   => 'Str',
        value => 'BAR',
    );

    has baz => (
        is           => 'ro',
        isa          => 'Str',
        block        => sub {
            my ($s, $self) = @_;
            return $s->param('bar') . $self->foo;
        },
        dependencies => ['bar'],
    );
}

{
    my $foo = Foo->new;
    is($foo->baz, 'BARFOO', "self is passed properly");
}

done_testing;