File Coverage

blib/lib/Syntax/Keyword/Junction/All.pm
Criterion Covered Total %
statement 80 80 100.0
branch 50 50 100.0
condition n/a
subroutine 19 19 100.0
pod 0 15 0.0
total 149 164 90.8


line stmt bran cond sub pod time code
1             package Syntax::Keyword::Junction::All;
2 12     12   233363 use strict;
  12         22  
  12         526  
3 12     12   56 use warnings;
  12         21  
  12         767  
4              
5             our $VERSION = '0.003009';
6              
7 12     12   3691 use parent 'Syntax::Keyword::Junction::Base';
  12         2795  
  12         88  
8              
9             BEGIN {
10 12     12   12457 if (Syntax::Keyword::Junction::Base::_WANT_SMARTMATCH) {
11             eval '#line '.(__LINE__+1).' "' . __FILE__.qq["\n] . <<'END_CODE' or die $@;
12             no if Syntax::Keyword::Junction::Base::_SMARTMATCH_WARNING_CATEGORY,
13             warnings => Syntax::Keyword::Junction::Base::_SMARTMATCH_WARNING_CATEGORY;
14              
15             sub match {
16             my ( $self, $other, $is_rhs ) = @_;
17              
18             if ($is_rhs) {
19             for (@$self) {
20             return unless $other ~~ $_;
21             }
22              
23             return 1;
24             }
25              
26             for (@$self) {
27             return unless $_ ~~ $other;
28             }
29              
30             return 1;
31             }
32              
33             1;
34             END_CODE
35             }
36             }
37              
38             sub num_eq {
39 35 100   35 0 139 return regex_eq(@_) if ref( $_[1] ) eq 'Regexp';
40              
41 30         69 my ( $self, $test ) = @_;
42              
43 30         74 for (@$self) {
44 50 100       383 return unless $_ == $test;
45             }
46              
47 14         116 return 1;
48             }
49              
50             sub num_ne {
51 9 100   9 0 66 return regex_ne(@_) if ref( $_[1] ) eq 'Regexp';
52              
53 5         12 my ( $self, $test ) = @_;
54              
55 5         15 for (@$self) {
56 11 100       37 return unless $_ != $test;
57             }
58              
59 3         18 return 1;
60             }
61              
62             sub num_ge {
63 28     28 0 76 my ( $self, $test, $switch ) = @_;
64              
65 28 100       122 return num_le( $self, $test ) if $switch;
66              
67 11         29 for (@$self) {
68 23 100       84 return unless $_ >= $test;
69             }
70              
71 7         39 return 1;
72             }
73              
74             sub num_gt {
75 13     13 0 106 my ( $self, $test, $switch ) = @_;
76              
77 13 100       80 return num_lt( $self, $test ) if $switch;
78              
79 8         23 for (@$self) {
80 14 100       101 return unless $_ > $test;
81             }
82              
83 3         36 return 1;
84             }
85              
86             sub num_le {
87 23     23 0 58 my ( $self, $test, $switch ) = @_;
88              
89 23 100       64 return num_ge( $self, $test ) if $switch;
90              
91 20         45 for (@$self) {
92 42 100       159 return unless $_ <= $test;
93             }
94              
95 9         89 return 1;
96             }
97              
98             sub num_lt {
99 11     11 0 65 my ( $self, $test, $switch ) = @_;
100              
101 11 100       68 return num_gt( $self, $test ) if $switch;
102              
103 8         23 for (@$self) {
104 17 100       74 return unless $_ < $test;
105             }
106              
107 2         12 return 1;
108             }
109              
110             sub str_eq {
111 2     2 0 8 my ( $self, $test ) = @_;
112              
113 2         6 for (@$self) {
114 4 100       86 return unless $_ eq $test;
115             }
116              
117 1         7 return 1;
118             }
119              
120             sub str_ne {
121 2     2 0 7 my ( $self, $test ) = @_;
122              
123 2         7 for (@$self) {
124 4 100       18 return unless $_ ne $test;
125             }
126              
127 1         6 return 1;
128             }
129              
130             sub str_ge {
131 9     9 0 25 my ( $self, $test, $switch ) = @_;
132              
133 9 100       34 return str_le( $self, $test ) if $switch;
134              
135 6         15 for (@$self) {
136 10 100       38 return unless $_ ge $test;
137             }
138              
139 4         25 return 1;
140             }
141              
142             sub str_gt {
143 9     9 0 26 my ( $self, $test, $switch ) = @_;
144              
145 9 100       33 return str_lt( $self, $test ) if $switch;
146              
147 6         15 for (@$self) {
148 8 100       43 return unless $_ gt $test;
149             }
150              
151 2         12 return 1;
152             }
153              
154             sub str_le {
155 9     9 0 28 my ( $self, $test, $switch ) = @_;
156              
157 9 100       31 return str_ge( $self, $test ) if $switch;
158              
159 6         17 for (@$self) {
160 10 100       41 return unless $_ le $test;
161             }
162              
163 4         21 return 1;
164             }
165              
166             sub str_lt {
167 9     9 0 30 my ( $self, $test, $switch ) = @_;
168              
169 9 100       30 return str_gt( $self, $test ) if $switch;
170              
171 6         15 for (@$self) {
172 8 100       46 return unless $_ lt $test;
173             }
174              
175 2         12 return 1;
176             }
177              
178             sub regex_eq {
179 5     5 0 34 my ( $self, $test, $switch ) = @_;
180              
181 5         16 for (@$self) {
182 13 100       255 return unless $_ =~ $test;
183             }
184              
185 2         45 return 1;
186             }
187              
188             sub regex_ne {
189 4     4 0 14 my ( $self, $test, $switch ) = @_;
190              
191 4         11 for (@$self) {
192 11 100       142 return unless $_ !~ $test;
193             }
194              
195 2         13 return 1;
196             }
197              
198             sub bool {
199 6     6 0 519 my ($self) = @_;
200              
201 6         18 for (@$self) {
202 12 100       46 return unless $_;
203             }
204              
205 3         10 return 1;
206             }
207              
208             1;
209              
210             __END__
211              
212             =pod
213              
214             =encoding UTF-8
215              
216             =for :stopwords Arthur Axel "fREW" Schmidt Carl Franks
217              
218             =head1 BUGS
219              
220             Please report any bugs or feature requests on the bugtracker website
221             L<https://github.com/haarg/Syntax-Keyword-Junction/issues>
222              
223             When submitting a bug or request, please include a test-file or a
224             patch to an existing test-file that illustrates the bug or desired
225             feature.
226              
227             =head1 AUTHORS
228              
229             =over 4
230              
231             =item *
232              
233             Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
234              
235             =item *
236              
237             Carl Franks
238              
239             =back
240              
241             =head1 COPYRIGHT AND LICENSE
242              
243             This software is copyright (c) 2024 by Arthur Axel "fREW" Schmidt.
244              
245             This is free software; you can redistribute it and/or modify it under
246             the same terms as the Perl 5 programming language system itself.
247              
248             =cut