File: 20-error-types-skip.t

package info (click to toggle)
libhtml-lint-perl 2.20%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 304 kB
  • ctags: 64
  • sloc: perl: 1,014; sh: 48; makefile: 20
file content (62 lines) | stat: -rw-r--r-- 1,561 bytes parent folder | download | duplicates (5)
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
#!perl -Tw

use strict;
use warnings;
use Test::More tests => 10;

BEGIN { use_ok( 'HTML::Lint' ); }
BEGIN { use_ok( 'HTML::Lint::Error', ':types' ); }

my $text = do { local $/ = undef; <DATA> };

FUNC_METHOD: {
    my $lint = HTML::Lint->new();
    isa_ok( $lint, 'HTML::Lint' );
    $lint->parse( $text );
    is( scalar $lint->errors, 1, 'One error with a clean lint' );

    $lint->newfile();
    $lint->clear_errors();
    $lint->only_types( HELPER, FLUFF );
    $lint->parse( $text );
    is( scalar $lint->errors, 0, 'No errors if helper & fluff' );

    $lint->newfile();
    $lint->clear_errors();
    $lint->only_types( STRUCTURE );
    $lint->parse( $text );
    my @errors = $lint->errors;
    if ( !is( scalar @errors, 1, 'One error if we specify STRUCTURE if we turn it off' ) ) {
        diag( $_->as_string ) for @errors;
    }
}

CONSTRUCTOR_METHOD_SCALAR: {
    my $lint = HTML::Lint->new( only_types => STRUCTURE );
    isa_ok( $lint, 'HTML::Lint' );

    $lint->parse( $text );
    my @errors = $lint->errors;
    if ( !is( scalar @errors, 1, 'One error if we specify STRUCTURE if we turn it off' ) ) {
        diag( $_->as_string ) for @errors;
    }
}

CONSTRUCTOR_METHOD_ARRAYREF: {
    my $lint = HTML::Lint->new( only_types => [HELPER, FLUFF] );
    isa_ok( $lint, 'HTML::Lint' );
    $lint->parse( $text );
    is( scalar $lint->errors, 0, 'No errors if helper & fluff' );
}



__DATA__
<HTML>
    <HEAD>
        <TITLE>Test stuff</TITLE>
    </HEAD>
    <BODY BGCOLOR="white">
        <TABLE>This is my paragraph
    </BODY>
</HTML>