File: sort_groups.t

package info (click to toggle)
libcpan-changes-perl 0.500005-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,964 kB
  • sloc: perl: 988; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 899 bytes parent folder | download
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
39
40
41
use strict;
use warnings;

use Test::More;

use CPAN::Changes;

my $changes = CPAN::Changes->load_string(<<'END_CHANGES');
1.05 2011-04-17
    [A]
    - stuff
    [B]
    - mo' stuff
1.04 2011-04-16
    [C]
    - stuff
    [D]
    - mo' stuff
END_CHANGES

like $changes->serialize => expected_order(qw/ A B C D/ );
like $changes->serialize( group_sort => \&reverse_order ) => expected_order(qw/ B A D C/ );

my ($release) = reverse $changes->releases;
like $release->serialize => expected_order(qw/ A B / );
like $release->serialize( group_sort => \&reverse_order ) => expected_order(qw/ B A / );

is_deeply [ $release->groups ], [qw/ A B /];
is_deeply [ $release->groups( sort => \&reverse_order ) ], [qw/ B A /];

sub reverse_order {
    return reverse sort @_;
}

sub expected_order {
    my @groups = @_;
    my $re = join '.*', map { "\\[$_\\]" } @groups;
    return qr/$re/s;
}

done_testing;