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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
|
From bccc82b82bde0488821d2ac538e806506ef3f43c Mon Sep 17 00:00:00 2001
From: Timothy Legge <timlegge@gmail.com>
Date: Wed, 28 Jul 2021 23:12:14 -0300
Subject: [PATCH] Update tests for tidy-html 5.8.0
Origin: https://github.com/petdance/html-tidy5/pull/14
Bug-Debian: https://bugs.debian.org/1010115
Reviewed-by: gregor herrmann <gregoa@debian.org>
Last-Update: 2022-05-23
---
t/drop-empty-elements.t | 18 ++++++++++++++----
t/html_fragment_tidy_ok.t | 12 ++++++++----
t/html_tidy_ok.t | 24 +++++++++++++++++++-----
t/new-tags.t | 4 ++--
t/opt-00.t | 4 ++--
t/roundtrip.t | 1 +
t/show-info.t | 16 +++++++++++++---
7 files changed, 59 insertions(+), 20 deletions(-)
diff --git a/t/drop-empty-elements.t b/t/drop-empty-elements.t
index 531e5fa..b2e83f9 100644
--- a/t/drop-empty-elements.t
+++ b/t/drop-empty-elements.t
@@ -32,11 +32,14 @@ subtest 'default constructor warns about empty spans' => sub {
$tidy->parse( 'test', $html );
messages_are( $tidy,
- [ 'test (7:9) Warning: trimming empty <span>' ],
+ [
+ 'test (4:9) Warning: blank \'title\' element',
+ 'test (7:9) Warning: trimming empty <span>'
+ ],
);
};
-subtest 'drop_empty_elements => 1 gives message' => sub {
+subtest 'drop_empty_elements => 2 gives message' => sub {
plan tests => 2;
my $tidy = HTML::Tidy5->new( { drop_empty_elements => 1 } );
@@ -44,7 +47,10 @@ subtest 'drop_empty_elements => 1 gives message' => sub {
$tidy->parse( 'test', $html );
messages_are( $tidy,
- [ 'test (7:9) Warning: trimming empty <span>' ],
+ [
+ 'test (4:9) Warning: blank \'title\' element',
+ 'test (7:9) Warning: trimming empty <span>'
+ ],
);
};
@@ -55,7 +61,11 @@ subtest 'drop_empty_elements => 0 gives no messages' => sub {
isa_ok( $tidy, 'HTML::Tidy5' );
$tidy->parse( 'test', $html );
- messages_are( $tidy, [] );
+ messages_are( $tidy,
+ [
+ 'test (4:9) Warning: blank \'title\' element',
+ ],
+ );
};
exit 0;
diff --git a/t/html_fragment_tidy_ok.t b/t/html_fragment_tidy_ok.t
index 15c04ca..1f74faa 100644
--- a/t/html_fragment_tidy_ok.t
+++ b/t/html_fragment_tidy_ok.t
@@ -44,12 +44,15 @@ HTML
test_test( $msg );
$msg = 'html_fragment_tidy_ok can handle it';
- test_out( "ok 1 - $msg" );
+ test_out( "not ok 1 - $msg" );
+ test_fail( +4 );
+ test_diag( "Errors: $msg" );
+ test_diag( '(-2:9) Warning: blank \'title\' element' );
+ test_diag( '1 message on the page' );
html_fragment_tidy_ok( $html, $msg );
test_test( $msg );
};
-
subtest 'html_fragment_tidy_ok gets the same errors as html_tidy_ok' => sub {
plan tests => 2;
@@ -76,11 +79,12 @@ HTML
# Note that the line numbers are the same between html_tidy_ok and html_fragment_tidy_ok.
$msg = 'html_fragment_tidy_ok on sloppy doc';
test_out( "not ok 1 - $msg" );
- test_fail( +5 );
+ test_fail( +6 );
test_diag( "Errors: $msg" );
test_diag( '(2:59) Warning: discarding unexpected </td>' );
+ test_diag( '(-2:9) Warning: blank \'title\' element' );
test_diag( '(3:5) Warning: <img> lacks "alt" attribute' );
- test_diag( '2 messages on the page' );
+ test_diag( '3 messages on the page' );
html_fragment_tidy_ok( $html, $msg );
test_test( $msg );
};
diff --git a/t/html_tidy_ok.t b/t/html_tidy_ok.t
index 07cfbfd..d8afd9b 100644
--- a/t/html_tidy_ok.t
+++ b/t/html_tidy_ok.t
@@ -41,9 +41,19 @@ subtest 'html_tidy_ok without errors' => sub {
</html>
HTML
- test_out( 'ok 1 - Called html_tidy_ok on full document' );
+ test_out( 'not ok 1 - Called html_tidy_ok on full document' );
+ test_fail( +4 );
+ test_diag( "Errors: Called html_tidy_ok on full document" );
+ test_diag( '(4:9) Warning: blank \'title\' element' );
+ test_diag( '1 message on the page' );
html_tidy_ok( $html, 'Called html_tidy_ok on full document' );
test_test( 'html_tidy_ok on full document works' );
+ # > # Failed test 'Called html_tidy_ok on full document'
+ # > # at t/html_tidy_ok.t line 45.
+ # > # Errors: Called html_tidy_ok on full document
+ # > # (4:9) Warning: blank 'title' element
+ # > # 1 message on the page
+
};
@@ -95,22 +105,26 @@ HTML
# Default html_tidy_ok() complains about empty paragraph.
test_out( 'not ok 1 - Empty paragraph' );
- test_fail( +4 );
+ test_fail( +5 );
test_diag( 'Errors: Empty paragraph' );
+ test_diag( '(4:9) Warning: blank \'title\' element' );
test_diag( '(12:9) Warning: trimming empty <p>' );
- test_diag( '1 message on the page' );
+ test_diag( '2 messages on the page' );
html_tidy_ok( $html, 'Empty paragraph' );
test_test( 'html_tidy_ok works on empty paragraph' );
# Now make our own more relaxed Tidy object and it should pass.
my $tidy = HTML::Tidy5->new( { drop_empty_elements => 0 } );
isa_ok( $tidy, 'HTML::Tidy5' );
- test_out( 'ok 1 - Relaxed tidy' );
+ test_out( 'not ok 1 - Relaxed tidy' );
+ test_fail( +4 );
+ test_diag( 'Errors: Relaxed tidy' );
+ test_diag( '(4:9) Warning: blank \'title\' element' );
+ test_diag( '1 message on the page' );
html_tidy_ok( $tidy, $html, 'Relaxed tidy' );
test_test( 'html_tidy_ok with user-specified tidy works' );
};
-
subtest 'Reusing a tidy object' => sub {
plan tests => 7;
diff --git a/t/new-tags.t b/t/new-tags.t
index 9912686..adb2ab5 100644
--- a/t/new-tags.t
+++ b/t/new-tags.t
@@ -43,6 +43,7 @@ my @all_errors = (
'test (14:28) Warning: discarding unexpected <newinline>',
'test (14:49) Warning: discarding unexpected </newinline>',
'test (16:9) Warning: discarding unexpected </otherblock>',
+ 'test (4:9) Warning: blank \'title\' element',
);
@@ -52,7 +53,6 @@ subtest 'default constructor warns about <nav> tag' => sub {
my $tidy = HTML::Tidy5->new;
isa_ok( $tidy, 'HTML::Tidy5' );
$tidy->parse( 'test', $html );
-
messages_are( $tidy, [ @all_errors ] );
};
@@ -89,7 +89,7 @@ subtest 'Add new line and blocklevel' => sub {
isa_ok( $tidy, 'HTML::Tidy5' );
$tidy->parse( 'test', $html );
- messages_are( $tidy, [], 'Quieted all errors' );
+ messages_are( $tidy, [grep { /element/ } @all_errors ], 'Quieted all errors' );
};
exit 0;
diff --git a/t/opt-00.t b/t/opt-00.t
index 762a4c4..7db3463 100644
--- a/t/opt-00.t
+++ b/t/opt-00.t
@@ -43,7 +43,7 @@ my $expected =<<'EOD';
</title>
<style type="text/css">
/*<![CDATA[*/
- span.myprefix-1 {color: blue}
+ span.myprefix1 {color: blue}
/*]]>*/
</style>
</head>
@@ -52,7 +52,7 @@ my $expected =<<'EOD';
<p>Here's some <b>ed and
<br />
-eakfest MarkUp: <span class="myprefix-1">...</span></b></p>
+eakfest MarkUp: <span class="myprefix1">...</span></b></p>
<p>
</p>
diff --git a/t/roundtrip.t b/t/roundtrip.t
index 1351896..613c18b 100644
--- a/t/roundtrip.t
+++ b/t/roundtrip.t
@@ -25,6 +25,7 @@ my $clean = $tidy->clean( $html );
# then verify that it meets tidy's high standards
$tidy = HTML::Tidy5->new($args); # reset messages;
$tidy->ignore( type => TIDY_INFO );
+$tidy->ignore( text => qr/title/ );
$clean = $tidy->clean($clean);
my @messages = $tidy->messages( $clean );
diff --git a/t/show-info.t b/t/show-info.t
index 7a073af..4c133be 100644
--- a/t/show-info.t
+++ b/t/show-info.t
@@ -31,7 +31,10 @@ subtest 'default constructor shows info' => sub {
$tidy->parse( 'test', $html );
messages_are( $tidy,
- [ 'test (6:5) Info: value for attribute "id" missing quote marks' ]
+ [
+ 'test (6:5) Info: value for attribute "id" missing quote marks',
+ 'test (4:9) Warning: blank \'title\' element',
+ ]
);
};
@@ -43,7 +46,10 @@ subtest 'show_info => 1 shows info' => sub {
$tidy->parse( 'test', $html );
messages_are( $tidy,
- [ 'test (6:5) Info: value for attribute "id" missing quote marks' ]
+ [
+ 'test (6:5) Info: value for attribute "id" missing quote marks',
+ 'test (4:9) Warning: blank \'title\' element',
+ ]
);
};
@@ -54,7 +60,11 @@ subtest 'show_info => 0' => sub {
isa_ok( $tidy, 'HTML::Tidy5' );
$tidy->parse( 'test', $html );
- messages_are( $tidy, [] );
+ messages_are( $tidy,
+ [
+ 'test (4:9) Warning: blank \'title\' element',
+ ]
+ );
};
exit 0;
|