File Coverage

blib/lib/Iterator/Flex/Role/Next/ClosedSelf.pm
Criterion Covered Total %
statement 42 42 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 11 11 100.0
pod 1 1 100.0
total 56 59 94.9


line stmt bran cond sub pod time code
1             package Iterator::Flex::Role::Next::ClosedSelf;
2              
3             # ABSTRACT: Role for closure iterator which closes over self
4              
5 40     40   183226 use v5.28;
  40         123  
6 40     40   160 use strict;
  40         59  
  40         752  
7 40     40   129 use warnings;
  40         57  
  40         2308  
8              
9             our $VERSION = '0.34';
10              
11 40     40   570 use Ref::Util;
  40         1956  
  40         1449  
12 40     40   175 use Scalar::Util;
  40         156  
  40         1541  
13 40     40   530 use Iterator::Flex::Utils qw( NEXT _SELF throw_failure );
  40         162  
  40         2176  
14              
15 40     40   560 use Role::Tiny;
  40         4685  
  40         496  
16 40     40   7945 use experimental 'signatures';
  40         59  
  40         295  
17 40     40   5360 use namespace::clean;
  40         11364  
  40         230  
18              
19              
20              
21              
22              
23              
24              
25              
26              
27 308     308   403 sub _construct_next ( $class, $ipar, $ ) {
  308         382  
  308         345  
  308         376  
28              
29 308   33     609 my $sub = $ipar->{ +NEXT } // throw_failure( parameter => q{Missing 'next' parameter} );
30 308         593 Scalar::Util::weaken $ipar->{ +NEXT };
31              
32             throw_failure( parameter => q{Missing ability to set self} )
33 308 50       582 unless exists $ipar->{ +_SELF };
34              
35 308         439 my $ref = $ipar->{ +_SELF };
36 308         408 $$ref = $sub;
37 308         492 Scalar::Util::weaken $$ref;
38 308         710 return $sub;
39             }
40              
41 1914     1914 1 92156 sub next ( $self ) { &{$self}() } ## no critic( BuiltinHomonyms )
  1914         2044  
  1914         1838  
  1914         1913  
  1914         3965  
42             *__next__ = \&next;
43              
44             1;
45              
46             #
47             # This file is part of Iterator-Flex
48             #
49             # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
50             #
51             # This is free software, licensed under:
52             #
53             # The GNU General Public License, Version 3, June 2007
54             #
55              
56             __END__