1#!/bin/perl -w
2
3use strict;
4use lib '.', 't/lib','../blib/lib','./blib/lib';
5use Test::More tests => 18;
6
7BEGIN { use_ok('CGI::Pretty') };
8
9# This is silly use_ok should take arguments
10use CGI::Pretty (':all');
11
12is(h1(), '<h1 />
13',"single tag");
14
15is(ol(li('fred'),li('ethel')), <<HTML,   "basic indentation");
16<ol>
17	<li>
18		fred
19	</li>
20	<li>
21		ethel
22	</li>
23</ol>
24HTML
25
26
27is(p('hi',pre('there'),'frog'), <<HTML, "<pre> tags");
28<p>
29	hi <pre>there</pre>
30	frog
31</p>
32HTML
33
34is(h1({-align=>'CENTER'},'fred'), <<HTML, "open/close tag with attribute");
35<h1 align="CENTER">
36	fred
37</h1>
38HTML
39
40is(h1({-align=>undef},'fred'), <<HTML,"open/close tag with orphan attribute");
41<h1 align>
42	fred
43</h1>
44HTML
45
46is(h1({-align=>'CENTER'},['fred','agnes']), <<HTML, "distributive tag with attribute");
47<h1 align="CENTER">
48	fred
49</h1>
50<h1 align="CENTER">
51	agnes
52</h1>
53HTML
54
55is(p('hi',a({-href=>'frog'},'there'),'frog'), <<HTML,   "as-is");
56<p>
57	hi <a href="frog">there</a>
58	frog
59</p>
60HTML
61
62is(p([ qw( hi there frog ) ] ), <<HTML,   "array-reference");
63<p>
64	hi
65</p>
66<p>
67	there
68</p>
69<p>
70	frog
71</p>
72HTML
73
74is(p(p(p('hi'), 'there' ), 'frog'), <<HTML,   "nested tags");
75<p>
76	<p>
77		<p>
78			hi
79		</p>
80		there
81	</p>
82	frog
83</p>
84HTML
85
86is(table(TR(td(table(TR(td('hi', 'there', 'frog')))))), <<HTML,   "nested as-is tags");
87<table>
88	<tr>
89		<td><table>
90			<tr>
91				<td>hi there frog</td>
92			</tr>
93		</table></td>
94	</tr>
95</table>
96HTML
97
98is(table(TR(td(table(TR(td( [ qw( hi there frog ) ])))))), <<HTML,   "nested as-is array-reference");
99<table>
100	<tr>
101		<td><table>
102			<tr>
103				<td>hi</td>
104				<td>there</td>
105				<td>frog</td>
106			</tr>
107		</table></td>
108	</tr>
109</table>
110HTML
111
112$CGI::Pretty::INDENT = $CGI::Pretty::LINEBREAK = ""; 
113
114is(h1(), '<h1 />',"single tag (pretty turned off)");
115is(h1('fred'), '<h1>fred</h1>',"open/close tag (pretty turned off)");
116is(h1('fred','agnes','maura'), '<h1>fred agnes maura</h1>',"open/close tag multiple (pretty turned off)");
117is(h1({-align=>'CENTER'},'fred'), '<h1 align="CENTER">fred</h1>',"open/close tag with attribute (pretty turned off)");
118is(h1({-align=>undef},'fred'), '<h1 align>fred</h1>',"open/close tag with orphan attribute (pretty turned off)");
119is(h1({-align=>'CENTER'},['fred','agnes']), '<h1 align="CENTER">fred</h1> <h1 align="CENTER">agnes</h1>',
120   "distributive tag with attribute (pretty turned off)");
121
122