This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Pod::Html - correctly link to =item's on the same page
[perl5.git] / lib / Pod / t / eol.t
1 #!./perl -w
2
3 use Test::More tests => 3;
4
5 open(POD, ">$$.pod") or die "$$.pod: $!";
6 print POD <<__EOF__;
7 =pod
8
9 =head1 NAME
10
11 crlf
12
13 =head1 DESCRIPTION
14
15 crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
16 crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
17 crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
18 crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
19
20     crlf crlf crlf crlf
21     crlf crlf crlf crlf
22     crlf crlf crlf crlf
23
24 crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
25 crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
26 crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
27 crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
28
29 =cut
30 __EOF__
31 close(POD);
32
33 use Pod::Html;
34
35 # --- CR ---
36
37 open(POD, "<$$.pod") or die "$$.pod: $!";
38 open(IN,  ">$$.in")  or die "$$.in: $!";
39 while (<POD>) {
40   s/[\r\n]+/\r/g;
41   print IN $_;
42 }
43 close(POD);
44 close(IN);
45
46 pod2html("--title=eol", "--infile=$$.in", "--outfile=$$.o1");
47
48 # --- LF ---
49
50 open(POD, "<$$.pod") or die "$$.pod: $!";
51 open(IN,  ">$$.in")  or die "$$.in: $!";
52 while (<POD>) {
53   s/[\r\n]+/\n/g;
54   print IN $_;
55 }
56 close(POD);
57 close(IN);
58
59 pod2html("--title=eol", "--infile=$$.in", "--outfile=$$.o2");
60
61 # --- CRLF ---
62
63 open(POD, "<$$.pod") or die "$$.pod: $!";
64 open(IN,  ">$$.in")  or die "$$.in: $!";
65 while (<POD>) {
66   s/[\r\n]+/\r\n/g;
67   print IN $_;
68 }
69 close(POD);
70 close(IN);
71
72 pod2html("--title=eol", "--infile=$$.in", "--outfile=$$.o3");
73
74 # --- now test ---
75
76 local $/;
77
78 open(IN, "<$$.o1") or die "$$.o1: $!";
79 my $cksum1 = unpack("%32C*", <IN>);
80
81 open(IN, "<$$.o2") or die "$$.o2: $!";
82 my $cksum2 = unpack("%32C*", <IN>);
83
84 open(IN, "<$$.o3") or die "$$.o3: $!";
85 my $cksum3 = unpack("%32C*", <IN>);
86
87 ok($cksum1 == $cksum2, "CR vs LF");
88 ok($cksum1 == $cksum3, "CR vs CRLF");
89 ok($cksum2 == $cksum3, "LF vs CRLF");
90 close IN;
91
92 END {
93   1 while unlink("$$.pod", "$$.in", "$$.o1", "$$.o2", "$$.o3",
94                  "pod2htmd.x~~", "pod2htmi.x~~");
95 }