File: comments.t

package info (click to toggle)
libhtml-restrict-perl 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: perl: 842; makefile: 7
file content (33 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env perl

use warnings;
use strict;

use HTML::Restrict ();
use Test::More;

my $hr = HTML::Restrict->new;

my $text = '<!-- comment here -->stuff';
$hr->debug(0);

is $hr->process($text), 'stuff', 'comments allowed';
$hr->allow_comments(1);
is $hr->process($text), $text, 'comments allowd';

$text = 'before<!-- This is a comment -- -- So is this -->after';
$hr->allow_comments(0);

is $hr->process($text), 'beforeafter', 'comment allowed';

$hr->allow_comments(1);
is $hr->process($text), $text, 'comments allowd';

$hr->allow_comments(0);
$text = '<!-- <script> <h1> -->';
is $hr->process($text), undef, 'tags nested in comments removed';

#$hr->set_rules({ script => [], 'h1' => [] });
#is $hr->process( $text ), $text, 'tags nested in comments not removed when explicitly allowed';

done_testing();