Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

128 lines (111 sloc) 5.376 kb
Reading database from ...
------------------------------------------ ------ ------ ------ ------ ------
File stmt bran cond sub total
------------------------------------------ ------ ------ ------ ------ ------
tests/dynamic_subs 97.2 75.0 n/a 88.9 93.9
Total 97.2 75.0 n/a 88.9 93.9
------------------------------------------ ------ ------ ------ ------ ------
Run: ...
Perl version: ...
OS: ...
Start: ...
Finish: ...
tests/dynamic_subs
line err stmt bran cond sub code
1 #!/usr/bin/perl
2
3 # Copyright 2004-2012, Paul Johnson (paul@pjcj.net)
4
5 # This software is free. It is licensed under the same terms as Perl itself.
6
7 # The latest version of this software should be available from my homepage:
8 # http://www.pjcj.net
9
10 *** 0 0 sub unused { 0 }
11 sub empty { }
12
13 sub gen
14 {
15 4 4 my $x = shift;
16 sub
17 {
18 5 5 my $y = shift;
19 *** 5 50 return $x + $y if $y;
20 }
21 4 };
22
23 1 my $o = gen(1);
24 1 my $p = $o->(7);
25 1 my $q = $o->(8);
26 1 my $r = gen(1)->(2);
27 1 my $s = gen(3)->(4);
28 1 my $t = gen(5)->(6);
29
30 1 print "$p, $q, $r, $s, $t\n";
31
32 1 for my $func (qw(f1 f2 f3))
33 {
34 1 1 no strict "refs";
1
1
35 *$func = sub
36 {
37 2 2 print "$func\n";
38 }
39 3 }
40
41 1 f1();
42 1 f2();
43
44 sub AUTOLOAD
45 {
46 3 3 my $func = $AUTOLOAD;
47 3 $func =~ s/^.*:://;
48 1 1 no strict "refs";
1
1
49 3 100 if ($func eq "add")
50 {
51 *$func = sub
52 {
53 3 3 print "Add!\n";
54 1 };
55 }
56 else
57 {
58 *$func = sub
59 {
60 2 2 print "$func\n";
61 2 };
62 }
63 3 goto &$func
64 }
65
66 1 add();
67 1 add();
68 1 add();
69 1 qaz();
70 1 wsx();
Branches
--------
line err % true false branch
----- --- ------ ------ ------ ------
19 *** 50 5 0 if $y
49 100 1 2 if ($func eq 'add') { }
Covered Subroutines
-------------------
Subroutine Count Location
---------- ----- ---------------------
AUTOLOAD 3 tests/dynamic_subs:46
BEGIN 1 tests/dynamic_subs:34
BEGIN 1 tests/dynamic_subs:48
__ANON__ 5 tests/dynamic_subs:18
__ANON__ 2 tests/dynamic_subs:37
__ANON__ 3 tests/dynamic_subs:53
__ANON__ 2 tests/dynamic_subs:60
gen 4 tests/dynamic_subs:15
Uncovered Subroutines
---------------------
Subroutine Count Location
---------- ----- ---------------------
unused 0 tests/dynamic_subs:10
Jump to Line
Something went wrong with that request. Please try again.