mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-22 02:35:23 +03:00
246 lines
7.7 KiB
Diff
246 lines
7.7 KiB
Diff
Update tests for tidy-html 5.8.0 #14
|
|
https://github.com/petdance/html-tidy5/pull/14
|
|
|
|
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;
|