File: each.t

package info (click to toggle)
libautobox-core-perl 1.2-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 328 kB
  • ctags: 161
  • sloc: perl: 567; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 365 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use Test::More qw(no_plan);
use strict;
use warnings;

use autobox::Core;

my %hash = ( foo => 1, bar => 2, baz => 3 );

my @glued;
%hash->each( sub { push @glued, $_[0] . $_[1] } );

is_deeply [ sort @glued ], [ qw(bar2 baz3 foo1) ];

my @array = values %hash;

my @added;
@array->each( sub { push @added, $_[0] + 1 } );

is_deeply [ sort @added ], [ qw(2 3 4) ];