Debian lenny version packages
[pkg-perl] / deb-src / libhtml-tree-perl / libhtml-tree-perl-3.23 / t / doctype.t
1 #!perl -Tw
2
3 use strict;
4 use Test::More tests => 5;
5
6 BEGIN {
7     use_ok( "HTML::TreeBuilder" );
8 }
9
10 my $html =<<'EOHTML';
11 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
12 "http://www.w3.org/TR/html4/loose.dtd">
13 <html>
14 <head>
15 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
16 </head>
17 <body>
18 blah blah
19 </body>
20 </html>
21 EOHTML
22
23 WITH_DECLARATION: { # Check default state
24     my $tree = HTML::TreeBuilder->new;
25     isa_ok( $tree, "HTML::TreeBuilder" );
26
27     $tree->parse( $html );
28     $tree->eof;
29
30     my @lines = split( "\n", $tree->as_HTML(undef, " ") );
31
32     like( $lines[0], qr/DOCTYPE/, "DOCTYPE is in the first line" );
33 }
34
35
36 WITHOUT_DECLARATION: {
37     my $tree = HTML::TreeBuilder->new;
38     isa_ok( $tree, "HTML::TreeBuilder" );
39
40     $tree->store_declarations(0);
41
42     $tree->parse( $html );
43     $tree->eof;
44
45     my @lines = split( "\n", $tree->as_HTML(undef, " ") );
46
47     unlike( $lines[0], qr/DOCTYPE/, "DOCTYPE is NOT in the first line" );
48 }