Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 90 lines (57 sloc) 1.757 kb
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
# Copyright 2001-2002, Paul Johnson (pjcj@cpan.org)

# This software is free. It is licensed under the same terms as Perl itself.

# The latest version of this software should be available from my homepage:
# http://www.pjcj.net

package Devel::Cover::Branch;

use strict;
use warnings;

our $VERSION = "0.17";

use base "Devel::Cover::Criterion";

sub covered { (scalar grep $_, @{$_[0][0]}) }
sub total { (scalar @{$_[0][0]}) }
sub percentage
{
    my $t = $_[0]->total;
    sprintf "%3d", $t ? $_[0]->covered / $t * 100 : 0
}
sub error { scalar grep !$_, @{$_[0][0]} }
sub text { $_[0][1]{text} }
sub values { @{$_[0][0]} }

sub calculate_summary
{
    my $self = shift;
    my ($db, $file) = @_;

    my $s = $db->{summary};

    $self->[0] = [0, 0] unless @{$self->[0]};

    my $t = $self->total;
    my $c = $self->covered;

    $s->{$file}{branch}{total} += $t;
    $s->{$file}{total}{total} += $t;
    $s->{Total}{branch}{total} += $t;
    $s->{Total}{total}{total} += $t;

    $s->{$file}{branch}{covered} += $c;
    $s->{$file}{total}{covered} += $c;
    $s->{Total}{branch}{covered} += $c;
    $s->{Total}{total}{covered} += $c;
}

1

__END__

=head1 NAME

Devel::Cover::Branch - Code coverage metrics for Perl

=head1 SYNOPSIS

use Devel::Cover::Branch;

=head1 DESCRIPTION

Module for storing branch coverage information.

=head1 SEE ALSO

Devel::Cover::Criterion

=head1 METHODS

=head1 BUGS

Huh?

=head1 VERSION

Version 0.17 - 15th September 2002

=head1 LICENCE

Copyright 2001-2002, Paul Johnson (pjcj@cpan.org)

This software is free. It is licensed under the same terms as Perl itself.

The latest version of this software should be available from my homepage:
http://www.pjcj.net

=cut
Something went wrong with that request. Please try again.