File: 004_list_compressions.t

package info (click to toggle)
libmoose-autobox-perl 0.12-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 308 kB
  • sloc: perl: 2,454; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 763 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 5;

BEGIN {
    use_ok('Moose::Autobox');
}

use Moose::Autobox;

is_deeply(
[ 1 .. 5 ]->map(sub { $_ * $_ }),
[ 1, 4, 9, 16, 25 ],
'... got the expected return values');

is_deeply(
[ 1 .. 5 ]->map(sub { $_ * $_ })->do(sub { $_->zip($_) }),
[ [1, 1], [4, 4], [9, 9], [16, 16], [25, 25] ],
'... got the expected return values');

is( # sprintf an array ...
[ 1 .. 5 ]->sprintf("%d -> %d -> %d"),
'1 -> 2 -> 3',
'... got the sprintf-ed values');

is( # sprintf an array ...
[ 1 .. 5 ]->do(sub {
    $_->sprintf(
        $_->keys
          ->map(sub { '%d (' . $_ . ')' })
          ->join(' -> '))
}),
'1 (0) -> 2 (1) -> 3 (2) -> 4 (3) -> 5 (4)',
'... got a more elaboratly sprintf-ed values');