blib/lib/Test/SMTP.pm

filter: Statementstmt 81.1% 233 / 287 Branchbran 72.9% 54 / 74 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 87.7% 50 / 57 Podpod 100% 46 / 46 totaltotal 82.9% 393 / 474 CC 40 SCAR 11.4
CC
40
Cov
80%
starttls_ok
12.0
starttls_ko
12.0
_convert_to_ssl
12.0
CRAP 3.1
↑ Summary
1 package Test::SMTP;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 our $VERSION = '0.05'; # VERSION
7 # ABSTRACT: Module for writing SMTP Server tests
8  
9 9 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 ▶ use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 ▶ use Net::SMTP_auth;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 9 ▶ use Test::Builder::Module;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 9 ▶ use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 9 @ISA = qw(Net::SMTP_auth Test::Builder::Module);
17 #Give a hoot don't pollute, do not export more than needed by default
18 9 @EXPORT = qw();
19 9 @EXPORT_OK = qw(plan);
20 9 %EXPORT_TAGS = ();
21 }
22  
23  
24 1 ▶sub plan {
Subroutine plan: called CC=1 SCAR=0.0
Pod documented
25 1 my $tb = __PACKAGE__->builder;
26 1 $tb->plan(@_);
27 }
28  
29  
30 6 ▶sub connect_ok {
Subroutine connect_ok: called CC=4 SCAR=13.9
Pod documented
31 6 my ($class, $name, %params) = @_;
32  
33 6 ▶ if ((not defined($params{'AutoHello'})) or ($params{'AutoHello'} != 1)){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $params{"AutoHello"} or $params{"AutoHello"} != 1) 2 4 6
Condition100%3/3
not defined $params{"AutoHello"} or $params{"AutoHello"} != 1
l!l&&r!l&&!r
114
MC/DC100%2/2
not defined $params{"AutoHello"} or $params{"AutoHello"} != 1
not defined $params{"AutoHello"} $params{"AutoHello"} != 1
Truth table100%3/3
not(A) or B
A= not defined $params{"AutoHello"}B= $params{"AutoHello"} != 1
ABresult
1X1
011
000
34 2 croak "Can only handle AutoHello for now...";
35 }
36  
37 4 my $smtp = Net::SMTP_auth->new(%params);
38  
39 4 my $tb = __PACKAGE__->builder();
40 4 $tb->ok(defined $smtp, $name);
41  
42 4 ▶ if (not defined($smtp)){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $smtp) 1 3 4
43 1 return;
44 }
45  
46 3 bless $smtp, $class;
47 3 return $smtp;
48 }
49  
50  
51 3 ▶sub connect_ko {
Subroutine connect_ko: called CC=2 SCAR=6.9
Pod documented
52 3 my ($class, $name, @params) = @_;
53  
54 3 my $smtp = Net::SMTP_auth->new(@params);
55 3 my $tb = __PACKAGE__->builder();
56  
57 3 $tb->ok(not(defined $smtp), $name);
58  
59 3 ▶ if (not defined $smtp){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $smtp) 2 1 3
60 2 return;
61 }
62  
63 1 bless $smtp, $class;
64 1 return $smtp;
65 }
66  
67  
68  
69 6 ▶sub code_is {
Subroutine code_is: called CC=1 SCAR=0.0
Pod documented
70 6 my ($self, $expected, $name) = @_;
71 6 my $tb = __PACKAGE__->builder();
72  
73 6 $tb->cmp_ok($self->code(), '==', $expected, $name);
74 }
75  
76  
77 6 ▶sub code_isnt {
Subroutine code_isnt: called CC=1 SCAR=0.0
Pod documented
78 6 my ($self, $expected, $name) = @_;
79 6 my $tb = __PACKAGE__->builder();
80  
81 6 $tb->cmp_ok($self->code(), '!=', $expected, $name);
82 }
83  
84  
85 4 ▶sub code_is_success {
Subroutine code_is_success: called CC=2 SCAR=6.9
Pod documented
86 4 my ($self, $name) = @_;
87 4 my $tb = __PACKAGE__->builder();
88  
89 4 ▶ if (_is_between($self->code(), 200, 399)){
Branch: 1 branch
BranchTrueFalseTotal
if (_is_between($self->code, 200, 399)) { } 2 2 4
90 2 $tb->ok(1, $name);
91 } else {
92 2 $tb->ok(0, $name);
93 2 $self->_smtp_diag;
94 }
95 }
96  
97  
98 5 ▶sub code_isnt_success {
Subroutine code_isnt_success: called CC=2 SCAR=6.9
Pod documented
99 5 my ($self, $name) = @_;
100 5 my $tb = __PACKAGE__->builder();
101  
102 5 ▶ if (_is_between($self->code(), 200, 399)){
Branch: 1 branch
BranchTrueFalseTotal
if (_is_between($self->code, 200, 399)) { } 1 4 5
103 1 $tb->ok(0, $name);
104 1 $self->_smtp_diag;
105 } else {
106 4 $tb->ok(1, $name);
107 }
108 }
109  
110  
111 5 ▶sub code_is_failure {
Subroutine code_is_failure: called CC=2 SCAR=6.9
Pod documented
112 5 my ($self, $name) = @_;
113 5 my $tb = __PACKAGE__->builder();
114  
115 5 ▶ if (not _is_between($self->code(), 200, 399)){
Branch: 1 branch
BranchTrueFalseTotal
if (not _is_between($self->code, 200, 399)) { } 4 1 5
116 4 $tb->ok(1, $name);
117 } else {
118 1 $tb->ok(0, $name);
119 1 $self->_smtp_diag;
120 }
121 }
122  
123  
124 4 ▶sub code_isnt_failure {
Subroutine code_isnt_failure: called CC=2 SCAR=6.9
Pod documented
125 4 my ($self, $name) = @_;
126 4 my $tb = __PACKAGE__->builder();
127  
128 4 ▶ if (not _is_between($self->code(), 200, 399)){
Branch: 1 branch
BranchTrueFalseTotal
if (not _is_between($self->code, 200, 399)) { } 2 2 4
129 2 $tb->ok(0, $name);
130 2 $self->_smtp_diag;
131 } else {
132 2 $tb->ok(1, $name);
133 }
134 }
135  
136  
137 4 ▶sub code_is_temporary {
Subroutine code_is_temporary: called CC=2 SCAR=6.9
Pod documented
138 4 my ($self, $name) = @_;
139 4 my $tb = __PACKAGE__->builder();
140  
141 4 ▶ if (_is_between($self->code(), 400, 499)){
Branch: 1 branch
BranchTrueFalseTotal
if (_is_between($self->code, 400, 499)) { } 2 2 4
142 2 $tb->ok(1, $name);
143 } else {
144 2 $tb->ok(0, $name);
145 2 $self->_smtp_diag;
146 }
147 }
148  
149  
150 5 ▶sub code_isnt_temporary {
Subroutine code_isnt_temporary: called CC=2 SCAR=6.9
Pod documented
151 5 my ($self, $name) = @_;
152 5 my $tb = __PACKAGE__->builder();
153  
154 5 ▶ if (_is_between($self->code(), 400, 499)){
Branch: 1 branch
BranchTrueFalseTotal
if (_is_between($self->code, 400, 499)) { } 1 4 5
155 1 $tb->ok(0, $name);
156 1 $self->_smtp_diag;
157 } else {
158 4 $tb->ok(1, $name);
159 }
160 }
161  
162  
163 4 ▶sub code_is_permanent {
Subroutine code_is_permanent: called CC=2 SCAR=6.9
Pod documented
164 4 my ($self, $name) = @_;
165 4 my $tb = __PACKAGE__->builder();
166  
167 4 ▶ if (_is_between($self->code(), 500, 599)){
Branch: 1 branch
BranchTrueFalseTotal
if (_is_between($self->code, 500, 599)) { } 2 2 4
168 2 $tb->ok(1, $name);
169 } else {
170 2 $tb->ok(0, $name);
171 2 $self->_smtp_diag;
172 }
173 }
174  
175  
176 5 ▶sub code_isnt_permanent {
Subroutine code_isnt_permanent: called CC=2 SCAR=6.9
Pod documented
177 5 my ($self, $name) = @_;
178 5 my $tb = __PACKAGE__->builder();
179  
180 5 ▶ if (_is_between($self->code(), 500, 599)){
Branch: 1 branch
BranchTrueFalseTotal
if (_is_between($self->code, 500, 599)) { } 1 4 5
181 1 $tb->ok(0, $name);
182 1 $self->_smtp_diag;
183 } else {
184 4 $tb->ok(1, $name);
185 }
186 }
187  
188  
189 6 ▶sub message_like {
Subroutine message_like: called CC=1 SCAR=0.0
Pod documented
190 6 my ($self, $expected, $name) = @_;
191 6 my $tb = __PACKAGE__->builder();
192  
193 6 my $message = $self->message();
194 6 $tb->like($message, $expected, $name);
195 }
196  
197  
198 6 ▶sub message_unlike {
Subroutine message_unlike: called CC=1 SCAR=0.0
Pod documented
199 6 my ($self, $expected, $name) = @_;
200 6 my $tb = __PACKAGE__->builder();
201  
202 6 my $message = $self->message();
203 6 $tb->unlike($message, $expected, $name);
204 }
205  
206  
207 0 ▶sub auth_ok {
Subroutine auth_ok: not called CC=2 SCAR=17.9
Pod documented
208 0 my ($self, $method, $user, $password, $name) = @_;
209 0 my $tb = __PACKAGE__->builder();
210  
211 0 my $result = $self->auth($method, $user, $password);
212 0 ▶ if ($result){
Branch: 1 branch
BranchTrueFalseTotal
if ($result) { } 0 0 0
213 0 $tb->ok(1, $name);
214 } else {
215 0 $tb->ok(0, $name);
216 0 $self->_smtp_diag;
217 }
218 }
219  
220  
221 0 ▶sub auth_ko {
Subroutine auth_ko: not called CC=2 SCAR=17.9
Pod documented
222 0 my ($self, $method, $user, $password, $name) = @_;
223 0 my $tb = __PACKAGE__->builder();
224  
225 0 my $result = $self->auth($method, $user, $password);
226 0 ▶ if ($result){
Branch: 1 branch
BranchTrueFalseTotal
if ($result) { } 0 0 0
227 0 $tb->ok(0, $name);
228 0 $self->_smtp_diag;
229 } else {
230 0 $tb->ok(1, $name);
231 }
232 }
233  
234  
235 0 ▶sub starttls_ok {
Subroutine starttls_ok: not called CC=3 SCAR=24.8
Pod documented
236 0 my ($self, $name, @sslargs) = @_;
237 0 my $tb = __PACKAGE__->builder();
238  
239 0 ▶ if (not ($self->command('STARTTLS')->response() == Net::Cmd::CMD_OK)){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->command("STARTTLS")->response == 2) 0 0 0
240 0 $tb->ok(0, $name);
241 0 $self->_smtp_diag;
242 0 return;
243 }
244 0 ▶ if (not $self->_convert_to_ssl(@sslargs)){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_convert_to_ssl(@sslargs)) 0 0 0
245 0 $tb->ok(0, $name);
246 0 $tb->diag('SSL: ' . IO::Socket::SSL::errstr());
247 0 return;
248 }
249  
250 0 $tb->ok(1, $name);
251 }
252  
253  
254 0 ▶sub starttls_ko {
Subroutine starttls_ko: not called CC=3 SCAR=24.8
Pod documented
255 0 my ($self, $name, @sslargs) = @_;
256 0 my $tb = __PACKAGE__->builder();
257  
258 0 ▶ if (not ($self->command('STARTTLS')->response() == Net::Cmd::CMD_OK)){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->command("STARTTLS")->response == 2) 0 0 0
259 0 $tb->ok(1, $name);
260 0 return;
261 }
262 0 ▶ if (not $self->_convert_to_ssl(@sslargs)){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_convert_to_ssl(@sslargs)) 0 0 0
263 0 $tb->ok(1, $name);
264 0 return;
265 }
266
267 0 $tb->ok(0, $name);
268 0 $self->_smtp_diag;
269 0 $tb->diag('And SSL negotiation went OK');
270 }
271  
272 0 ▶sub _convert_to_ssl {
Subroutine _convert_to_ssl: not called CC=3 SCAR=24.8
273 0 my ($self, @sslargs) = @_;
274 0 ▶ require IO::Socket::SSL or die "starttls requires IO::Socket::SSL";
Branch: 1 branch
BranchTrueFalseTotal
require IO::Socket::SSL or die "starttls requires IO::Socket::SSL" 0 0 0
275 # the socket is stored in ${*self}{'_ssl_sock'}.
276 # If not, when starttls sub ends *$self is not tied to the SSL
277 # socket anymore, instead, it's tied to the old socket.
278 0 ▶ my $ssl_sock = IO::Socket::SSL->new_from_fd($self->fileno, @sslargs)
Branch: 1 branch
BranchTrueFalseTotal
my $ssl_sock = "IO::Socket::SSL"->new_from_fd($self->fileno, @sslargs) or return 0 0 0 0
279 or return 0;
280 0 ${*self}{'_ssl_sock'} = $ssl_sock;
281 0 *$self = *$ssl_sock;
282 }
283  
284  
285 0 ▶sub hello_ok {
Subroutine hello_ok: not called CC=2 SCAR=17.9
Pod documented
286 0 my ($self, $hello, $name) = @_;
287 0 my $tb = __PACKAGE__->builder();
288  
289 0 ▶ if ($self->hello($hello)){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->hello($hello)) { } 0 0 0
290 0 $tb->ok(1, $name);
291 } else {
292 0 $tb->ok(0, $name);
293 0 $self->_smtp_diag;
294 }
295 }
296  
297  
298 0 ▶sub hello_ko {
Subroutine hello_ko: not called CC=2 SCAR=17.9
Pod documented
299 0 my ($self, $hello, $name) = @_;
300 0 my $tb = __PACKAGE__->builder();
301  
302 0 ▶ if ($self->hello($hello)){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->hello($hello)) { } 0 0 0
303 0 $tb->ok(0, $name);
304 0 $self->_smtp_diag;
305 } else {
306 0 $tb->ok(1, $name);
307 }
308 }
309  
310  
311  
312 4 ▶sub rset_ok {
Subroutine rset_ok: called CC=2 SCAR=6.9
Pod documented
313 4 my ($self, $name) = @_;
314 4 my $tb = __PACKAGE__->builder();
315  
316 4 ▶ if ($self->reset){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reset) { } 3 1 4
317 3 $tb->ok(1, $name);
318 } else {
319 1 $tb->ok(0, $name);
320 1 $self->_smtp_diag;
321 }
322 }
323  
324  
325 3 ▶sub rset_ko {
Subroutine rset_ko: called CC=2 SCAR=6.9
Pod documented
326 3 my ($self, $name) = @_;
327 3 my $tb = __PACKAGE__->builder();
328  
329 3 ▶ if ($self->reset){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reset) { } 2 1 3
330 2 $tb->ok(0, $name);
331 2 $self->_smtp_diag;
332 } else {
333 1 $tb->ok(1, $name);
334 }
335 }
336  
337  
338 3 ▶sub supports_ok {
Subroutine supports_ok: called CC=2 SCAR=6.9
Pod documented
339 3 my ($self, $capa, $name) = @_;
340 3 my $tb = __PACKAGE__->builder();
341  
342 3 ▶ if (defined $self->supports($capa)){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->supports($capa)) { } 2 1 3
343 2 $tb->ok(1, $name);
344 } else {
345 1 $tb->ok(0, $name);
346 }
347 }
348  
349  
350 3 ▶sub supports_ko {
Subroutine supports_ko: called CC=2 SCAR=6.9
Pod documented
351 3 my ($self, $capa, $name) = @_;
352 3 my $tb = __PACKAGE__->builder();
353  
354 3 ▶ if (defined $self->supports($capa)){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->supports($capa)) { } 2 1 3
355 2 $tb->ok(0, $name);
356 2 $tb->diag("Server supports the feature $capa with " . $self->supports($capa));
357 } else {
358 1 $tb->ok(1, $name);
359 }
360 }
361  
362  
363 2 ▶sub supports_cmp_ok {
Subroutine supports_cmp_ok: called CC=1 SCAR=0.0
Pod documented
364 2 my ($self, $capa, $operator, $expected, $name) = @_;
365 2 my $tb = __PACKAGE__->builder();
366  
367 2 my $val = $self->supports($capa);
368 2 $tb->cmp_ok($val, $operator, $expected, $name);
369 }
370  
371  
372 1 ▶sub supports_like {
Subroutine supports_like: called CC=1 SCAR=0.0
Pod documented
373 1 my ($self, $capa, $expected, $name) = @_;
374 1 my $tb = __PACKAGE__->builder();
375  
376 1 my $val = $self->supports($capa);
377 1 $tb->like($val, $expected, $name);
378 }
379  
380  
381 1 ▶sub supports_unlike {
Subroutine supports_unlike: called CC=1 SCAR=0.0
Pod documented
382 1 my ($self, $capa, $expected, $name) = @_;
383 1 my $tb = __PACKAGE__->builder();
384  
385 1 my $val = $self->supports($capa);
386 1 $tb->unlike($val, $expected, $name);
387 }
388  
389  
390 1 ▶sub banner_like {
Subroutine banner_like: called CC=1 SCAR=0.0
Pod documented
391 1 my ($self, $qr, $name) = @_;
392 1 my $tb = __PACKAGE__->builder();
393  
394 1 $tb->like($self->banner(), $qr, $name);
395 }
396  
397  
398 1 ▶sub banner_unlike {
Subroutine banner_unlike: called CC=1 SCAR=0.0
Pod documented
399 1 my ($self, $qr, $name) = @_;
400 1 my $tb = __PACKAGE__->builder();
401  
402 1 $tb->unlike($self->banner(), $qr, $name);
403 }
404  
405  
406 1 ▶sub domain_like {
Subroutine domain_like: called CC=1 SCAR=0.0
Pod documented
407 1 my ($self, $qr, $name) = @_;
408 1 my $tb = __PACKAGE__->builder();
409  
410 1 $tb->like($self->domain(), $qr, $name);
411 }
412  
413  
414 1 ▶sub domain_unlike {
Subroutine domain_unlike: called CC=1 SCAR=0.0
Pod documented
415 1 my ($self, $qr, $name) = @_;
416 1 my $tb = __PACKAGE__->builder();
417  
418 1 $tb->unlike($self->domain(), $qr, $name);
419 }
420  
421  
422 4 ▶sub mail_from_ok {
Subroutine mail_from_ok: called CC=2 SCAR=6.9
Pod documented
423 4 my ($self, $from, $name) = @_;
424 4 my $tb = __PACKAGE__->builder();
425  
426 4 ▶ if ($self->mail_from($from)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mail_from($from)) { } 2 2 4
427 2 $tb->ok(1, $name);
428 } else {
429 2 $tb->ok(0, $name);
430 2 $self->_smtp_diag;
431 }
432 }
433  
434  
435 3 ▶sub mail_from_ko {
Subroutine mail_from_ko: called CC=2 SCAR=6.9
Pod documented
436 3 my ($self, $from, $name) = @_;
437 3 my $tb = __PACKAGE__->builder();
438  
439 3 ▶ if (not $self->mail_from($from)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->mail_from($from)) { } 2 1 3
440 2 $tb->ok(1, $name);
441 } else {
442 1 $tb->ok(0, $name);
443 1 $self->_smtp_diag;
444 }
445 }
446  
447  
448 4 ▶sub rcpt_to_ok {
Subroutine rcpt_to_ok: called CC=2 SCAR=6.9
Pod documented
449 4 my ($self, $to, $name) = @_;
450 4 my $tb = __PACKAGE__->builder();
451  
452 4 ▶ if ($self->rcpt_to($to)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->rcpt_to($to)) { } 2 2 4
453 2 $tb->ok(1, $name);
454 } else {
455 2 $tb->ok(0, $name);
456 2 $self->_smtp_diag;
457 }
458 }
459  
460  
461 3 ▶sub rcpt_to_ko {
Subroutine rcpt_to_ko: called CC=2 SCAR=6.9
Pod documented
462 3 my ($self, $to, $name) = @_;
463 3 my $tb = __PACKAGE__->builder();
464  
465 3 ▶ if (not $self->rcpt_to($to)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->rcpt_to($to)) { } 2 1 3
466 2 $tb->ok(1, $name);
467 } else {
468 1 $tb->ok(0, $name);
469 1 $self->_smtp_diag;
470 }
471 }
472  
473  
474 3 ▶sub data_ok {
Subroutine data_ok: called CC=2 SCAR=6.9
Pod documented
475 3 my ($self, $name) = @_;
476 3 my $tb = __PACKAGE__->builder();
477  
478 3 ▶ if ($self->data == 1){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data == 1) { } 2 1 3
479 2 $tb->ok(1, $name);
480 } else {
481 1 $tb->ok(0, $name);
482 1 $self->_smtp_diag;
483 }
484 }
485  
486  
487 2 ▶sub data_ko {
Subroutine data_ko: called CC=2 SCAR=6.9
Pod documented
488 2 my ($self, $name) = @_;
489 2 my $tb = __PACKAGE__->builder();
490  
491 2 ▶ if ($self->data != 1){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data != 1) { } 1 1 2
492 1 $tb->ok(1, $name);
493 } else {
494 1 $tb->ok(0, $name);
495 1 $self->_smtp_diag;
496 }
497 }
498  
499 #sub datasend {
500 # my ($self, $data) = @_;
501 #
502 # if (ref($data) eq 'ARRAY'){
503 # $self::SUPER->datasend($data);
504 # }
505 #}
506  
507  
508 2 ▶sub dataend_ok {
Subroutine dataend_ok: called CC=2 SCAR=6.9
Pod documented
509 2 my ($self, $name) = @_;
510 2 my $tb = __PACKAGE__->builder();
511  
512 2 ▶ if ($self->dataend() == 1){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dataend == 1) { } 1 1 2
513 1 $tb->ok(1, $name);
514 } else {
515 1 $tb->ok(0, $name);
516 1 $self->_smtp_diag();
517 }
518 }
519  
520  
521 2 ▶sub dataend_ko {
Subroutine dataend_ko: called CC=2 SCAR=6.9
Pod documented
522 2 my ($self, $name) = @_;
523 2 my $tb = __PACKAGE__->builder();
524  
525 2 ▶ if ($self->dataend() != 1){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dataend != 1) { } 1 1 2
526 1 $tb->ok(1, $name);
527 } else {
528 1 $tb->ok(0, $name);
529 1 $self->_smtp_diag();
530 }
531 }
532  
533  
534 3 ▶sub help_like {
Subroutine help_like: called CC=2 SCAR=6.9
Pod documented
535 3 my ($self, $help_on, $expected, $name) = @_;
536 3 my $tb = __PACKAGE__->builder();
537  
538 3 ▶ my $msg = $self->help(
Branch: 1 branch
BranchTrueFalseTotal
defined $help_on ? : 2 1 3
539 defined $help_on ? $help_on : ()
540 );
541 3 $tb->like($msg, $expected, $name);
542 }
543  
544  
545 2 ▶sub help_unlike {
Subroutine help_unlike: called CC=2 SCAR=6.9
Pod documented
546 2 my ($self, $help_on, $expected, $name) = @_;
547 2 my $tb = __PACKAGE__->builder();
548  
549 2 ▶ my $msg = $self->help(
Branch: 1 branch
BranchTrueFalseTotal
defined $help_on ? : 1 1 2
550 defined $help_on ? $help_on : ()
551 );
552 2 $tb->unlike($msg, $expected, $name);
553 }
554  
555  
556 2 ▶sub quit_ok {
Subroutine quit_ok: called CC=2 SCAR=6.9
Pod documented
557 2 my ($self, $name) = @_;
558 2 my $tb = __PACKAGE__->builder();
559 2 $self->quit();
560 2 ▶ if (_is_between($self->code(), 200, 399)){
Branch: 1 branch
BranchTrueFalseTotal
if (_is_between($self->code, 200, 399)) { } 1 1 2
561 1 $tb->ok(1, $name);
562 } else {
563 1 $tb->ok(0, $name);
564 1 $self->_smtp_diag;
565 }
566 }
567  
568  
569 2 ▶sub quit_ko {
Subroutine quit_ko: called CC=2 SCAR=6.9
Pod documented
570 2 my ($self, $name) = @_;
571 2 my $tb = __PACKAGE__->builder();
572 2 $self->quit();
573 2 ▶ if (_is_between($self->code(), 200, 399)){
Branch: 1 branch
BranchTrueFalseTotal
if (_is_between($self->code, 200, 399)) { } 1 1 2
574 1 $tb->ok(0, $name);
575 1 $self->_smtp_diag;
576 } else {
577 1 $tb->ok(1, $name);
578 }
579 }
580  
581 40 ▶sub _is_between {
Subroutine _is_between: called CC=2 SCAR=6.9
582 40 my ($what, $start, $end) = @_;
583 40 ▶ return ($what >= $start and $what <= $end);
Condition100%3/3
$what >= $start && $what <= $end
!ll&&!rl&&r
91714
MC/DC100%2/2
$what >= $start && $what <= $end
$what >= $start $what <= $end
Truth table100%3/3
A && B
A= $what >= $startB= $what <= $end
ABresult
0X0
100
111
584 }
585  
586 27 ▶sub _smtp_diag {
Subroutine _smtp_diag: called CC=1 SCAR=0.0
587 27 my $self = shift;
588 27 my $tb = __PACKAGE__->builder();
589 27 $tb->diag(sprintf(" Got from server %s %s\n", $self->code, $self->message));
590 }
591  
592  
593 8 ▶sub mail_from {
Subroutine mail_from: called CC=1 SCAR=0.0
Pod documented
594 8 return shift->command("MAIL", "FROM:", @_)->response() == Net::Cmd::CMD_OK
595 }
596  
597  
598 8 ▶sub rcpt_to {
Subroutine rcpt_to: called CC=1 SCAR=0.0
Pod documented
599 8 return shift->command("RCPT", "TO:", @_)->response() == Net::Cmd::CMD_OK
600 }
601  
602  
603  
604 9 1;
605  
606 __END__
↑ Summary