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