File: too-many-titles.t

package info (click to toggle)
libhtml-tidy-perl 1.60-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 472 kB
  • sloc: perl: 1,289; sh: 23; makefile: 7
file content (47 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download
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
#!perl -T

use warnings;
use strict;

use Test::More tests => 3;

use HTML::Tidy;

my $html = join '', <DATA>;

my @expected = split /\n/, q{
- (1:1) Warning: missing <!DOCTYPE> declaration
- (2:5) Warning: too many title elements in <head>
};

my $tidyversion = HTML::Tidy->tidyp_version;
if ($tidyversion =~ /^5.006/) {
@expected = split /\n/, q{
- (1:1) Warning: missing <!DOCTYPE> declaration
- (2:5) Warning: too many title elements in <title>
};
}

chomp @expected;
shift @expected; # First one's blank

my $tidy = HTML::Tidy->new;
isa_ok( $tidy, 'HTML::Tidy' );
$tidy->ignore( type => TIDY_INFO );
my $rc = $tidy->parse( '-', $html );
ok( $rc, 'Parsed OK' );

my @returned = map { $_->as_string } $tidy->messages;
s/[\r\n]+\z// for @returned;
is_deeply( \@returned, \@expected, 'Matching warnings' );

__DATA__
<HTML>
    <HEAD>
        <TITLE>Test stuff</TITLE>
        <TITLE>As if one title isn't enough</TITLE>
    </HEAD>
    <BODY BGCOLOR="white">
        <P>This is my paragraph</P>
    </BODY>
</HTML>