From: Stevan Little Date: Sun, 4 Jun 2006 20:17:16 +0000 (+0000) Subject: foo X-Git-Tag: 0_02~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMoose-Autobox.git;a=commitdiff_plain;h=feffe00c3c1456347355662d6da3c6a676129712 foo --- diff --git a/lib/Moose/Autobox/Array.pm b/lib/Moose/Autobox/Array.pm index defa83b..6144e6f 100644 --- a/lib/Moose/Autobox/Array.pm +++ b/lib/Moose/Autobox/Array.pm @@ -25,7 +25,8 @@ sub map { } sub join { - my ($array, $sep) = @_; + my ($array, $sep) = @_; + $sep ||= ''; CORE::join $sep, @$array; } @@ -75,7 +76,7 @@ sub values { sub kv { my ($array) = @_; - [ CORE::map { [ $_, $array->[$_] ] } (0 .. $#{$array}) ]; + $array->keys->map(sub { [ $_, $array->[$_] ] }); } ## Array Interface diff --git a/t/003_p6_example.t b/t/003_p6_example.t index 60cd248..711d808 100644 --- a/t/003_p6_example.t +++ b/t/003_p6_example.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 8; use Test::Exception; BEGIN { @@ -11,7 +11,7 @@ BEGIN { } { - package Bytes; + package Units::Bytes; use Moose::Role; use autobox; @@ -34,7 +34,11 @@ BEGIN { { package SCALAR; use Moose; - with 'Bytes'; + with 'Units::Bytes'; +} + +sub testing_bytes { + ::dies_ok { 10->bytes } '... cannot do the autoboxing lexically'; } { @@ -45,6 +49,7 @@ BEGIN { is(2->megabytes, 2097152, '... got 2 megabytes'); is(1->gigabyte, 1073741824, '... got 1 gigabyte'); is(2->terabytes, 2199023255552, '... got 2 terabyte'); + testing_bytes; } dies_ok { 5->bytes } '... no longer got 5 bytes';