File: | t/02-List-Util.t |
Coverage: | 100.0% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | #!perl | ||||||
2 | |||||||
3 | 1 1 1 | 90728 3 87 | use strict; | ||||
4 | 1 1 1 | 4 1 42 | use warnings; | ||||
5 | |||||||
6 | 1 1 1 | 611 95162 10 | use Test::More tests => 23; | ||||
7 | |||||||
8 | 1 1 1 | 1580 4 95 | use Util::Underscore; | ||||
9 | |||||||
10 | 1 | 177905 | my %lu_aliases = qw/ | ||||
11 | reduce reduce | ||||||
12 | any any | ||||||
13 | all all | ||||||
14 | none none | ||||||
15 | max max | ||||||
16 | max_str maxstr | ||||||
17 | min min | ||||||
18 | min_str minstr | ||||||
19 | sum sum | ||||||
20 | product product | ||||||
21 | pairgrep pairgrep | ||||||
22 | pairfirst pairfirst | ||||||
23 | pairmap pairmap | ||||||
24 | shuffle shuffle | ||||||
25 | /; | ||||||
26 | |||||||
27 | 1 | 8 | while (my ($k, $v) = each %lu_aliases) { | ||||
28 | 1 1 1 | 6 1 128 | no strict 'refs'; | ||||
29 | 14 14 14 | 8412 55 83 | ok \&{"_::$k"} == \&{"List::Util::$v"}, "_::$k == List::Util::$v"; | ||||
30 | } | ||||||
31 | |||||||
32 | 1 | 590 | my %lmu_aliases = qw/ | ||||
33 | first first_value | ||||||
34 | first_index first_index | ||||||
35 | last last_value | ||||||
36 | last_index last_index | ||||||
37 | natatime natatime | ||||||
38 | uniq uniq | ||||||
39 | part part | ||||||
40 | each_array each_arrayref | ||||||
41 | /; | ||||||
42 | |||||||
43 | 1 | 8 | while (my ($k, $v) = each %lmu_aliases) { | ||||
44 | 1 1 1 | 4 1 2080 | no strict 'refs'; | ||||
45 | 8 8 8 | 4746 43 49 | ok \&{"_::$k"} == \&{"List::MoreUtils::$v"}, "_::$k == List::MoreUtils::$v"; | ||||
46 | } | ||||||
47 | |||||||
48 | # Special test for "zip": | ||||||
49 | |||||||
50 | 1 | 633 | my @xs = qw/a b c d/; | ||||
51 | 1 | 3 | my @ys = qw/1 2 3/; | ||||
52 | 1 | 6 | is_deeply [ _::zip \@xs, \@ys ], [ a => 1, b => 2, c => 3, d => undef ], | ||||
53 | '_::zip sanity test'; |