File: serialize.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 (184 lines) | stat: -rw-r--r-- 4,163 bytes parent folder | download | duplicates (4)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
use strict;
use warnings;

use Test::More;

use CPAN::Changes;

my $changes = CPAN::Changes->new;
$changes->add_release(
    {   date    => '2010-06-16',
        version => '0.01',
        changes => { '' => [ 'Initial release' ] },
    }
);

{
    my $expected = <<EOCHANGES;
0.01 2010-06-16
 - Initial release
EOCHANGES

    is( $changes->serialize, $expected, 'serialize' );
}

{
    $changes->preamble( 'Revision history for perl module Foo::Bar' );

    my $expected = <<EOCHANGES;
Revision history for perl module Foo::Bar

0.01 2010-06-16
 - Initial release
EOCHANGES

    is( $changes->serialize, $expected, 'serialize with preamble' );
}

{
    my $release = $changes->release( '0.01' );
    $release->clear_changes;
    $release->add_changes( { group => 'Group 1' }, 'Initial release' );

    my $expected = <<EOCHANGES;
Revision history for perl module Foo::Bar

0.01 2010-06-16
 [Group 1]
 - Initial release
EOCHANGES

    is( $changes->serialize, $expected,
        'serialize with ground and preamble' );
}

{
    $changes->add_release(
        {   version => '0.02',
            date    => '2010-06-17',
            changes => { '' => [ 'New version' ] },
        }
    );

    my $expected = <<EOCHANGES;
Revision history for perl module Foo::Bar

0.02 2010-06-17
 - New version

0.01 2010-06-16
 [Group 1]
 - Initial release
EOCHANGES

    is( $changes->serialize, $expected, 'serialize with multiple releases' );
}

{
    $changes->releases(
        {   version => '0.01',
            date    => '2010-06-16',
            changes => {
                '' => [
                    'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In quis tortor ac urna faucibus feugiat.'
                ]
            },
        }
    );

    my $expected = <<EOCHANGES;
Revision history for perl module Foo::Bar

0.01 2010-06-16
 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. In quis tortor
   ac urna faucibus feugiat.
EOCHANGES

    is( $changes->serialize, $expected, 'serialize with line-wrap' );
}

{
    $changes->releases(
        {   version => '0.01',
            date    => '2010-06-16',
            note    => 'Note',
            changes => {
                '' => [
                    'Test'
                ]
            },
        }
    );

    my $expected = <<EOCHANGES;
Revision history for perl module Foo::Bar

0.01 2010-06-16 Note
 - Test
EOCHANGES

    is( $changes->serialize, $expected, 'serialize with note' );
}

{
    $changes->releases(
        {   version => '0.01',
            date    => 'Unknown',
            note    => '(Oops)',
            changes => {
                '' => [
                    'Test'
                ]
            },
        }
    );

    my $expected = <<EOCHANGES;
Revision history for perl module Foo::Bar

0.01 Unknown (Oops)
 - Test
EOCHANGES

    is( $changes->serialize, $expected, 'serialize with unknown date and note' );
}

{
    my $changes = CPAN::Changes->new;
    $changes->add_release(
        {   date    => '',
            version => '0.01',
            note    => '',
            changes => { '' => [ 'Initial release' ] },
        }
    );
    my $expected = <<EOCHANGES;
0.01
 - Initial release
EOCHANGES

    is( $changes->serialize, $expected, 'serialize w/ defined but empty date and note' );
}

{
    my $changes = CPAN::Changes->new;
    $changes->add_release(
        {   date    => '',
            version => '0.01',
            note    => '',
            changes => { '' => [
                'http://www.cpan.org/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz',
                "\x{026B}this_entry_should_not_be_wrapped_on_the_nonbreaking_space\x{00A0}in_it_even_though_it_is_over_80_characters_long",
            ] },
        }
    );
    my $expected = <<EOCHANGES;
0.01
 - http://www.cpan.org/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
 - \x{026B}this_entry_should_not_be_wrapped_on_the_nonbreaking_space\x{00A0}in_it_even_though_it_is_over_80_characters_long
EOCHANGES

    is( $changes->serialize, $expected, 'serialize does not wrap long tokens or split on nbsp' );
}

done_testing;