File Coverage

blib/lib/Array/Stream/Transactional/Matcher/Value.pm
Criterion Covered Total %
statement 35 36 97.2
branch 8 14 57.1
condition 7 21 33.3
subroutine 9 10 90.0
pod 1 2 50.0
total 60 83 72.2


line stmt bran cond sub pod time code
1             # $Id: Value.pm,v 1.6 2004/06/11 21:50:53 claes Exp $
2              
3 5     5   28 use strict;
  5         9  
  5         4328  
4              
5             our $VERSION = "1.00";
6             my $number = qr/^-?\d+(?:\.\d+)$/;
7              
8             package Array::Stream::Transactional::Matcher::Value;
9             our @ISA = qw(Array::Stream::Transactional::Matcher::Rule);
10              
11             sub new {
12 34     34 1 73 my ($class, @args) = @_;
13 34   33     147 $class = ref $class || $class;
14 34         132 my $self = bless [@args], $class;
15 34         248 return $self;
16             }
17              
18 0     0 0 0 sub match { 1; }
19              
20             package Array::Stream::Transactional::Matcher::Value::eq;
21             our @ISA = qw(Array::Stream::Transactional::Matcher::Value);
22              
23             sub match {
24 129     129   164 my ($self, $stream) = @_;
25 129         302 my $compare = $stream->current;
26 129 50 33     878 return $compare == $self->[0] if($compare =~ $number && $self->[1]);
27 129         494 return $compare eq $self->[0];
28             }
29              
30             package Array::Stream::Transactional::Matcher::Value::ne;
31             our @ISA = qw(Array::Stream::Transactional::Matcher::Value);
32              
33             sub match {
34 6     6   13 my ($self, $stream) = @_;
35 6         14 my $compare = $stream->current;
36 6 50 33     57 return $compare != $self->[0] if($compare =~ $number && $self->[1]);
37 6         32 return $compare ne $self->[0];
38             }
39              
40             package Array::Stream::Transactional::Matcher::Value::gt;
41             our @ISA = qw(Array::Stream::Transactional::Matcher::Value);
42              
43             sub match {
44 11     11   16 my ($self, $stream) = @_;
45 11         30 my $compare = $stream->current;
46 11 50 33     86 return $compare > $self->[0] if($compare =~ $number && $self->[1]);
47 11         53 return $compare gt $self->[0];
48             }
49              
50             package Array::Stream::Transactional::Matcher::Value::lt;
51             our @ISA = qw(Array::Stream::Transactional::Matcher::Value);
52              
53             sub match {
54 9     9   17 my ($self, $stream) = @_;
55 9         23 my $compare = $stream->current;
56 9 50 33     66 return $compare < $self->[0] if($compare =~ $number && $self->[1]);
57 9         46 return $compare lt $self->[0];
58             }
59              
60             package Array::Stream::Transactional::Matcher::Value::ge;
61             our @ISA = qw(Array::Stream::Transactional::Matcher::Value);
62              
63             sub match {
64 40     40   56 my ($self, $stream) = @_;
65 40         98 my $compare = $stream->current;
66 40 50 33     288 return $compare >= $self->[0] if($compare =~ $number && $self->[1]);
67 40         191 return $compare ge $self->[0];
68             }
69              
70             package Array::Stream::Transactional::Matcher::Value::le;
71             our @ISA = qw(Array::Stream::Transactional::Matcher::Value);
72              
73             sub match {
74 6     6   8 my ($self, $stream) = @_;
75 6         13 my $compare = $stream->current;
76 6 50 33     47 return $compare <= $self->[0] if($compare =~ $number && $self->[1]);
77 6         28 return $compare le $self->[0];
78             }
79              
80             package Array::Stream::Transactional::Matcher::Value::isa;
81             our @ISA = qw(Array::Stream::Transactional::Matcher::Value);
82              
83             sub match {
84 6     6   10 my ($self, $stream) = @_;
85 6         14 my $compare = $stream->current;
86 6 100       47 return 0 unless(ref $compare);
87 1         15 return UNIVERSAL::isa($compare, $self->[0]);
88             }
89              
90             1;
91             __END__