File: test.pl

package info (click to toggle)
libhtml-highlight-perl 0.20-7.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 132 kB
  • sloc: perl: 493; makefile: 2
file content (90 lines) | stat: -rw-r--r-- 2,097 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

######################### We start with some black magic to print on failure.

BEGIN { $| = 1; print "1..last_test_to_print\n"; }
END { print "not ok 1\n" unless $loaded; }

use HTML::Highlight;
# require "Highlight.pm";

###

print "2..first highlighting test\n";

my $doc = qq{
<html>
<text tag="value">Blah</text>
Textual car misinformation reality sex pride is your own destiny
purity seduction of miserable voices characters. For all your needs in this
world of piss and misbehaviour. We all are bullshit people here. No way from
this horrible place of death and sorrow.
<character>Text</character>
Contextual
</html>
};

my $hl = new HTML::Highlight (
	words => [ 'blah', 'text', 'character', 'span' ],
	wildcards => [ undef, '%', '*' ],
	colors => [ 'red', 'green' ],
	debug => 0
);

my $hldoc = $hl->highlight($doc);

if ($hldoc eq qq{
<html>
<text tag="value"><span style="background-color: red">Blah</span></text>
<span style="background-color: green">Textual</span> car misinformation reality sex pride is your own destiny
purity seduction of miserable voices <span style="background-color: red">characters</span>. For all your needs in this
world of piss and misbehaviour. We all are bullshit people here. No way from
this horrible place of death and sorrow.
<character><span style="background-color: green">Text</span></character>
Contextual
</html>
}) {
	print "ok 2\n";
}
else {
	print "not ok 2\n";
}

#print "$doc\n";
#print "$hldoc\n";

###

print "3..first preview context test\n";

my $sections = $hl->preview_context($doc, 10);

=item
print "$sections\n";
my $len = @{$sections};
print "len = $len\n";
{
	local $, = "\n---\n";
	print @{$sections};
}
print "\n";
=cut

if ($sections->[0] eq qq{

Blah
Textual car misinformation reality sex}
	and $sections->[1] eq qq{seduction of miserable voices characters. For all your needs in this
world of}) {
	print "ok 3\n";
}
else {
	print "not ok 3\n";
}

###

$loaded = 1;
print "ok 1\n";