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   342827 use v5.28;
  40         181  
6 40     40   223 use strict;
  40         76  
  40         1225  
7 40     40   236 use warnings;
  40         115  
  40         2998  
8              
9             our $VERSION = '0.33';
10              
11 40     40   960 use Ref::Util;
  40         3016  
  40         2139  
12 40     40   266 use Scalar::Util;
  40         150  
  40         2096  
13 40     40   809 use Iterator::Flex::Utils qw( NEXT _SELF );
  40         231  
  40         2972  
14              
15 40     40   1050 use Role::Tiny;
  40         8682  
  40         448  
16 40     40   10813 use experimental 'signatures';
  40         184  
  40         355  
17 40     40   9114 use namespace::clean;
  40         18928  
  40         295  
18              
19              
20              
21              
22              
23              
24              
25              
26              
27 288     288   548 sub _construct_next ( $class, $ipar, $ ) {
  288         507  
  288         491  
  288         434  
28              
29 288   33     948 my $sub = $ipar->{ +NEXT } // throw_failure( parameter => q{Missing 'next' parameter} );
30 288         781 Scalar::Util::weaken $ipar->{ +NEXT };
31              
32             throw_failure( parameter => q{Missing ability to set self} )
33 288 50       797 unless exists $ipar->{ +_SELF };
34              
35 288         568 my $ref = $ipar->{ +_SELF };
36 288         552 $$ref = $sub;
37 288         657 Scalar::Util::weaken $$ref;
38 288         892 return $sub;
39             }
40              
41 1895     1895 1 142628 sub next ( $self ) { &{$self}() } ## no critic( BuiltinHomonyms )
  1895         2912  
  1895         2882  
  1895         2794  
  1895         6354  
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__