File: 98apply.t

package info (click to toggle)
libsub-handlesvia-perl 0.050000-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,840 kB
  • sloc: perl: 9,585; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 484 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use strict;
use warnings;
use Test::More;
{ package Local::Dummy; use Test::Requires { 'Moo' => '1.006' } };

{
	package Local::Class;
	use Moo;
	use Sub::HandlesVia;
	has collection => (
		is          => 'ro',
		handles_via => 'Array',
		handles     => [qw/ apply /],
	);
}

my $collection = Local::Class->new(
	collection => [qw/ 1 2 3 4 /],
);

my @r = $collection->apply(sub { $_ *= 2; 1 });
is_deeply(\@r, [2,4,6,8]);
is_deeply($collection->collection, [1,2,3,4]);
done_testing;