use_ok stinks; just load the library
[gitmo/Moose-Autobox.git] / t / 004_list_compressions.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 4;
7
8 use Moose::Autobox;
9
10 is_deeply(
11 [ 1 .. 5 ]->map(sub { $_ * $_ }),
12 [ 1, 4, 9, 16, 25 ],
13 '... got the expected return values');
14
15 is_deeply(
16 [ 1 .. 5 ]->map(sub { $_ * $_ })->do(sub { $_->zip($_) }),
17 [ [1, 1], [4, 4], [9, 9], [16, 16], [25, 25] ],
18 '... got the expected return values');
19
20 is( # sprintf an array ...
21 [ 1 .. 5 ]->sprintf("%d -> %d -> %d"),
22 '1 -> 2 -> 3',
23 '... got the sprintf-ed values');
24
25 is( # sprintf an array ...
26 [ 1 .. 5 ]->do(sub {
27     $_->sprintf(
28         $_->keys
29           ->map(sub { '%d (' . $_ . ')' })
30           ->join(' -> '))
31 }),
32 '1 (0) -> 2 (1) -> 3 (2) -> 4 (3) -> 5 (4)',
33 '... got a more elaboratly sprintf-ed values');
34