File Coverage

blib/lib/Aion/Type/Lim.pm
Criterion Covered Total %
statement 25 25 100.0
branch 12 14 85.7
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 45 50 90.0


line stmt bran cond sub pod time code
1             package Aion::Type::Lim;
2             # Граница для Range
3              
4 8     8   125551 use common::sense;
  8         11  
  8         37  
5              
6             use overload
7             "fallback" => 1,
8 455 100   455   1453 "<=>" => sub { my ($self, $other) = _up(@_); $self->{lim} == $other->{lim}? $self->{shifting} <=> $other->{shifting}: $self->{lim} <=> $other->{lim} },
  455         1724  
9 69 100   69   1214 '""' => sub { my ($self) = @_; $self->{shifting}? "Opened[$self->{lim}]": "Closed[$self->{lim}]" },
  69         187  
10 8     8   2192 ;
  8         1346  
  8         81  
11              
12             # Конструктор
13             sub from {
14 350     350 0 134731 my ($cls, $lim) = @_;
15 350 100       1061 bless { ref $lim eq $cls? %$lim: (lim => $lim) }, $cls;
16             }
17              
18             # Преобразователь операторных аргументов
19             sub _up {
20 455     455   700 my ($self, $other, $right) = @_;
21 455 100       969 unless(UNIVERSAL::isa($other, __PACKAGE__)) {
22 322         461 $other = __PACKAGE__->from($other);
23 322 100       535 ($other, $self) = ($self, $other) if $right;
24             }
25 455         656 return $self, $other;
26             }
27              
28             # Умесньшает сдвиг
29             sub dec {
30 14     14 0 27 my ($self) = @_;
31 14 50       58 $self->{lim} == '-Inf'? '-Inf': do { $self->{shifting}--; $self }
  14         26  
  14         49  
32             }
33              
34             # Увеличивает сдвиг
35             sub inc {
36 13     13 0 26 my ($self) = @_;
37 13 50       40 $self->{lim} == 'Inf'? 'Inf': do { $self->{shifting}++; $self }
  13         22  
  13         37  
38             }
39              
40             1;