Same/Range.pm

filter: Statementstmt 85.1% 23 / 27 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 87.5% 7 / 8 Podpod 100% 4 / 4 totaltotal 71.7% 38 / 53 CC 5 SCAR 13.4
CC
5
Cov
73%
new
7.6
as_string
2.0
BEGIN
1.0
CRAP 3.8
« Same.pm ↑ Summary Same/MatchMap.pm »
1 =head1 NAME
2  
3 Text::Same::Range
4  
5 =head1 DESCRIPTION
6  
7 A class representing a range of integers
8  
9 =head1 SYNOPSIS
10  
11 my $range = new Text::Same::Range($start, $end);
12  
13 =head1 METHODS
14  
15 See below. Methods private to this module are prefixed by an
16 underscore.
17  
18 =cut
19  
20 package Text::Same::Range;
21  
22 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 4 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
27 4 $VERSION = '0.07';
28  
29 =head2 new
30  
31 Title : new
32 Usage : $range = new Text::Same::Range($start, $end)
33 Function: Creates a new Range object with the given start and end
34 Returns : A Text::Same::Range object
35  
36 =cut
37  
38 sub new
39 45 ▶{
Subroutine new: called CC=5 SCAR=20.3
Pod documented
40 45 my $self = shift;
41 45 ▶ my $class = ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
0450
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
42  
43 45 ▶ if (scalar(@_) != 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ != 2) 0 45 45
44 0 die "Range constructor needs 2 arguments\n";
45 }
46  
47 45 ▶ if (!defined $_[0] || !defined $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[0] and defined $_[1]) 0 45 45
Condition33%1/3
defined $_[0] and defined $_[1]
!ll&&!rl&&r
0045
MC/DC0%0/2
defined $_[0] and defined $_[1]
defined $_[0] defined $_[1]
Truth table33%1/3
A and B
A= defined $_[0]B= defined $_[1]
ABresult
0X0
100
111
48 0 croak "undefined value passed to Range->new\n";
49 }
50  
51 45 return bless [@_], $class;
52 }
53  
54 =head2 start
55  
56 Title : start
57 Usage : $start = $range->start
58 Function: Returns the start position that was passed to new()
59  
60 =cut
61  
62 sub start
63 30 ▶{
Subroutine start: called CC=1 SCAR=0.0
Pod documented
64 30 my $self = shift;
65 30 return $self->[0];
66 }
67  
68 =head2 end
69  
70 Title : end
71 Usage : $end = $range->end
72 Function: Returns the end position that was passed to new()
73  
74 =cut
75  
76 sub end
77 30 ▶{
Subroutine end: called CC=1 SCAR=0.0
Pod documented
78 30 my $self = shift;
79 30 return $self->[1];
80 }
81  
82 =head2 as_string
83  
84 Title : as_string
85 Usage : my $str = $range->as_string
86 Function: return a string representation of this Range
87 Args : none
88  
89 =cut
90  
91 sub as_string
92 0 ▶{
Subroutine as_string: not called CC=1 SCAR=6.9
Pod documented
93 0 my $self = shift;
94 0 return $self->[0] . ".." . $self->[1];
95 }
96  
97 =head1 AUTHOR
98  
99 Kim Rutherford <kmr+same@xenu.org.uk>
100  
101 =head1 COPYRIGHT & LICENSE
102  
103 Copyright 2005,2006 Kim Rutherford. All rights reserved.
104  
105 This program is free software; you can redistribute it and/or modify it
106 under the same terms as Perl itself.
107  
108 =head1 DISCLAIMER
109  
110 This module is provided "as is" without warranty of any kind. It
111 may redistributed under the same conditions as Perl itself.
112  
113 =cut
114  
115 4 1;
« Same.pm ↑ Summary Same/MatchMap.pm »