File: array-slice.t

package info (click to toggle)
libautobox-core-perl 1.2-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 328 kB
  • ctags: 161
  • sloc: perl: 567; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 427 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use autobox::Core;

my @array = qw(foo bar baz);

ok @array->slice(0);
is_deeply [@array->slice(0)], ['foo'];
is_deeply [@array->slice(0,2)], ['foo', 'baz'];

my @slice = @array->slice(0,1);

is scalar @slice, 2, "Returns an array in list context";

my $slice = @array->slice(0,1);

is ref $slice, 'ARRAY', "Returns an arrayref in scalar context";

done_testing();