File Coverage

lib/Devel/Trepan/Position.pm
Criterion Covered Total %
statement 18 20 90.0
branch 1 2 50.0
condition 3 6 50.0
subroutine 6 7 85.7
pod 0 2 0.0
total 28 37 75.6


line stmt bran cond sub pod time code
1             # Copyright (C) 2011-2014 Rocky Bernstein <rocky@cpan.org>
2 13     13   131538 use warnings; use strict;
  13     13   39  
  13         516  
  13         97  
  13         30  
  13         490  
3              
4 13     13   661 use Class::Struct;
  13         1997  
  13         250  
5 13     13   1945 no strict 'subs';
  13         43  
  13         1231  
6             struct Devel::Trepan::Position => {pkg => '$', filename => '$', line => '$',
7             event => '$'};
8 13     13   115 use strict 'subs';
  13         34  
  13         4662  
9              
10             package Devel::Trepan::Position;
11             sub eq($$)
12             {
13 2     2 0 2253 my ($self, $other) = @_;
14 2 50 33     14 return 0 unless defined $self && defined $other;
15             return (
16 2   66     45 $self->filename eq $other->filename
17             && $self->line eq $other->line
18             && $self->event eq $other->event)
19             }
20              
21             sub inspect($) {
22 0     0 0   my $self = shift;
23 0           return sprintf("pkg: %s, file: %s, line: %s, event: %s",
24             $self->pkg, $self->filename, $self->line, $self->event);
25             }
26              
27             unless (caller) {
28             my $line = __LINE__;
29             my $pos1 = __PACKAGE__->new(pkg=>__PACKAGE__, filename=>__FILE__,
30             line => $line, event=>'brkpt');
31             my $pos2 = __PACKAGE__->new(pkg=>__PACKAGE__, filename=>__FILE__,
32             line => $line, event=>'brkpt');
33             my $pos3 = __PACKAGE__->new(pkg=>__PACKAGE__, filename=>__FILE__,
34             line => __LINE__, event=>'brkpt');
35             printf "pos1 is%s pos2\n", $pos1->eq($pos2) ? '' : ' not';
36             printf "pos1 is%s pos3\n", $pos1->eq($pos3) ? '' : ' not';
37             print $pos1->inspect, "\n";
38              
39             }
40             1;