}
sub join {
- my ($array, $sep) = @_;
+ my ($array, $sep) = @_;
+ $sep ||= '';
CORE::join $sep, @$array;
}
sub kv {
my ($array) = @_;
- [ CORE::map { [ $_, $array->[$_] ] } (0 .. $#{$array}) ];
+ $array->keys->map(sub { [ $_, $array->[$_] ] });
}
## Array Interface
use strict;
use warnings;
-use Test::More tests => 7;
+use Test::More tests => 8;
use Test::Exception;
BEGIN {
}
{
- package Bytes;
+ package Units::Bytes;
use Moose::Role;
use autobox;
{
package SCALAR;
use Moose;
- with 'Bytes';
+ with 'Units::Bytes';
+}
+
+sub testing_bytes {
+ ::dies_ok { 10->bytes } '... cannot do the autoboxing lexically';
}
{
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';