Commit | Line | Data |
---|---|---|
351625bd SP |
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 => 24 }; | |
11 | ||
12 | my $d; | |
13 | #use Pod::Simple::Debug (\$d,0); | |
14 | ||
15 | ok 1; | |
16 | ||
17 | use Pod::Simple::DumpAsXML; | |
18 | use Pod::Simple::XMLOutStream; | |
19 | print "# Pod::Simple version $Pod::Simple::VERSION\n"; | |
20 | sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) } | |
21 | ||
22 | my $x = 'Pod::Simple::XMLOutStream'; | |
23 | ||
24 | print "##### Tests for =item directives via class $x\n"; | |
25 | ||
26 | $Pod::Simple::XMLOutStream::ATTR_PAD = ' '; | |
27 | $Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output | |
28 | ||
29 | ||
30 | print "#\n# Tests for simple =item *'s\n"; | |
31 | ok( $x->_out("\n=over\n\n=item *\n\nStuff\n\n=item *\n\nBar I<baz>!\n\n=back\n\n"), | |
32 | '<Document><over-bullet indent="4"><item-bullet>Stuff</item-bullet><item-bullet>Bar <I>baz</I>!</item-bullet></over-bullet></Document>' | |
33 | ); | |
34 | ok( $x->_out("\n=over\n\n=item *\n\nStuff\n\n=cut\n\nStuff\n\n=item *\n\nBar I<baz>!\n\n=back\n\n"), | |
35 | '<Document><over-bullet indent="4"><item-bullet>Stuff</item-bullet><item-bullet>Bar <I>baz</I>!</item-bullet></over-bullet></Document>' | |
36 | ); | |
37 | ok( $x->_out("\n=over 10\n\n=item *\n\nStuff\n\n=cut\n\nStuff\n\n=item *\n\nBar I<baz>!\n\n=back\n\n"), | |
38 | '<Document><over-bullet indent="10"><item-bullet>Stuff</item-bullet><item-bullet>Bar <I>baz</I>!</item-bullet></over-bullet></Document>' | |
39 | ); | |
40 | ok( $x->_out("\n=over\n\n=item *\n\nStuff\n=cut\nStuff\n\n=item *\n\nBar I<baz>!\n\n=back"), | |
41 | '<Document><over-bullet indent="4"><item-bullet>Stuff</item-bullet><item-bullet>Bar <I>baz</I>!</item-bullet></over-bullet></Document>' | |
42 | ); | |
43 | ||
44 | ||
45 | ||
46 | ||
47 | print "#\n# Tests for simple =item 1.'s\n"; | |
48 | ok( $x->_out("\n=over\n\n=item 1.\n\nStuff\n\n=item 2.\n\nBar I<baz>!\n\n=back\n\n"), | |
49 | '<Document><over-number indent="4"><item-number number="1">Stuff</item-number><item-number number="2">Bar <I>baz</I>!</item-number></over-number></Document>' | |
50 | ); | |
51 | ok( $x->_out("\n=over\n\n=item 1.\n\nStuff\n\n=cut\n\nStuff\n\n=item 2.\n\nBar I<baz>!\n\n=back\n\n"), | |
52 | '<Document><over-number indent="4"><item-number number="1">Stuff</item-number><item-number number="2">Bar <I>baz</I>!</item-number></over-number></Document>' | |
53 | ); | |
54 | # Now without a dot | |
55 | ok( $x->_out("\n=over\n\n=item 1\n\nStuff\n\n=cut\n\nStuff\n\n=item 2\n\nBar I<baz>!\n\n=back\n\n"), | |
56 | '<Document><over-number indent="4"><item-number number="1">Stuff</item-number><item-number number="2">Bar <I>baz</I>!</item-number></over-number></Document>' | |
57 | ); | |
58 | ok( $x->_out("\n=over\n\n=item 1\n\nStuff\n=cut\nStuff\n\n=item 2\n\nBar I<baz>!\n\n=back"), | |
59 | '<Document><over-number indent="4"><item-number number="1">Stuff</item-number><item-number number="2">Bar <I>baz</I>!</item-number></over-number></Document>' | |
60 | ); | |
61 | ||
62 | ||
63 | ||
64 | print "#\n# Tests for =over blocks (without =items)\n"; | |
65 | ok( $x->_out("\n=over\n\nStuff\n\nBar I<baz>!\n\n=back\n\n"), | |
66 | '<Document><over-block indent="4"><Para>Stuff</Para><Para>Bar <I>baz</I>!</Para></over-block></Document>' | |
67 | ); | |
68 | ok( $x->_out("\n=over\n\n Stuff\n\nBar I<baz>!\n\n=back\n\n"), | |
69 | '<Document><over-block indent="4"><Verbatim xml:space="preserve"> Stuff</Verbatim><Para>Bar <I>baz</I>!</Para></over-block></Document>' | |
70 | ); | |
71 | ok( $x->_out("\n=over\n\nBar I<baz>!\n\n Stuff\n\n=back\n\n"), | |
72 | '<Document><over-block indent="4"><Para>Bar <I>baz</I>!</Para><Verbatim xml:space="preserve"> Stuff</Verbatim></over-block></Document>' | |
73 | ); | |
74 | ||
75 | ||
76 | ||
77 | ||
78 | print "#\n# Tests for =item Text blocks...\n"; | |
79 | ok( $x->_out("\n=over\n\n=item Foo\n\nStuff\n\n=cut\n\nCrunk\nZorp\n\n=item Bar I<baz>!\n\nQuux\n\n=back\n\n"), | |
80 | '<Document><over-text indent="4"><item-text>Foo</item-text><Para>Stuff</Para><item-text>Bar <I>baz</I>!</item-text><Para>Quux</Para></over-text></Document>' | |
81 | ); | |
82 | ok( $x->_out("\n=over\n\n=item Foo\n\n Stuff\n\tSnork\n\n=cut\n\nCrunk\nZorp\n\n=item Bar I<baz>!\n\nQuux\n\n=back\n\n"), | |
83 | qq{<Document><over-text indent="4"><item-text>Foo</item-text><Verbatim xml:space="preserve"> Stuff\n Snork</Verbatim>} | |
84 | . qq{<item-text>Bar <I>baz</I>!</item-text><Para>Quux</Para></over-text></Document>} | |
85 | ); | |
86 | ok( $x->_out("\n=over\n\n=item Foo\n\n Stuff\n\tSnork\n=cut\n\nCrunk\nZorp\n\n=item Bar I<baz>!\n\nQuux\n\n=back\n\n"), | |
87 | qq{<Document><over-text indent="4"><item-text>Foo</item-text><Verbatim xml:space="preserve"> Stuff\n Snork</Verbatim>} | |
88 | . qq{<item-text>Bar <I>baz</I>!</item-text><Para>Quux</Para></over-text></Document>} | |
89 | ); | |
90 | ||
91 | ||
92 | ||
93 | print "#\n# Test for mixed =item blocks...\n"; | |
94 | ok( $x->_out("\n=over\n\n=item Foo\n\nStuff\n\n=item 2.\n\nBar I<baz>!\n\nQuux\n\n=item *\n\nThwoong\n\n=back\n\n"), | |
95 | qq{<Document><over-text indent="4"><item-text>Foo</item-text><Para>Stuff</Para>} | |
96 | . qq{<item-text>2.</item-text><Para>Bar <I>baz</I>!</Para><Para>Quux</Para>} | |
97 | . qq{<item-text>*</item-text><Para>Thwoong</Para></over-text></Document>} | |
98 | ); | |
99 | ||
100 | # ok( $x->_out("\n=over\n\n=item *\n\nStuff\n\n=item 2.\n\nBar I<baz>!\n\nQuux\n\n=item *\n\nThwoong\n\n=back\n\n"), | |
101 | # ok( $x->_out("\n=over\n\n=item 1.\n\nStuff\n\n=item 2.\n\nBar I<baz>!\n\nQuux\n\n=item *\n\nThwoong\n\n=back\n\n"), | |
102 | ||
103 | print "#\n# Tests for indenting\n"; | |
104 | ok( $x->_out("\n=over 19\n\n=item *\n\nStuff\n\n=item *\n\nBar I<baz>!\n\n=back\n\n"), | |
105 | '<Document><over-bullet indent="19"><item-bullet>Stuff</item-bullet><item-bullet>Bar <I>baz</I>!</item-bullet></over-bullet></Document>' | |
106 | ); | |
107 | ok( $x->_out("\n=over 19\n\n=item 1.\n\nStuff\n\n=item 2.\n\nBar I<baz>!\n\n=back\n\n"), | |
108 | '<Document><over-number indent="19"><item-number number="1">Stuff</item-number><item-number number="2">Bar <I>baz</I>!</item-number></over-number></Document>' | |
109 | ); | |
110 | ok( $x->_out("\n=over 19\n\nStuff\n\nBar I<baz>!\n\n=back\n\n"), | |
111 | '<Document><over-block indent="19"><Para>Stuff</Para><Para>Bar <I>baz</I>!</Para></over-block></Document>' | |
112 | ); | |
113 | ok( $x->_out("\n=over 19\n\n=item Foo\n\nStuff\n\n=cut\n\nCrunk\nZorp\n\n=item Bar I<baz>!\n\nQuux\n\n=back\n\n"), | |
114 | '<Document><over-text indent="19"><item-text>Foo</item-text><Para>Stuff</Para><item-text>Bar <I>baz</I>!</item-text><Para>Quux</Para></over-text></Document>' | |
115 | ); | |
116 | ||
117 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
118 | ||
119 | print "# Now testing nesting...\n"; | |
120 | ok( $x->_out(join "\n\n", '', | |
121 | '=over', | |
122 | '=item *', | |
123 | 'Stuff', | |
124 | '=cut', | |
125 | 'Stuff', | |
126 | '=over', | |
127 | '=item 1.', | |
128 | '=item 2.', | |
129 | 'Bar I<baz>!', | |
130 | '=back', | |
131 | '=item *', | |
132 | 'Bar I<baz>!', | |
133 | '=back', '' | |
134 | ), join '', | |
135 | '<Document>', | |
136 | '<over-bullet indent="4">', | |
137 | '<item-bullet>Stuff</item-bullet>', | |
138 | '<over-number indent="4">', | |
139 | '<item-number number="1"></item-number>', | |
140 | '<item-number number="2">Bar <I>baz</I>!</item-number>', | |
141 | '</over-number>', | |
142 | '<item-bullet>Bar <I>baz</I>!</item-bullet>', | |
143 | '</over-bullet></Document>' | |
144 | ); | |
145 | ||
146 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
147 | ||
148 | ok( $x->_out( join "\n\n", '', '', | |
149 | '=over', | |
150 | '=item *', | |
151 | 'Stuff', | |
152 | '=cut', | |
153 | 'Stuff', | |
154 | '=over', | |
155 | '=item 1.', | |
156 | '=over 19', | |
157 | 'Gleiven', | |
158 | 'Squim F<.thingrc>!', | |
159 | '=back', | |
160 | '=item 2.', | |
161 | 'Bar I<baz>!', | |
162 | '=back', | |
163 | '=item *', | |
164 | 'Bar I<baz>!', | |
165 | '=back', | |
166 | '', '' | |
167 | ), join '', | |
168 | '<Document>', | |
169 | '<over-bullet indent="4">', | |
170 | '<item-bullet>Stuff</item-bullet>', | |
171 | '<over-number indent="4">', | |
172 | '<item-number number="1"></item-number>', | |
173 | ||
174 | '<over-block indent="19">', | |
175 | '<Para>Gleiven</Para>', | |
176 | '<Para>Squim <F>.thingrc</F>!</Para>', | |
177 | '</over-block>', | |
178 | ||
179 | '<item-number number="2">Bar <I>baz</I>!</item-number>', | |
180 | '</over-number>', | |
181 | '<item-bullet>Bar <I>baz</I>!</item-bullet>', | |
182 | '</over-bullet></Document>' | |
183 | ); | |
184 | ||
185 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
186 | ||
187 | $d = 11; | |
188 | print "# Now checking that document-end closes things right...\n"; | |
189 | ||
190 | ok( $x->_out( join "\n\n", '', '', | |
191 | '=over', | |
192 | '=item *', | |
193 | 'Stuff', | |
194 | '=cut', | |
195 | 'Stuff', | |
196 | '=over', | |
197 | '=item 1.', | |
198 | '=over 19', | |
199 | 'Gleiven', | |
200 | 'Squim F<.thingrc>!', | |
201 | '', '' | |
202 | ), join '', | |
203 | '<Document>', | |
204 | '<over-bullet indent="4">', | |
205 | '<item-bullet>Stuff</item-bullet>', | |
206 | '<over-number indent="4">', | |
207 | '<item-number number="1"></item-number>', | |
208 | ||
209 | '<over-block indent="19">', | |
210 | '<Para>Gleiven</Para>', | |
211 | '<Para>Squim <F>.thingrc</F>!</Para>', | |
212 | '</over-block>', | |
213 | '</over-number>', | |
214 | '</over-bullet></Document>' | |
215 | ); | |
216 | ||
217 | ||
218 | ||
219 | # TODO: more checking of coercion in nesting? | |
220 | ||
221 | ||
222 | ||
223 | print "# Wrapping up... one for the road...\n"; | |
224 | ok 1; | |
225 | print "# --- Done with ", __FILE__, " --- \n"; | |
226 |