xref: /openbsd-src/gnu/usr.bin/perl/cpan/Pod-Simple/t/heads.t (revision 5486feefcc8cb79b19e014ab332cc5dfd05b3b33)
1use strict;
2use warnings;
3use Test::More tests => 21;
4
5#use Pod::Simple::Debug (6);
6
7BEGIN {
8  require FindBin;
9  unshift @INC, $FindBin::Bin . '/lib';
10}
11use helpers;
12
13use Pod::Simple::DumpAsXML;
14use Pod::Simple::XMLOutStream;
15print "# Pod::Simple version $Pod::Simple::VERSION\n";
16
17
18print "# Simple tests for head1 - head6...\n";
19is( Pod::Simple::XMLOutStream->_out("\n=head1 Chacha\n\n"),
20    '<Document><head1>Chacha</head1></Document>'
21);
22is( Pod::Simple::XMLOutStream->_out("\n=head2 Chacha\n\n"),
23    '<Document><head2>Chacha</head2></Document>'
24);
25is( Pod::Simple::XMLOutStream->_out("\n=head3 Chacha\n\n"),
26    '<Document><head3>Chacha</head3></Document>'
27);
28is( Pod::Simple::XMLOutStream->_out("\n=head4 Chacha\n\n"),
29    '<Document><head4>Chacha</head4></Document>'
30);
31is( Pod::Simple::XMLOutStream->_out("\n=head5 Chacha\n\n"),
32    '<Document><head5>Chacha</head5></Document>'
33);
34is( Pod::Simple::XMLOutStream->_out("\n=head6 Chacha\n\n"),
35    '<Document><head6>Chacha</head6></Document>'
36);
37
38print "# Testing whitespace equivalence...\n";
39
40&is(e "\n=head1 Chacha\n\n", "\n=head1       Chacha\n\n");
41&is(e "\n=head1 Chacha\n\n", "\n=head1\tChacha\n\n");
42&is(e "\n=head1 Chacha\n\n", "\n=head1\tChacha      \n\n");
43
44
45
46is( Pod::Simple::XMLOutStream->_out("=head1     Chachacha"),
47    '<Document><head1>Chachacha</head1></Document>'
48);
49
50
51print "# Testing whitespace variance ...\n";
52is( Pod::Simple::XMLOutStream->_out("=head1     Cha cha cha   \n"),
53    '<Document><head1>Cha cha cha</head1></Document>'
54);
55is( Pod::Simple::XMLOutStream->_out("=head1     Cha   cha\tcha   \n"),
56    '<Document><head1>Cha cha cha</head1></Document>'
57);
58
59
60
61
62print "# Testing head2 ... head6 more...\n";
63
64is( Pod::Simple::XMLOutStream->_out("=head2     Cha   cha\tcha   \n"),
65    '<Document><head2>Cha cha cha</head2></Document>'
66);
67is( Pod::Simple::XMLOutStream->_out("=head3     Cha   cha\tcha   \n"),
68    '<Document><head3>Cha cha cha</head3></Document>'
69);
70is( Pod::Simple::XMLOutStream->_out("=head4     Cha   cha\tcha   \n"),
71    '<Document><head4>Cha cha cha</head4></Document>'
72);
73is( Pod::Simple::XMLOutStream->_out("=head5     Cha   cha\tcha   \n"),
74    '<Document><head5>Cha cha cha</head5></Document>'
75);
76is( Pod::Simple::XMLOutStream->_out("=head6     Cha   cha\tcha   \n"),
77    '<Document><head6>Cha cha cha</head6></Document>'
78);
79
80print "# Testing entity expansion...\n";
81
82is( Pod::Simple::XMLOutStream->_out("=head4 fooE<64>bar!\n"),
83    Pod::Simple::XMLOutStream->_out("\n=head4  foo\@bar!\n\n"),
84);
85
86# TODO: a mode so that DumpAsXML can ask for all contiguous string
87#  sequences to be fused?
88# &ok( e "=head4 fooE<64>bar!\n", "\n=head4  foo\@bar!\n\n");
89
90print "# Testing formatting sequences...\n";
91
92# True only if the sequences resolve, as they should...
93&is( e "=head4 C<foobar!>\n", "\n=head4 C<< foobar!    >>\n\n");
94&is( e "=head4 C<foobar!>\n", "\n\n=head4 C<<<  foobar! >>>\n");
95&is( e "=head4 C<foobar!>\n", "\n=head4 C<< foobar!\n\t>>\n\n");
96