File: example.pl

package info (click to toggle)
lcov 2.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,464 kB
  • sloc: perl: 27,911; sh: 7,320; xml: 6,982; python: 1,152; makefile: 597; cpp: 520; ansic: 176
file content (55 lines) | stat: -rw-r--r-- 1,179 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
# example used to test perl2lcov coverage data extract

use strict;

sub global1 {
  print("called global1 function\n");
  if (exists($ENV{NO_SUCH_VARIABLE})) {
    print("unexercised statement in un-hit branch\n");
  }
}

package space1;
# LCOV_EXCL_START
sub packageFunc {
  print("this is a function in space1 - not exercised\n");
}
# LCOV_EXCL_STOP
sub packageFunc2 {
  my $val = shift;
  if (exists($ENV{NO_SUCH_VARIABLE}) &&
      ($ENV{NO_SUCH_VARIABLE} eq 'a' ||
       $ENV{NO_SUCH_VARIABLE} < 3)) {
    print("unexercised statement in more complex conditional\n");
  }
  print("packageFunc2 called\n");
}

package space2;

sub packageFunc {
  print("this is a function in space2 - not exercised\n");
}

sub packageFunc2 {
  if (exists($ENV{NO_SUCH_VARIABLE}) &&
      ($ENV{NO_SUCH_VARIABLE} eq 'a' ||
       $ENV{NO_SUCH_VARIABLE} < 3)) {
    print("unexercised statement in more complex conditional\n");
  }
  print("packageFunc2 called\n");
}

package main;
# LCOV_EXCL_BR_START
print "simple perl testcase\n";
global1();

space1::packageFunc2(1);

space2::packageFunc();
unless (@ARGV) {
  print("no args so we entered the branch\n");
}
exit 0;
# LCOV_EXCL_BR_STOP