Commit | Line | Data |
188ba755 |
1 | #!/bin/perl -w |
f0c07f2e |
2 | |
ac734d8b |
3 | use strict; |
188ba755 |
4 | use lib '.', 't/lib','../blib/lib','./blib/lib'; |
5 | use Test::More tests => 18; |
ac734d8b |
6 | |
7 | BEGIN { use_ok('CGI::Pretty') }; |
8 | |
9 | # This is silly use_ok should take arguments |
10 | use CGI::Pretty (':all'); |
11 | |
188ba755 |
12 | is(h1(), '<h1 /> |
13 | ',"single tag"); |
ac734d8b |
14 | |
15 | is(ol(li('fred'),li('ethel')), <<HTML, "basic indentation"); |
16 | <ol> |
17 | <li> |
18 | fred |
19 | </li> |
20 | <li> |
21 | ethel |
22 | </li> |
23 | </ol> |
24 | HTML |
25 | |
26 | |
27 | is(p('hi',pre('there'),'frog'), <<HTML, "<pre> tags"); |
28 | <p> |
6b4ac661 |
29 | hi <pre>there</pre> |
ac734d8b |
30 | frog |
6b4ac661 |
31 | </p> |
ac734d8b |
32 | HTML |
33 | |
188ba755 |
34 | is(h1({-align=>'CENTER'},'fred'), <<HTML, "open/close tag with attribute"); |
35 | <h1 align="CENTER"> |
36 | fred |
37 | </h1> |
38 | HTML |
39 | |
40 | is(h1({-align=>undef},'fred'), <<HTML,"open/close tag with orphan attribute"); |
41 | <h1 align> |
42 | fred |
43 | </h1> |
44 | HTML |
45 | |
46 | is(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> |
53 | HTML |
ac734d8b |
54 | |
55 | is(p('hi',a({-href=>'frog'},'there'),'frog'), <<HTML, "as-is"); |
56 | <p> |
6b4ac661 |
57 | hi <a href="frog">there</a> |
ac734d8b |
58 | frog |
6b4ac661 |
59 | </p> |
ac734d8b |
60 | HTML |
61 | |
188ba755 |
62 | is(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> |
72 | HTML |
73 | |
74 | is(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> |
84 | HTML |
85 | |
86 | is(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> |
96 | HTML |
97 | |
98 | is(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> |
110 | HTML |
111 | |
112 | $CGI::Pretty::INDENT = $CGI::Pretty::LINEBREAK = ""; |
113 | |
114 | is(h1(), '<h1 />',"single tag (pretty turned off)"); |
115 | is(h1('fred'), '<h1>fred</h1>',"open/close tag (pretty turned off)"); |
116 | is(h1('fred','agnes','maura'), '<h1>fred agnes maura</h1>',"open/close tag multiple (pretty turned off)"); |
117 | is(h1({-align=>'CENTER'},'fred'), '<h1 align="CENTER">fred</h1>',"open/close tag with attribute (pretty turned off)"); |
118 | is(h1({-align=>undef},'fred'), '<h1 align>fred</h1>',"open/close tag with orphan attribute (pretty turned off)"); |
119 | is(h1({-align=>'CENTER'},['fred','agnes']), '<h1 align="CENTER">fred</h1> <h1 align="CENTER">agnes</h1>', |
120 | "distributive tag with attribute (pretty turned off)"); |
121 | |