root/lang/perl/Shika/trunk/t/010_core/04_handles.t @ 25088

Revision 25088, 0.5 kB (checked in by tokuhirom, 5 years ago)

handles に scalar もわたせるようにした

Line 
1use strict;
2use warnings;
3use Test::More tests => 2;
4
5{
6    package Bar;
7    use Shika;
8
9    sub yay {
10        my $self = shift;
11        "yay " . join(", ", @_)
12    }
13}
14
15{
16    package Foo1;
17    use Shika;
18    has bar => (
19        handles => ['yay'],
20    );
21}
22
23{
24    package Foo2;
25    use Shika;
26    has bar => (
27        handles => 'yay',
28    );
29}
30
31{
32    my $f = Foo1->new(bar => Bar->new());
33    is $f->yay('hoge', 'fuga'), 'yay hoge, fuga';
34}
35
36{
37    my $f = Foo2->new(bar => Bar->new());
38    is $f->yay('hoge', 'fuga'), 'yay hoge, fuga';
39}
40
Note: See TracBrowser for help on using the browser.