File: 07_booleans.t

package info (click to toggle)
libhtml-scrubber-perl 0.08-4%2Bdeb6u1
  • links: PTS
  • area: main
  • in suites: squeeze-lts
  • size: 140 kB
  • ctags: 23
  • sloc: perl: 329; makefile: 43
file content (76 lines) | stat: -rw-r--r-- 1,508 bytes parent folder | download | duplicates (4)
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
# 07_booleans.t

use strict;
use File::Spec;
use Test::More tests => 9;
BEGIN { $^W = 1 }

use_ok( 'HTML::Scrubber' );

use HTML::Scrubber;
my @allow = qw[ br hr b a option button th ];
my $scrubber = HTML::Scrubber->new();
$scrubber->allow( @allow );
$scrubber->default(
    undef,              # don't change
    {                   # default attribute rules
        '/' => 1,       # '/' ia boolean (stand-alone) attribute 
        'pie' => 1,
        'selected' => 1,
        'disabled' => 1,
        'nowrap' => 1,
    }
);

ok( $scrubber,  "got scrubber");

test(
q~<br> hi <br /> <a href= >~,
q~<br> hi <br /> <a>~,
"br /");


test(
q~<option selected> flicka <a href=>~,
q~<option selected> flicka <a>~,
"selected");

test(
q~<button name="flicka" Disabled > the flicker </button>~,
q~<button disabled> the flicker </button>~,
"disabled");


test(
q~<button disabled > dd </button>~,
q~<button disabled> dd </button>~,
"dd");


test(
q~<a disabled pie=6> | </a>~,
q~<a disabled pie="6"> | </a>~,
"pie");


test(
q~<a selected disabled selected pie pie pie disabled /> | </a>~,
q~<a selected disabled pie /> | </a>~,
"selected pie");


#dependent on version of HTML::Parser, after 0.36 1st is returned (ie pie)
#test(q~<br pie pie=4>~, q~<br pie="4">~, 'repeated mixed');

test( q~<th nowrap=nowrap>~,
q~<th nowrap="nowrap">~,
"th nowrap=nowrap");




sub test {
    my ($in, $out, $name) = @_;
    is( $scrubber->scrub($in), $out, $name );
}