File: perl_highlighting.t

package info (click to toggle)
libsyntax-highlight-engine-kate-perl 0.14%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 3,848 kB
  • sloc: perl: 84,065; ruby: 176; asm: 166; cpp: 144; jsp: 128; haskell: 116; sh: 111; f90: 99; python: 98; ml: 75; xml: 43; yacc: 37; ansic: 32; tcl: 29; lisp: 24; makefile: 14; awk: 13; php: 5
file content (69 lines) | stat: -rw-r--r-- 2,029 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
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
use strict;
use warnings;

use Test::More;
use Test::Differences;
use lib 't/lib';
use TestHighlight ':all';

diag <<'END';
We don't actually know if these are highlighted correctly, but this
makes decent regression tests when we refactor.
END

my ( $before, $after ) = ( 't/perl/before', 't/perl/highlighted' );

my $highlighted_version_of = get_sample_perl_files();
plan tests => 1 + scalar keys %$highlighted_version_of;

for my $perl ( sort keys %$highlighted_version_of ) {
    my $highlighted = $highlighted_version_of->{$perl};
    my $have        = get_highlighter('Perl')->highlightText( slurp($perl) );
    my $want        = slurp($highlighted);
	chomp $want;

    eq_or_diff $have, $want, "($perl) was highlighted correctly";
}

# https://rt.cpan.org/Public/Bug/Display.html?id=76160
my $pod_bug = do { local $/; <DATA>; };
my $have = highlight_perl($pod_bug);

my $want = <<'END';
<normal>
</normal><keyword>#!/usr/bin/env perl</keyword><normal>
</normal><comment># https://rt.cpan.org/Ticket/Display.html?id=76160</comment><comment>
</comment><comment>=pod
</comment><comment>
</comment><comment>=head1 BORKED</comment><comment>
</comment><comment>
</comment><comment>All Perl code after this was considered a "comment" and Kate could not</comment><comment>
</comment><comment>highlight it correctly.</comment><comment>
</comment><comment>
</comment><comment>=cutabove</comment><comment>
</comment><comment>
</comment><comment>=cut</comment><normal>
</normal><normal>
</normal><keyword>my</keyword><normal> </normal><datatype>$this_is_not_a_comment</datatype><normal> = </normal><operator>'</operator><string>or a pipe</string><operator>'</operator><normal>;</normal><normal>
</normal>
END
chomp($want);

eq_or_diff $have, $want, 'post pod parsing all good';

__DATA__

#!/usr/bin/env perl
# https://rt.cpan.org/Ticket/Display.html?id=76160
=pod

=head1 BORKED

All Perl code after this was considered a "comment" and Kate could not
highlight it correctly.

=cutabove

=cut

my $this_is_not_a_comment = 'or a pipe';