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