File: too-many-titles.t

package info (click to toggle)
libhtml-tidy5-perl 1.06-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 368 kB
  • sloc: perl: 1,853; makefile: 14
file content (40 lines) | stat: -rw-r--r-- 1,088 bytes parent folder | download | duplicates (3)
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
#!perl -T

use 5.010001;
use warnings;
use strict;

use Test::More tests => 4;

use HTML::Tidy5;

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

my $tidy = HTML::Tidy5->new;
isa_ok( $tidy, 'HTML::Tidy5' );
$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( scalar @returned, 1, 'Exactly one warning returned' );

# Tidy 5.6.0 returns "too many title elements in <title>" instead of "too many title elements in <head>".
# When this gets fixed, make this like() into an is().
# https://github.com/htacg/tidy-html5/issues/692
like( $returned[0], qr/^- \(3:5\) Warning: too many title elements in <(head|title)>$/, 'Error message matches' );

exit 0;

__DATA__
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <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>