Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 8a0b95dca5
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (21 sloc) 0.681 kb
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) ];
# Ensure each() always iterates through the whole hash
{
my %want = (foo => 23, bar => 42, baz => 99, biff => 66);
# Call each once on %want to start the iterator attached to %want
my($k,$v) = each %want;
my %have;
%want->each( sub { $have{$_[0]} = $_[1] } );
is_deeply \%have, \%want;
}
Jump to Line
Something went wrong with that request. Please try again.