summaryrefslogtreecommitdiffstats
path: root/t/block.t
blob: 3ce9f48f6ea44e21779a0d511bbe0bf2d8431923 (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
40
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Moose;

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

    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'],
    );
}

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

done_testing;