File: squished.t

package info (click to toggle)
liblist-objects-withutils-perl 2.028003-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,296 kB
  • sloc: perl: 1,957; makefile: 17; sh: 1
file content (29 lines) | stat: -rw-r--r-- 907 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use Test::More;
use strict; use warnings;

use Lowu 'array';

my $arr = array(qw/a b b c d c c e b/);
my $squished = $arr->squished;
is_deeply [ $squished->all ], [ qw/a b c d c e b/ ], 'squished ok';
is_deeply [ $arr->squish->all ], [ $squished->all ], 'squish alias ok';

$arr = array('a', 'b', undef, 'b', undef, undef, 'c');
is_deeply [ $arr->squished->all ], [ 'a', 'b', undef, 'b', undef, 'c' ],
  'squished with (middle) undefs ok';

$arr = array(undef, undef, 'a', 'b');
is_deeply [ $arr->squished->all ], [ undef, 'a', 'b' ],
  'squished with (leading) undefs ok';

$arr = array(undef, 'a', 'a', 'b');
is_deeply [ $arr->squished->all ], [ undef, 'a', 'b' ],
  'squished with leading single undef ok';

$arr = array('a', 'b', 'c');
is_deeply [ $arr->squished->all ], [ 'a', 'b', 'c' ],
  'squished (no squished values) ok';

ok array->squished->is_empty, 'squished on empty array ok';

done_testing