"Fossies" - the Fresh Open Source Software Archive 
Member "HTML-Stream-1.60/t/02-OO_Tests.t" (7 Aug 2008, 2842 Bytes) of package /linux/www/old/HTML-Stream-1.60.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1
2 #use Test::More tests=>19;
3 use Test::More qw(no_plan);
4 use HTML::Stream;
5
6
7
8 # Test if we have all the normal stuff we are supposed to.
9 my $HTML = new HTML::Stream \*STDOUT;
10
11 # The directly defined methods.
12 can_ok($HTML, qw(auto_escape auto_format comment ent io nl tag t text text_nbsp
13 output accept_tag private_tags set_tag tags
14 ));
15
16 # Check that we say we accept the 'historic' tag list by default.
17 # (The historic tag list is the list of all tags in HTML 4 plus other common tags.)
18 my @tags = $HTML->tags();
19 @tags = sort @tags;
20 my @historic_tags = qw(A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO
21 BGSOUND BIG BLINK BLOCKQUOTE BODY BR BUTTON CAPTION
22 CENTER CITE CODE COL COLGROUP COMMENT DD DEL DFN DIR
23 DIV DL DT EM EMBED FIELDSET FONT FORM FRAME FRAMESET
24 H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS
25 ISINDEX KBD KEYGEN LABEL LEGEND LI LINK LISTING MAP
26 MARQUEE MENU META NEXTID NOBR NOEMBED NOFRAME NOFRAMES NOSCRIPT
27 OBJECT OL OPTGROUP OPTION P PARAM PLAINTEXT PRE Q SAMP
28 SCRIPT SELECT SERVER SMALL SPAN STRIKE STRONG STYLE
29 SUB SUP TABLE TBODY TD TEXTAREA TFOOT TH THEAD TITLE
30 TR TT U UL VAR WBR XMP
31 );
32
33 is_deeply (\@tags, \@historic_tags, "Tags List");
34
35 # Check that we can add tags as needed...
36 $HTML->accept_tag('DSTAAL');
37 push @historic_tags, 'DSTAAL';
38 @historic_tags = sort @historic_tags;
39 @tags = $HTML->tags();
40 @tags = sort @tags;
41 is_deeply (\@tags, \@historic_tags, "Tags List");
42
43
44 # Skip tests if we can't run them.
45 SKIP: {
46 eval { require Test::Output };
47 skip "Test::Output is needed for OO tests to run.", 16 if $@;
48 Test::Output->import();
49
50 # Check that some of these tags actually work as expected...
51 stdout_is( sub { $HTML->ABBR }, "<ABBR>" );
52 stdout_is( sub { $HTML->ABBR->_ABBR }, "<ABBR></ABBR>" );
53 stdout_is( sub { $HTML->A(HREF=>'mailto:DSTAAL@USA.NET') }, '<A HREF="mailto:DSTAAL@USA.NET">' );
54 stdout_is( sub { $HTML->ADDRESS->_ADDRESS }, "<ADDRESS>\n</ADDRESS>\n" );
55 stdout_is( sub { $HTML->AREA->_AREA }, "<AREA></AREA>\n" );
56 stdout_is( sub { $HTML->BR->_BR }, "<BR>\n</BR>" );
57 stdout_is( sub { $HTML->BUTTON->_BUTTON }, "\n<BUTTON></BUTTON>" );
58 stdout_is( sub { $HTML->H1->_H1 }, "<H1></H1>\n" );
59 stdout_is( sub { $HTML->TR(NOWRAP=>undef)->_TR }, "\n<TR NOWRAP></TR>\n" );
60
61 # Check Escaping
62 # (I really should be through about this, but these are the
63 # HTML _required_ escapes checked at least.)
64 stdout_is( sub { $HTML->text("&") }, "&" );
65 stdout_is( sub { $HTML->t("<") }, "<" );
66
67 #Check a couple of the other methods...
68
69 # 'Newline' is up first.
70 stdout_is( sub { $HTML->nl }, "\n" );
71 stdout_is( sub { $HTML->nl(3) }, "\n\n\n" );
72 stdout_is( sub { $HTML->nl(0) }, "" );
73 stdout_is( sub { $HTML->nl(-1) }, "" );
74 stdout_is( sub { $HTML->nl("a") }, "" ); # This fails intentionally.
75 }