6 use Test::More tests => 11;
8 require_ok('Moose::Autobox');
21 is_deeply($href, \%hash, "sanity check to start");
24 $href->each_key(sub { push @keys, $_ });
25 is_deeply([ sort @keys ], [ sort keys %hash ], "keys found via each_key");
28 $href->each_value(sub { push @values, $_ });
29 is_deeply([ sort @values ], [ sort values %hash ], "values via each_values");
31 $href->each_value(sub { $_++ });
32 is($href->{a}, 2, "we can ++ values directly");
34 $href->each_key(sub { $_ = "$_$_" });
35 ok(! exists $href->{aa}, "we cannot alter keys directly");
39 my @array = qw(foo bar baz);
41 my $aref = [ @array ];
43 is_deeply($aref, \@array, "sanity check to start");
46 $aref->each_key(sub { push @keys, $_ });
47 is_deeply([ @keys ], [ 0, 1, 2 ], "keys found via each_key");
50 $aref->each_value(sub { push @values, $_ });
51 is_deeply([ @values ], [ @array ], "values via each_values");
53 $aref->each_value(sub { $_ = uc });
54 is($aref->[0], 'FOO', "we can alter values directly");
56 $aref->each_key(sub { $_ = $_ + 1 });
57 ok(! $aref->[3], "we cannot alter keys directly");