File Coverage

t/04.syntax-vim.t
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 20 90.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3 1     1   5 use strict;
  1         2  
  1         34  
4 1     1   5 use warnings;
  1         1  
  1         27  
5              
6 1     1   880 use Test::More qw(no_plan);
  1         17040  
  1         8  
7              
8 1     1   1135 use lib qw(lib t/lib);
  1         649  
  1         4  
9 1     1   432 use IkiWiki q(2.0);
  0            
  0            
10              
11             use MyTestTools qw(:css);
12              
13             my $class = 'IkiWiki::Plugin::syntax::Vim';
14              
15             use_ok($class);
16              
17             my $engine = $class->new();
18              
19             SKIP: {
20             skip "Syntax::Highlight::Engine::Vim not installed" if not $engine;
21              
22             isa_ok($engine, $class );
23              
24             my $source = <<'EOF';
25             /* This is a foo program */
26             int a = 3;
27             printf("%d\n",a);
28             EOF
29              
30             my $output = eval {
31             $engine->syntax_highlight( language => 'c',
32             source => $source,
33             linenumbers => 1,
34             bars => 1, );
35             };
36              
37             if ($@) {
38             if (my $ex = Syntax::X::Engine->caught()) {
39             if ($ex->isa('Syntax::X::Engine::Use')) {
40             skip('Text::VimColor is not installed');
41             }
42             elsif ($ex->isa('Syntax::X::Engine::Language')) {
43             skip('Language C syntaxis not supported in Vim');
44             }
45             }
46             fail('Unknown exception');
47             }
48              
49             my $regex_ln = build_css_regex('synLineNumber','\d+');
50             like($output, $regex_ln, "Source text with line numbers");
51              
52             my $regex_bar = build_css_regex('synBar');
53             like($output, $regex_bar, "Source text with bar lines");
54              
55             check_results( $output,
56             synBar => 2,
57             synLineNumber => 3,
58             synType => 1,
59             synComment => 1,
60             synConstant => 3, );
61             }
62              
63              
64