xref: /openbsd/gnu/usr.bin/perl/cpan/Pod-Simple/t/basic.t (revision 3d61058a)
1use strict;
2use warnings;
3use Test::More tests => 29;
4
5#use Pod::Simple::Debug (6);
6
7require Pod::Simple::BlackBox;
8ok 1;
9
10require Pod::Simple; ok 1;
11
12Pod::Simple->VERSION(.90); ok 1;
13
14#print "# Pod::Simple version $Pod::Simple::VERSION\n";
15
16require Pod::Simple::DumpAsXML; ok 1;
17
18require Pod::Simple::XMLOutStream; ok 1;
19
20BEGIN {
21  require FindBin;
22  unshift @INC, $FindBin::Bin . '/lib';
23}
24use helpers;
25
26print "# Simple identity tests...\n";
27
28&is( e "", "" );
29&is( e "\n", "", );
30&is( e "\n", "\n", );
31&is( e "puppies\n\n\n\n", "", );
32
33
34print "# Contentful identity tests...\n";
35
36&is( e "=pod\n\nFoo\n",         "=pod\n\nFoo\n"         );
37&is( e "=pod\n\n\n\nFoo\n\n\n", "=pod\n\n\n\nFoo\n\n\n" );
38&is( e "=pod\n\n\n\nFoo\n\n\n", "=pod\n\nFoo\n"         );
39
40# Now with some more newlines
41&is( e "\n\n=pod\n\nFoo\n",     "\n\n=pod\n\nFoo\n"     );
42&is( e "=pod\n\n\n\nFoo\n\n\n", "=pod\n\n\n\nFoo\n\n\n" );
43&is( e "=pod\n\n\n\nFoo\n\n\n", "\n\n=pod\n\nFoo\n"     );
44
45
46&is( e "=head1 Foo\n",          "=head1 Foo\n"          );
47&is( e "=head1 Foo\n\n=cut\n",  "=head1 Foo\n\n=cut\n"  );
48&is( e "=head1 Foo\n\n=cut\n",  "=head1 Foo\n"          );
49
50# Now just add some newlines...
51&is( e "\n\n\n\n=head1 Foo\n",  "\n\n\n\n=head1 Foo\n"  );
52&is( e "=head1 Foo\n\n=cut\n",  "=head1 Foo\n\n=cut\n"  );
53&is( e "=head1 Foo\n\n=cut\n",  "\n\n\n\n=head1 Foo\n"  );
54
55
56print "# Simple XMLification tests...\n";
57
58is( Pod::Simple::XMLOutStream->_out("\n\n\nprint \$^T;\n\n\n"),
59    qq{<Document\ncontentless="1"></Document>}
60     # make sure the contentless flag is set
61);
62is( Pod::Simple::XMLOutStream->_out("\n\n"),
63    qq{<Document\ncontentless="1"></Document>}
64     # make sure the contentless flag is set
65);
66is( Pod::Simple::XMLOutStream->_out("\n"),
67    qq{<Document\ncontentless="1"></Document>}
68     # make sure the contentless flag is set
69);
70is( Pod::Simple::XMLOutStream->_out(""),
71    qq{<Document\ncontentless="1"></Document>}
72     # make sure the contentless flag is set
73);
74
75ok( Pod::Simple::XMLOutStream->_out('', '<Document></Document>' ) );
76
77is( Pod::Simple::XMLOutStream->_out("=pod\n\nFoo\n"),
78    '<Document><Para>Foo</Para></Document>'
79);
80
81is( Pod::Simple::XMLOutStream->_out("=head1 Chacha\n\nFoo\n"),
82    '<Document><head1>Chacha</head1><Para>Foo</Para></Document>'
83);
84
85# Make sure an obviously invalid Pod tag is invalid.
86is( Pod::Simple::XMLOutStream->_out("=F\0blah\n\nwhatever\n"),
87    qq{<Document\ncontentless="1"></Document>}
88);
89