Skip to content
This repository has been archived by the owner on Apr 14, 2019. It is now read-only.

fix tests failing on cpan testers reports #44

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions t/LintTest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sub checkit {
my @expected = @{+shift};
my @linesets = @_;

plan( tests => 3*(scalar @expected) + 4 );
plan( tests => 2*(scalar @expected) + 4 );

my $lint = new HTML::Lint;
isa_ok( $lint, 'HTML::Lint', 'Created lint object' );
Expand All @@ -21,29 +21,32 @@ sub checkit {
my @errors = $lint->errors();
is( scalar @errors, scalar @expected, 'Right # of errors' );

while ( @errors && @expected ) {
my $expected_found = 0;
while ( @errors ) {
my $error = shift @errors;
isa_ok( $error, 'HTML::Lint::Error' );
foreach my $exp (@expected) {
my $match = $exp->[1];
if ( ref $match eq "Regexp" && $error->as_string =~ /$match/) {
$expected_found++;
is( $error->errcode, $exp->[0], 'Error codes match' );
last;
}
elsif ($error->as_string eq $match) {
$expected_found++;
is( $error->errcode, $exp->[0], 'Error codes match' );
last;
}

my $expected = shift @expected;

is( $error->errcode, $expected->[0], 'Error codes match' );
my $match = $expected->[1];
if ( ref $match eq "Regexp" ) {
like( $error->as_string, $match, 'Error matches regex' );
}
else {
is( $error->as_string, $match, 'Error matches string' );
}
}

my $dump;

is( scalar @errors, 0, 'No unexpected errors found' ) or $dump = 1;
is( scalar @expected, 0, 'No expected errors missing' ) or $dump = 1;
is( $expected_found, scalar @expected, 'No expected errors missing' ) or $dump = 1;

if ( $dump && @errors ) {
diag( "Leftover errors..." );
diag( "Leftover errors..." );
diag( $_->as_string ) for @errors;
}
}
Expand Down