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 / fcodes.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 => 23 };
11
12 #use Pod::Simple::Debug (5);
13
14 ok 1;
15
16 use Pod::Simple::DumpAsXML;
17 use Pod::Simple::XMLOutStream;
18 print "# Pod::Simple version $Pod::Simple::VERSION\n";
19 sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }
20
21 print "# With weird leading whitespace...\n";
22 # With weird whitespace
23 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nI<foo>\n"),
24  '<Document><Para><I>foo</I></Para></Document>'
25 );
26 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB< foo>\n"),
27  '<Document><Para><B> foo</B></Para></Document>'
28 );
29 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB<\tfoo>\n"),
30  '<Document><Para><B> foo</B></Para></Document>'
31 );
32 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB<\nfoo>\n"),
33  '<Document><Para><B> foo</B></Para></Document>'
34 );
35 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB<foo>\n"),
36  '<Document><Para><B>foo</B></Para></Document>'
37 );
38 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB<foo\t>\n"),
39  '<Document><Para><B>foo </B></Para></Document>'
40 );
41 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB<foo\n>\n"),
42  '<Document><Para><B>foo </B></Para></Document>'
43 );
44
45
46 print "#\n# Tests for wedges outside of formatting codes...\n";
47 &ok( Pod::Simple::XMLOutStream->_out("=pod\n\nX < 3 and N > 19\n"),
48      Pod::Simple::XMLOutStream->_out("=pod\n\nX E<lt> 3 and N E<gt> 19\n")
49 );
50
51
52 print "# A complex test with internal whitespace...\n";
53 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nI<foo>B< bar>C<baz >F< quux\t?>\n"),
54  '<Document><Para><I>foo</I><B> bar</B><C>baz </C><F> quux ?</F></Para></Document>'
55 );
56
57
58 print "# Without any nesting...\n";
59 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nF<a>C<b>I<c>B<d>X<e>\n"),
60  '<Document><Para><F>a</F><C>b</C><I>c</I><B>d</B><X>e</X></Para></Document>'
61 );
62
63 print "# Without any nesting, but with Z's...\n";
64 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nZ<>F<a>C<b>I<c>B<d>X<e>\n"),
65  '<Document><Para><F>a</F><C>b</C><I>c</I><B>d</B><X>e</X></Para></Document>'
66 );
67
68
69 print "# With lots of nesting, and Z's...\n";
70 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nZ<>F<C<Z<>foo> I<bar>> B<X<thingZ<>>baz>\n"),
71  '<Document><Para><F><C>foo</C> <I>bar</I></F> <B><X>thing</X>baz</B></Para></Document>'
72 );
73
74
75
76 print "#\n# *** Now testing different numbers of wedges ***\n";
77 print "# Without any nesting...\n";
78 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nF<< a >>C<<< b >>>I<<<< c >>>>B<< d >>X<< e >>\n"),
79  '<Document><Para><F>a</F><C>b</C><I>c</I><B>d</B><X>e</X></Para></Document>'
80 );
81
82 print "# Without any nesting, but with Z's, and odder whitespace...\n";
83 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nF<< aZ<> >>C<<< Z<>b >>>I<<<< c  >>>>B<< d \t >>X<<\ne >>\n"),
84   '<Document><Para><F>a</F><C>b</C><I>c</I><B>d</B><X>e</X></Para></Document>'
85 );
86
87 print "# With nesting and Z's, and odder whitespace...\n";
88 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nF<< aZ<> >>C<<< Z<>bZ<>B<< d \t >>X<<\ne >> >>>I<<<< c  >>>>\n"),
89  "<Document><Para><F>a</F><C>b<B>d</B><X>e</X></C><I>c</I></Para></Document>"
90 );
91
92 print "# Regression https://rt.cpan.org/Ticket/Display.html?id=55602 (vs 12239)\n";
93 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nC<<< foo->bar >>>\n"),
94  '<Document><Para><C>foo-&#62;bar</C></Para></Document>'
95 );
96 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nC<<< C<foo> >>>\n"),
97  '<Document><Para><C><C>foo</C></C></Para></Document>'
98 );
99 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nC<<< C<<foo>> >>>\n"),
100  '<Document><Para><C><C>&#60;foo</C>&#62;</C></Para></Document>'
101 );
102 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nC<<< CZ<><<foo>> >>>\n"),
103  '<Document><Para><C>C&#60;&#60;foo&#62;&#62;</C></Para></Document>'
104 );
105 ok( Pod::Simple::XMLOutStream->_out("=pod\n\nC<<< CE<lt><foo>> >>>\n"),
106  '<Document><Para><C>C&#60;&#60;foo&#62;&#62;</C></Para></Document>'
107 );
108
109 print "# Misc...\n";
110 ok( Pod::Simple::XMLOutStream->_out(
111  "=pod\n\nI like I<PIE> with B<cream> and Stuff and N < 3 and X<< things >> hoohah\n"
112 ."And I<pie is B<also> a happy time>.\n"
113 ."And B<I<<< I like pie >>>.>\n"
114 ) =>
115 "<Document><Para>I like <I>PIE</I> with <B>cream</B> and Stuff and N &#60; 3 and <X>things</X> hoohah "
116 ."And <I>pie is <B>also</B> a happy time</I>. "
117 ."And <B><I>I like pie</I>.</B></Para></Document>"
118 );
119
120
121
122
123
124 print "# Wrapping up... one for the road...\n";
125 ok 1;
126 print "# --- Done with ", __FILE__, " --- \n";
127
128