Subject: | Test::HTML::Lint should clear HTML::Lint between calls to html_ok |
I have a small patch for Test::HTML::Lint that I would like you to consider. It alters the functionality slightly by clearing the HTML::Lint state between calls to html_ok if a $lint object is passed in.
For example, I do the following in my test modules:
# Create the HTML::Lint object once so we can reuse it
my $lint = HTML::Lint->new(only_types => HTML::Lint::Error::STRUCTURE);
html_ok( $lint, $a1->content, "Page 1 HTML" );
html_ok( $lint, $a2->content, "Page 2 HTML" );
The second call to html_ok will fail, because the HTML::Lint object still has the content and errors of the first page in memory. I would rather not have to call $lint->newfile() and $lint->clear_errors() after every use of html_ok, and think this should be done automatically in the Test::HTML::Lint module. This is the way I expected the html_ok function to work when I first used it, and I think it has the potential to trip people up in the way it works right now.
Cheers,
Cees Hek
--- Lint.pm.orig 2003-12-18 11:37:52.000000000 -0500
+++ Lint.pm 2003-12-18 11:36:56.000000000 -0500
@@ -84,6 +84,8 @@
my $lint;
if ( ref($_[0]) eq "HTML::Lint" ) {
$lint = shift;
+ $lint->newfile();
+ $lint->clear_errors();
} else {
$lint = HTML::Lint->new;
}