Skip to content

Commit 204cc67

Browse files
bookericherman
authored andcommitted
add a test script for Porting/merge-deltas.pl
1 parent c9dcb53 commit 204cc67

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

t/porting/merge-deltas.t

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
use v5.36;
2+
use Test2::V0;
3+
4+
# load the script
5+
do('./Porting/merge-deltas.pl') or die $@ || $!;
6+
7+
# tree_for & as_pod
8+
{
9+
my $pod = <<~ 'POD';
10+
=head2 CVE-2025-12345
11+
12+
Some CVE was fixed.
13+
14+
Found by some person.
15+
16+
=cut
17+
POD
18+
19+
# just a single test: we're not testing Pod::Simple::SimpleTree
20+
is(
21+
tree_for($pod),
22+
[
23+
Document => { start_line => 1 },
24+
[ head2 => { start_line => 1 }, 'CVE-2025-12345' ],
25+
[ Para => { start_line => 3 }, 'Some CVE was fixed.' ],
26+
[ Para => { start_line => 5 }, 'Found by some person.' ],
27+
],
28+
'tree_for'
29+
);
30+
31+
# as_pod round-trips basic POD
32+
is( as_pod( tree_for($pod) ), $pod, 'as_pod' );
33+
}
34+
35+
# loop_head1
36+
{
37+
my $template_file = 'Porting/perldelta_template.pod';
38+
my $template = tree_for( slurp($template_file) );
39+
40+
# loop_head1 dies on unexpected =head1
41+
# the callback is only run on the unskipped sections
42+
ok(
43+
lives {
44+
loop_head1(
45+
[],
46+
$template,
47+
$template_file,
48+
sub ( $master, $title, $template ) {
49+
is( $title, L(), "=head1 $title" );
50+
}
51+
);
52+
},
53+
'loop_head1'
54+
);
55+
}
56+
57+
# copy_section
58+
{
59+
my $master_pod = <<~ 'POD';
60+
=head1 NAME
61+
62+
Master perldelta
63+
64+
=head1 Notice
65+
66+
XXX Some notice
67+
68+
=head1 Acknowledgments
69+
POD
70+
my $delta_pod = <<~ 'POD';
71+
=head1 NAME
72+
73+
Devel perldelta
74+
75+
=head1 Notice
76+
77+
Devel notice
78+
79+
=head1 Acknowledgments
80+
POD
81+
my $master = tree_for($master_pod);
82+
copy_section( $master, 'Notice', tree_for($delta_pod) );
83+
is( as_pod($master), <<~ 'EXPECTED', 'copy_section' );
84+
=head1 NAME
85+
86+
Master perldelta
87+
88+
=head1 Notice
89+
90+
Devel notice
91+
92+
XXX Some notice
93+
94+
=head1 Acknowledgments
95+
96+
=cut
97+
EXPECTED
98+
}
99+
100+
# remove_identical
101+
{
102+
my $pod = <<~ 'POD';
103+
=head1 NAME
104+
105+
Template perldelta
106+
107+
=head1 Notice
108+
109+
XXX Some notice
110+
111+
=head1 Acknowledgments
112+
POD
113+
114+
my $master = tree_for( $pod =~ s/Template/Master/r );
115+
remove_identical( $master, 'Notice', tree_for($pod) );
116+
is( as_pod($master), <<~ 'EXPECTED', 'remove_identical' );
117+
=head1 NAME
118+
119+
Master perldelta
120+
121+
=head1 Acknowledgments
122+
123+
=cut
124+
EXPECTED
125+
}
126+
127+
done_testing;

0 commit comments

Comments
 (0)