Added name to changelog entry per standaards.
[gitmo/Moose.git] / t / 070_native_traits / 209_trait_code.t
CommitLineData
cdf3cae6 1use strict;
2use warnings;
3
a28e50e4 4use Test::More;
cdf3cae6 5
6{
7 package Thingy;
8 use Moose;
9
10 has callback => (
11 traits => ['Code'],
12 is => 'ro',
13 isa => 'CodeRef',
14 required => 1,
15 handles => { 'invoke_callback' => 'execute' },
16 );
63723115 17
18 has multiplier => (
19 traits => ['Code'],
20 is => 'ro',
21 isa => 'CodeRef',
22 required => 1,
23 handles => { 'multiply' => 'execute' },
24 );
cdf3cae6 25}
26
27my $i = 0;
63723115 28my $thingy = Thingy->new(
29 callback => sub { ++$i },
30 multiplier => sub { $_[0] * 2 }
31);
cdf3cae6 32
33is($i, 0);
34$thingy->invoke_callback;
35is($i, 1);
63723115 36is($thingy->multiply(3), 6);
a28e50e4 37
38done_testing;