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