SDK/Core/Pager.pm

filter: Statementstmt 100% 48 / 48 Branchbran 81.8% 18 / 22 Conditioncond 75.0% 9 / 12 MC/DCmcdc 50.0% 4 / 8 Subroutinesub 100% 11 / 11 Podpod 100% 4 / 4 totaltotal 89.5% 94 / 105 CC 16 SCAR 14.1
CC
16
Cov
91%
next_page
7.1
__ANON__
5.4
next_item
4.0
CRAP 4.1
« SDK/Storage/Queues/Serializer.pm ↑ Summary SDK/Storage/Queues/QueueProperties.pm »
1 10 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 10 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 10 ▶use Azure::SDK::Core::Page;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 10 class Azure::SDK::Core::Pager {
8 10 ▶ use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶ use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
10
11 10 field $fetch_page :param;
12 10 field $continuation_token :param :reader = undef;
13
14 10 field $current_page :reader = undef;
15 10 field $item_index = 0;
16 10 field $exhausted = 0;
17 10 field %seen_tokens;
18
19 13 ▶ ADJUST {
Subroutine __ANON__: called CC=5 SCAR=16.8
20 13 ▶ croak 'Azure::SDK::Core::Pager fetch_page must be a code reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $fetch_page eq "CODE" 0 13 13
21 unless ref $fetch_page eq 'CODE';
22
23 13 ▶ $continuation_token = undef
Branch: 1 branch
BranchTrueFalseTotal
if defined $continuation_token and not length $continuation_token 0 13 13
Condition66%2/3
defined $continuation_token and not length $continuation_token
!ll&&!rl&&r
940
MC/DC0%0/2
defined $continuation_token and not length $continuation_token
defined $continuation_token not length $continuation_token
Truth table66%2/3
A and not(B)
A= defined $continuation_tokenB= not length $continuation_token
ABresult
0X0
100
111
24 if defined $continuation_token && !length $continuation_token;
25 13 ▶ $seen_tokens{$continuation_token} = 1
Branch: 1 branch
BranchTrueFalseTotal
if defined $continuation_token 4 9 13
26 if defined $continuation_token;
27 }
28
29 3 ▶ method has_more () {
Subroutine has_more: called CC=2 SCAR=6.9
Pod documented
30 3 ▶ return $exhausted ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$exhausted ? : 2 1 3
31 }
32
33 1 ▶ method items () {
Subroutine items: called CC=2 SCAR=7.6
Pod documented
34 1 ▶ return $current_page ? $current_page->items : [];
Branch: 1 branch
BranchTrueFalseTotal
$current_page ? : 1 0 1
35 }
36
37 26 ▶ method next_page () {
Subroutine next_page: called CC=7 SCAR=19.6
Pod documented
38 26 ▶ return undef if $exhausted;
Branch: 1 branch
BranchTrueFalseTotal
if $exhausted 1 25 26
39
40 25 my $page = $fetch_page->($continuation_token);
41 25 ▶ croak 'Azure::SDK::Core::Pager fetch_page must return an Azure::SDK::Core::Page'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($page) and $page->isa("Azure::SDK::Core::Page") 0 25 25
Condition33%1/3
builtin::blessed($page) and $page->isa("Azure::SDK::Core::Page")
!ll&&!rl&&r
0025
MC/DC0%0/2
builtin::blessed($page) and $page->isa("Azure::SDK::Core::Page")
builtin::blessed($page) $page->isa("Azure::SDK::Core::Page")
Truth table33%1/3
A and B
A= builtin::blessed($page)B= $page->isa("Azure::SDK::Core::Page")
ABresult
0X0
100
111
42 unless blessed($page)
43 && $page->isa('Azure::SDK::Core::Page');
44
45 25 $current_page = $page;
46 25 $item_index = 0;
47
48 25 my $next_token = $page->continuation_token;
49 25 ▶ if (defined $next_token && $seen_tokens{$next_token}++) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $next_token and $seen_tokens{$next_token}++) 1 24 25
Condition100%3/3
defined $next_token and $seen_tokens{$next_token}++
!ll&&!rl&&r
12121
MC/DC100%2/2
defined $next_token and $seen_tokens{$next_token}++
defined $next_token $seen_tokens{$next_token}++
Truth table100%3/3
A and B
A= defined $next_tokenB= $seen_tokens{$next_token}++
ABresult
0X0
100
111
50 1 $continuation_token = $next_token;
51 1 $exhausted = 1;
52 1 croak 'Page listing returned a repeated continuation token';
53 }
54
55 24 $continuation_token = $next_token;
56 24 ▶ $exhausted = 1 unless defined $continuation_token;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $continuation_token 12 12 24
57
58 24 return $page;
59 }
60
61 31 ▶ method next_item () {
Subroutine next_item: called CC=4 SCAR=13.9
Pod documented
62 31 while (1) {
63 53 ▶ if ($current_page && $item_index < $current_page->count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_page and $item_index < $current_page->count) 20 33 53
Condition100%3/3
$current_page and $item_index < $current_page->count
!ll&&!rl&&r
112220
MC/DC100%2/2
$current_page and $item_index < $current_page->count
$current_page $item_index < $current_page->count
Truth table100%3/3
A and B
A= $current_pageB= $item_index < $current_page->count
ABresult
0X0
100
111
64 20 return $current_page->items->[$item_index++];
65 }
66
67 33 ▶ return undef if $exhausted;
Branch: 1 branch
BranchTrueFalseTotal
if $exhausted 11 22 33
68 22 $self->next_page;
69 }
70 }
71 }
72
73 10 1;
74
75 __END__
« SDK/Storage/Queues/Serializer.pm ↑ Summary SDK/Storage/Queues/QueueProperties.pm »