Reading database from ...
------------------------------------------ ------ ------ ------ ------ ------
File stmt bran cond sub total
------------------------------------------ ------ ------ ------ ------ ------
tests/branch_return_sub 100.0 100.0 100.0 100.0 100.0
Total 100.0 100.0 100.0 100.0 100.0
------------------------------------------ ------ ------ ------ ------ ------
Run: ...
Perl version: ...
OS: ...
Start: ...
Finish: ...
tests/branch_return_sub
line err stmt bran cond sub code
1 #!/usr/bin/perl
2
3 # Copyright 2004-2014, 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 1 1 use strict;
1
1
11 1 1 use warnings;
1
1
12
13 sub my_sqrt {
14 3 3 my $n = shift;
15
16 3 100 100 if ( !defined($n) || ($n < 0) ) {
17 2 return undef;
18 }
19
20 1 return sqrt($n);
21 }
22
23 1 my_sqrt(25);
24 1 my_sqrt(-2);
25 1 my_sqrt(undef);
Branches
--------
line err % true false branch
----- --- ------ ------ ------ ------
16 100 2 1 if (not defined $n or $n < 0)
Conditions
----------
or 3 conditions
line err % l !l&&r !l&&!r expr
----- --- ------ ------ ------ ------ ----
16 100 1 1 1 not defined $n or $n < 0
Covered Subroutines
-------------------
Subroutine Count Location
---------- ----- --------------------------
BEGIN 1 tests/branch_return_sub:10
BEGIN 1 tests/branch_return_sub:11
my_sqrt 3 tests/branch_return_sub:14