Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix the tests for %hash->get()

Broken by 26e9cc0

%hash->get() returing an array ref in scalar context is a non starter because
then $val = %hash->get($key) would return an array ref which doesn't make sense.
%hash->get() should probalby be changed to just take one value and leave it to
slice to take multiple keys.
  • Loading branch information...
commit 67f6a8ad8d0ddbbedd6872b262bef07da5b0d3f7 1 parent cac63b9
@schwern schwern authored
Showing with 10 additions and 9 deletions.
  1. +1 −1  lib/autobox/Core.pm
  2. +9 −8 t/added.t
View
2  lib/autobox/Core.pm
@@ -1459,7 +1459,7 @@ sub values {
# local extensions
-sub get { my @res = $_[0]->{@_[1..$#_]}; return wantarray ? @res : \@res }
+sub get { @{$_[0]}{@_[1..$#_]}; }
*at = *get;
sub put {
View
17 t/added.t
@@ -1,5 +1,4 @@
-use Test::More;
-BEGIN { plan tests => 73 };
+use Test::More 'no_plan';
use autobox::Core;
#####################################################################
@@ -107,19 +106,21 @@ is_deeply \@a, [ reverse 1 .. 10 ];
# Hashes
#####################################################################
my $h = {a => 1, b => 2, c => 3};
-ok($h->at('b') == 2);
+is($h->at('b'), 2);
-ok($h->get('c') == 3);
+is($h->get('c'), 3);
$h->put('d' => 4, e=>5, f=>6);
-ok($h->get('e') == 5);
+is($h->get('e'), 5);
$h->put('g', 7);
-ok($h->get('g') == 7);
+is($h->get('g'), 7);
$h->set('h' => 8);
-ok($h->get('h') == 8);
+is($h->get('h'), 8);
$h->set('i', 9);
-ok($h->get('i') == 9);
+is($h->get('i'), 9);
+
+is_deeply [$h->get(qw(a b c))], [1, 2, 3];
is_deeply(
[ sort $h->flatten ],
Please sign in to comment.
Something went wrong with that request. Please try again.