xref: /openbsd/gnu/usr.bin/perl/cpan/Pod-Simple/t/fcodes.t (revision 8932bfb7)
1BEGIN {
2    if($ENV{PERL_CORE}) {
3        chdir 't';
4        @INC = '../lib';
5    }
6}
7
8use strict;
9use Test;
10BEGIN { plan tests => 23 };
11
12#use Pod::Simple::Debug (5);
13
14ok 1;
15
16use Pod::Simple::DumpAsXML;
17use Pod::Simple::XMLOutStream;
18print "# Pod::Simple version $Pod::Simple::VERSION\n";
19sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }
20
21print "# With weird leading whitespace...\n";
22# With weird whitespace
23ok( Pod::Simple::XMLOutStream->_out("=pod\n\nI<foo>\n"),
24 '<Document><Para><I>foo</I></Para></Document>'
25);
26ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB< foo>\n"),
27 '<Document><Para><B> foo</B></Para></Document>'
28);
29ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB<\tfoo>\n"),
30 '<Document><Para><B> foo</B></Para></Document>'
31);
32ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB<\nfoo>\n"),
33 '<Document><Para><B> foo</B></Para></Document>'
34);
35ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB<foo>\n"),
36 '<Document><Para><B>foo</B></Para></Document>'
37);
38ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB<foo\t>\n"),
39 '<Document><Para><B>foo </B></Para></Document>'
40);
41ok( Pod::Simple::XMLOutStream->_out("=pod\n\nB<foo\n>\n"),
42 '<Document><Para><B>foo </B></Para></Document>'
43);
44
45
46print "#\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
52print "# A complex test with internal whitespace...\n";
53ok( 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
58print "# Without any nesting...\n";
59ok( 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
63print "# Without any nesting, but with Z's...\n";
64ok( 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
69print "# With lots of nesting, and Z's...\n";
70ok( 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
76print "#\n# *** Now testing different numbers of wedges ***\n";
77print "# Without any nesting...\n";
78ok( 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
82print "# Without any nesting, but with Z's, and odder whitespace...\n";
83ok( 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
87print "# With nesting and Z's, and odder whitespace...\n";
88ok( 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
92print "# Regression https://rt.cpan.org/Ticket/Display.html?id=55602 (vs 12239)\n";
93ok( Pod::Simple::XMLOutStream->_out("=pod\n\nC<<< foo->bar >>>\n"),
94 '<Document><Para><C>foo-&#62;bar</C></Para></Document>'
95);
96ok( Pod::Simple::XMLOutStream->_out("=pod\n\nC<<< C<foo> >>>\n"),
97 '<Document><Para><C><C>foo</C></C></Para></Document>'
98);
99ok( Pod::Simple::XMLOutStream->_out("=pod\n\nC<<< C<<foo>> >>>\n"),
100 '<Document><Para><C><C>&#60;foo</C>&#62;</C></Para></Document>'
101);
102ok( Pod::Simple::XMLOutStream->_out("=pod\n\nC<<< CZ<><<foo>> >>>\n"),
103 '<Document><Para><C>C&#60;&#60;foo&#62;&#62;</C></Para></Document>'
104);
105ok( 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
109print "# Misc...\n";
110ok( 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
124print "# Wrapping up... one for the road...\n";
125ok 1;
126print "# --- Done with ", __FILE__, " --- \n";
127
128
129