12 sub is_passed_undefined { !defined($_[0]) ? 'bar' : 'fail' }
43 has foo => ( is => 'ro', handles => [ qw(one two) ] );
44 has foo2 => ( is => 'ro', handles => { un => 'one' } );
45 has foo3 => ( is => 'ro', handles => 'Robot' );
46 has foo4 => ( is => 'ro', handles => {
47 eat_curry => [ yum => 'Curry!' ],
49 has foo5 => ( is => 'ro', handles => 'ExtRobot' );
50 has foo6 => ( is => 'rw',
51 handles => { foobot => '${\\Baz->can("beep")}'},
52 default => sub { 0 } );
53 has foo7 => ( is => 'rw',
54 handles => { foobar => '${\\Baz->can("is_passed_undefined")}'},
55 default => sub { undef } );
60 foo => Foo->new, foo2 => Foo->new, foo3 => Foo->new, foo4 => Foo->new,
64 is $bar->one, 1, 'handles works';
65 is $bar->two, 2, 'handles works for more than one method';
67 is $bar->un, 1, 'handles works for aliasing a method';
69 is $bar->smash, 'smash', 'handles works for a role';
71 is $bar->beep, 'beep', 'handles loads roles';
73 is $bar->eat_curry, 'Curry!', 'handles works for currying';
75 is $bar->foobot, 'beep', 'asserter checks for existence not truth, on false value';
77 is $bar->foobar, 'bar', 'asserter checks for existence not truth, on undef ';
79 ok(my $e = exception {
82 has foo => ( is => 'ro', handles => 'Robot' );
84 }, 'handles will not overwrite locally defined method');
85 like $e, qr{You cannot overwrite a locally defined method \(smash\) with a delegation},
86 '... and has correct error message';
91 has foo => ( is => 'ro', handles => $bar );
92 }, 'invalid handles throws exception');