This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Pod-Simple to CPAN version 3.18
[perl5.git] / cpan / Pod-Simple / t / basic.t
1 BEGIN {
2     if($ENV{PERL_CORE}) {
3         chdir 't';
4         @INC = '../lib';
5     }
6 }
7
8 use strict;
9 use Test;
10 BEGIN { plan tests => 30 };
11
12 #use Pod::Simple::Debug (6);
13
14 ok 1;
15
16 require Pod::Simple::BlackBox;
17 ok 1;
18
19 require Pod::Simple; ok 1;
20
21 Pod::Simple->VERSION(.90); ok 1;
22
23 #print "# Pod::Simple version $Pod::Simple::VERSION\n";
24
25 require Pod::Simple::DumpAsXML; ok 1;
26
27 require Pod::Simple::XMLOutStream; ok 1;
28
29 sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }
30
31 print "# Simple identity tests...\n";
32
33 &ok( e "", "" );
34 &ok( e "\n", "", );
35 &ok( e "\n", "\n", );
36 &ok( e "puppies\n\n\n\n", "", );
37
38
39 print "# Contentful identity tests...\n";
40
41 &ok( e "=pod\n\nFoo\n",         "=pod\n\nFoo\n"         );
42 &ok( e "=pod\n\n\n\nFoo\n\n\n", "=pod\n\n\n\nFoo\n\n\n" );
43 &ok( e "=pod\n\n\n\nFoo\n\n\n", "=pod\n\nFoo\n"         );
44
45 # Now with some more newlines
46 &ok( e "\n\n=pod\n\nFoo\n",     "\n\n=pod\n\nFoo\n"     );
47 &ok( e "=pod\n\n\n\nFoo\n\n\n", "=pod\n\n\n\nFoo\n\n\n" );
48 &ok( e "=pod\n\n\n\nFoo\n\n\n", "\n\n=pod\n\nFoo\n"     );
49
50
51 &ok( e "=head1 Foo\n",          "=head1 Foo\n"          );
52 &ok( e "=head1 Foo\n\n=cut\n",  "=head1 Foo\n\n=cut\n"  );
53 &ok( e "=head1 Foo\n\n=cut\n",  "=head1 Foo\n"          );
54
55 # Now just add some newlines...
56 &ok( e "\n\n\n\n=head1 Foo\n",  "\n\n\n\n=head1 Foo\n"  );
57 &ok( e "=head1 Foo\n\n=cut\n",  "=head1 Foo\n\n=cut\n"  );
58 &ok( e "=head1 Foo\n\n=cut\n",  "\n\n\n\n=head1 Foo\n"  );
59
60
61 print "# Simple XMLification tests...\n";
62
63 ok( Pod::Simple::XMLOutStream->_out("\n\n\nprint \$^T;\n\n\n"),
64     qq{<Document\ncontentless="1"></Document>}
65      # make sure the contentless flag is set
66 );
67 ok( Pod::Simple::XMLOutStream->_out("\n\n"),
68     qq{<Document\ncontentless="1"></Document>}
69      # make sure the contentless flag is set
70 );
71 ok( Pod::Simple::XMLOutStream->_out("\n"),
72     qq{<Document\ncontentless="1"></Document>}
73      # make sure the contentless flag is set
74 );
75 ok( Pod::Simple::XMLOutStream->_out(""),
76     qq{<Document\ncontentless="1"></Document>}
77      # make sure the contentless flag is set
78 );
79
80 ok( Pod::Simple::XMLOutStream->_out('', '<Document></Document>' ) );
81
82 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nFoo\n"),
83     '<Document><Para>Foo</Para></Document>'
84 );
85
86 ok( Pod::Simple::XMLOutStream->_out("=head1 Chacha\n\nFoo\n"),
87     '<Document><head1>Chacha</head1><Para>Foo</Para></Document>'
88 );
89
90
91 print "# Wrapping up... one for the road...\n";
92 ok 1;
93 print "# --- Done with ", __FILE__, " --- \n";
94
95