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