blib/lib/Venus/Role/Comparable.pm

filter: Statementstmt 86.3% 76 / 88 Branchbran 75.6% 56 / 74 Conditioncond 71.4% 15 / 21 MC/DCmcdc 57.1% 8 / 14 Subroutinesub 100% 16 / 16 Podpod 91.6% 11 / 12 totaltotal 80.8% 182 / 225 CC 45 SCAR 21.7
CC
45
Cov
80%
lt
18.1
gt
14.9
eq
10.8
CRAP 8.8
« blib/lib/Venus/Role/Throwable.pm ↑ Summary blib/lib/Venus/Prototype.pm »
1 package Venus::Role::Comparable;
2  
3 119 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 119 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 119 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # IMPORTS
9  
10 119 ▶use Venus::Role 'with';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 119 require Scalar::Util;
13 119 require Venus::What;
14  
15 # METHODS
16  
17 440 ▶sub eq {
Subroutine eq: called CC=10 SCAR=23.8
Pod documented
18 440 my ($self, $data) = @_;
19  
20 440 $data = Venus::What->new(value => $data)->deduce;
21  
22 440 ▶ if (Scalar::Util::refaddr($self) eq Scalar::Util::refaddr($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($self) eq builtin::refaddr($data)) 2 438 440
23 2 return true;
24 }
25 438 ▶ if (Scalar::Util::blessed($data) && !$data->isa('Venus::Kind')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($data) and not $data->isa("Venus::Kind")) 0 438 438
Condition33%1/3
builtin::blessed($data) and not $data->isa("Venus::Kind")
!ll&&!rl&&r
04380
MC/DC0%0/2
builtin::blessed($data) and not $data->isa("Venus::Kind")
builtin::blessed($data) not $data->isa("Venus::Kind")
Truth table33%1/3
A and not(B)
A= builtin::blessed($data)B= not $data->isa("Venus::Kind")
ABresult
0X0
100
111
26 0 return false;
27 }
28 438 ▶ if ($self->comparer('eq') eq 'numified') {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->comparer('eq') eq 'numified') { } 186 252 438
elsif ($self->comparer('eq') eq 'stringified') { } 80 172 252
elsif (my $method = $self->comparer('eq')) { } 172 0 172
29 186 ▶ return $self->numified == $data->numified ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$self->numified == $data->numified ? : 106 80 186
30 }
31 elsif ($self->comparer('eq') eq 'stringified') {
32 80 ▶ return $self->stringified eq $data->stringified ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$self->stringified eq $data->stringified ? : 19 61 80
33 }
34 elsif (my $method = $self->comparer('eq')) {
35 172 ▶ return $self->$method eq $data->$method ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$self->$method eq $data->$method ? : 25 147 172
36 }
37 else {
38 0 return false;
39 }
40 }
41  
42 187 ▶sub ge {
Subroutine ge: called CC=3 SCAR=11.0
Pod documented
43 187 my ($self, $data) = @_;
44  
45 187 ▶ if ($self->gt($data) || $self->eq($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->gt($data) or $self->eq($data)) { } 102 85 187
Condition100%3/3
$self->gt($data) or $self->eq($data)
l!l&&r!l&&!r
544885
MC/DC100%2/2
$self->gt($data) or $self->eq($data)
$self->gt($data) $self->eq($data)
Truth table100%3/3
A or B
A= $self->gt($data)B= $self->eq($data)
ABresult
1X1
011
000
46 102 return true;
47 }
48 else {
49 85 return false;
50 }
51 }
52  
53 94 ▶sub gele {
Subroutine gele: called CC=3 SCAR=11.0
Pod documented
54 94 my ($self, $ge, $le) = @_;
55  
56 94 ▶ if ($self->ge($ge) && $self->le($le)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->ge($ge) and $self->le($le)) { } 21 73 94
Condition100%3/3
$self->ge($ge) and $self->le($le)
!ll&&!rl&&r
423121
MC/DC100%2/2
$self->ge($ge) and $self->le($le)
$self->ge($ge) $self->le($le)
Truth table100%3/3
A and B
A= $self->ge($ge)B= $self->le($le)
ABresult
0X0
100
111
57 21 return true;
58 }
59 else {
60 73 return false;
61 }
62 }
63  
64 401 ▶sub gt {
Subroutine gt: called CC=10 SCAR=27.0
Pod documented
65 401 my ($self, $data) = @_;
66  
67 401 $data = Venus::What->new(value => $data)->deduce;
68  
69 401 ▶ if (Scalar::Util::refaddr($self) eq Scalar::Util::refaddr($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($self) eq builtin::refaddr($data)) 1 400 401
70 1 return false;
71 }
72 400 ▶ if (Scalar::Util::blessed($data) && !$data->isa('Venus::Kind')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($data) and not $data->isa("Venus::Kind")) 0 400 400
Condition33%1/3
builtin::blessed($data) and not $data->isa("Venus::Kind")
!ll&&!rl&&r
04000
MC/DC0%0/2
builtin::blessed($data) and not $data->isa("Venus::Kind")
builtin::blessed($data) not $data->isa("Venus::Kind")
Truth table33%1/3
A and not(B)
A= builtin::blessed($data)B= not $data->isa("Venus::Kind")
ABresult
0X0
100
111
73 0 return false;
74 }
75 400 ▶ if ($self->comparer('gt') eq 'numified') {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->comparer('gt') eq 'numified') { } 328 72 400
elsif ($self->comparer('gt') eq 'stringified') { } 72 0 72
elsif (my $method = $self->comparer('gt')) { } 0 0 0
76 328 ▶ return $self->numified > $data->numified ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$self->numified > $data->numified ? : 99 229 328
77 }
78 elsif ($self->comparer('gt') eq 'stringified') {
79 72 ▶ return $self->stringified gt $data->stringified ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$self->stringified gt $data->stringified ? : 24 48 72
80 }
81 elsif (my $method = $self->comparer('gt')) {
82 0 ▶ return $self->$method gt $data->$method ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$self->$method gt $data->$method ? : 0 0 0
83 }
84 else {
85 0 return false;
86 }
87 }
88  
89 94 ▶sub gtlt {
Subroutine gtlt: called CC=3 SCAR=11.0
Pod documented
90 94 my ($self, $gt, $lt) = @_;
91  
92 94 ▶ if ($self->gt($gt) && $self->lt($lt)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->gt($gt) and $self->lt($lt)) { } 2 92 94
Condition100%3/3
$self->gt($gt) and $self->lt($lt)
!ll&&!rl&&r
66262
MC/DC100%2/2
$self->gt($gt) and $self->lt($lt)
$self->gt($gt) $self->lt($lt)
Truth table100%3/3
A and B
A= $self->gt($gt)B= $self->lt($lt)
ABresult
0X0
100
111
93 2 return true;
94 }
95 else {
96 92 return false;
97 }
98 }
99  
100 3 ▶sub is {
Subroutine is: called CC=3 SCAR=11.2
Pod documented
101 3 my ($self, $data) = @_;
102  
103 3 ▶ if (!ref $data) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $data) 0 3 3
104 0 return false;
105 }
106 3 ▶ if (Scalar::Util::refaddr($self) eq Scalar::Util::refaddr($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($self) eq builtin::refaddr($data)) { } 1 2 3
107 1 return true;
108 }
109 else {
110 2 return false;
111 }
112 }
113  
114 268 ▶sub lt {
Subroutine lt: called CC=10 SCAR=29.0
Pod documented
115 268 my ($self, $data) = @_;
116  
117 268 $data = Venus::What->new(value => $data)->deduce;
118  
119 268 ▶ if (Scalar::Util::refaddr($self) eq Scalar::Util::refaddr($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($self) eq builtin::refaddr($data)) 0 268 268
120 0 return false;
121 }
122 268 ▶ if (Scalar::Util::blessed($data) && !$data->isa('Venus::Kind')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($data) and not $data->isa("Venus::Kind")) 0 268 268
Condition33%1/3
builtin::blessed($data) and not $data->isa("Venus::Kind")
!ll&&!rl&&r
02680
MC/DC0%0/2
builtin::blessed($data) and not $data->isa("Venus::Kind")
builtin::blessed($data) not $data->isa("Venus::Kind")
Truth table33%1/3
A and not(B)
A= builtin::blessed($data)B= not $data->isa("Venus::Kind")
ABresult
0X0
100
111
123 0 return false;
124 }
125 268 ▶ if ($self->comparer('lt') eq 'numified') {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->comparer('lt') eq 'numified') { } 217 51 268
elsif ($self->comparer('lt') eq 'stringified') { } 51 0 51
elsif (my $method = $self->comparer('lt')) { } 0 0 0
126 217 ▶ return $self->numified < $data->numified ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$self->numified < $data->numified ? : 60 157 217
127 }
128 elsif ($self->comparer('lt') eq 'stringified') {
129 51 ▶ return $self->stringified lt $data->stringified ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$self->stringified lt $data->stringified ? : 18 33 51
130 }
131 elsif (my $method = $self->comparer('lt')) {
132 0 ▶ return $self->$method lt $data->$method ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$self->$method lt $data->$method ? : 0 0 0
133 }
134 else {
135 0 return false;
136 }
137 }
138  
139 146 ▶sub le {
Subroutine le: called CC=3 SCAR=11.0
Pod documented
140 146 my ($self, $data) = @_;
141  
142 146 ▶ if ($self->lt($data) || $self->eq($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->lt($data) or $self->eq($data)) { } 82 64 146
Condition100%3/3
$self->lt($data) or $self->eq($data)
l!l&&r!l&&!r
394364
MC/DC100%2/2
$self->lt($data) or $self->eq($data)
$self->lt($data) $self->eq($data)
Truth table100%3/3
A or B
A= $self->lt($data)B= $self->eq($data)
ABresult
1X1
011
000
143 82 return true;
144 }
145 else {
146 64 return false;
147 }
148 }
149  
150 94 ▶sub ne {
Subroutine ne: called CC=2 SCAR=6.9
Pod documented
151 94 my ($self, $data) = @_;
152  
153 94 ▶ return $self->eq($data) ? false : true;
Branch: 1 branch
BranchTrueFalseTotal
$self->eq($data) ? : 24 70 94
154 }
155  
156 4 ▶sub st {
Subroutine st: called CC=4 SCAR=14.0
Pod documented
157 4 my ($self, $data) = @_;
158  
159 4 ▶ if (!Scalar::Util::blessed($data)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($data)) 0 4 4
160 0 return false;
161 }
162 4 ▶ if (Scalar::Util::refaddr($self) eq Scalar::Util::refaddr($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($self) eq builtin::refaddr($data)) 1 3 4
163 1 return true;
164 }
165 3 ▶ if ($data->isa($self->class)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->isa($self->class)) { } 1 2 3
166 1 return true;
167 }
168 else {
169 2 return false;
170 }
171 }
172  
173 95 ▶sub tv {
Subroutine tv: called CC=4 SCAR=14.0
Pod documented
174 95 my ($self, $data) = @_;
175  
176 95 ▶ if (!Scalar::Util::blessed($data)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($data)) 0 95 95
177 0 return false;
178 }
179 95 ▶ if (Scalar::Util::refaddr($self) eq Scalar::Util::refaddr($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($self) eq builtin::refaddr($data)) 1 94 95
180 1 return true;
181 }
182 94 ▶ if ($data->isa($self->class)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->isa($self->class)) { } 12 82 94
183 12 return $self->eq($data);
184 }
185 else {
186 82 return false;
187 }
188 }
189  
190 # EXPORTS
191  
192 120 ▶sub EXPORT {
Subroutine EXPORT: called CC=1 SCAR=0.0
Pod undocumented
193 120 ['eq', 'ge', 'gele', 'gt', 'gtlt', 'is', 'lt', 'le', 'ne', 'st', 'tv']
194 }
195  
196 119 1;
197  
198  
199  
200 =head1 NAME
201  
202 Venus::Role::Comparable - Comparable Role
203  
204 =cut
205  
206 =head1 ABSTRACT
207  
208 Comparable Role for Perl 5
209  
210 =cut
211  
212 =head1 SYNOPSIS
213  
214 package Example;
215  
216 use Venus::Class;
217  
218 base 'Venus::Kind';
219  
220 with 'Venus::Role::Comparable';
221  
222 sub numified {
223 return 2;
224 }
225  
226 package main;
227  
228 my $example = Example->new;
229  
230 # my $result = $example->eq(2);
231  
232 =cut
233  
234 =head1 DESCRIPTION
235  
236 This package modifies the consuming package and provides methods for performing
237 numerical and stringwise comparision operations or any object or raw data type.
238  
239 =cut
240  
241 =head1 METHODS
242  
243 This package provides the following methods:
244  
245 =cut
246  
247 =head2 eq
248  
249 eq(any $arg) (boolean)
250  
251 The eq method performs an I<"equals"> operation using the invocant and the
252 argument provided. The operation will be performed as either a numerical or
253 stringwise operation based upon the preference (i.e. the return value of the
254 L</comparer> method) of the invocant.
255  
256 I<Since C<0.08>>
257  
258 =over 4
259  
260 =item eq example 1
261  
262 package main;
263  
264 my $example = Example->new;
265  
266 my $result = $example->eq($example);
267  
268 # 1
269  
270 =back
271  
272 =over 4
273  
274 =item eq example 2
275  
276 package main;
277  
278 my $example = Example->new;
279  
280 my $result = $example->eq([1,2]);
281  
282 # 0
283  
284 =back
285  
286 =over 4
287  
288 =item eq example 3
289  
290 package main;
291  
292 my $example = Example->new;
293  
294 my $result = $example->eq({1..4});
295  
296 # 0
297  
298 =back
299  
300 =cut
301  
302 =head2 ge
303  
304 ge(any $arg) (boolean)
305  
306 The ge method performs a I<"greater-than-or-equal-to"> operation using the
307 invocant and argument provided. The operation will be performed as either a
308 numerical or stringwise operation based upon the preference (i.e. the return
309 value of the L</comparer> method) of the invocant.
310  
311 I<Since C<0.08>>
312  
313 =over 4
314  
315 =item ge example 1
316  
317 package main;
318  
319 my $example = Example->new;
320  
321 my $result = $example->ge(3);
322  
323 # 0
324  
325 =back
326  
327 =over 4
328  
329 =item ge example 2
330  
331 package main;
332  
333 my $example = Example->new;
334  
335 my $result = $example->ge($example);
336  
337 # 1
338  
339 =back
340  
341 =over 4
342  
343 =item ge example 3
344  
345 package main;
346  
347 my $example = Example->new;
348  
349 my $result = $example->ge([1,2,3]);
350  
351 # 0
352  
353 =back
354  
355 =cut
356  
357 =head2 gele
358  
359 gele(any $arg1, any $arg2) (boolean)
360  
361 The gele method performs a I<"greater-than-or-equal-to"> operation on the 1st
362 argument, and I<"lesser-than-or-equal-to"> operation on the 2nd argument. The
363 operation will be performed as either a numerical or stringwise operation based
364 upon the preference (i.e. the return value of the L</comparer> method) of the
365 invocant.
366  
367 I<Since C<0.08>>
368  
369 =over 4
370  
371 =item gele example 1
372  
373 package main;
374  
375 my $example = Example->new;
376  
377 my $result = $example->gele(1, 3);
378  
379 # 1
380  
381 =back
382  
383 =over 4
384  
385 =item gele example 2
386  
387 package main;
388  
389 my $example = Example->new;
390  
391 my $result = $example->gele(2, []);
392  
393 # 0
394  
395 =back
396  
397 =over 4
398  
399 =item gele example 3
400  
401 package main;
402  
403 my $example = Example->new;
404  
405 my $result = $example->gele(0, '3');
406  
407 # 1
408  
409 =back
410  
411 =cut
412  
413 =head2 gt
414  
415 gt(any $arg) (boolean)
416  
417 The gt method performs a I<"greater-than"> operation using the invocant and
418 argument provided. The operation will be performed as either a numerical or
419 stringwise operation based upon the preference (i.e. the return value of the
420 L</comparer> method) of the invocant.
421  
422 I<Since C<0.08>>
423  
424 =over 4
425  
426 =item gt example 1
427  
428 package main;
429  
430 my $example = Example->new;
431  
432 my $result = $example->gt({1..2});
433  
434 # 0
435  
436 =back
437  
438 =over 4
439  
440 =item gt example 2
441  
442 package main;
443  
444 my $example = Example->new;
445  
446 my $result = $example->gt(1.9998);
447  
448 # 1
449  
450 =back
451  
452 =over 4
453  
454 =item gt example 3
455  
456 package main;
457  
458 my $example = Example->new;
459  
460 my $result = $example->gt(\1_000_000);
461  
462 # 0
463  
464 =back
465  
466 =cut
467  
468 =head2 gtlt
469  
470 gtlt(any $arg1, any $arg2) (boolean)
471  
472 The gtlt method performs a I<"greater-than"> operation on the 1st argument, and
473 I<"lesser-than"> operation on the 2nd argument. The operation will be performed
474 as either a numerical or stringwise operation based upon the preference (i.e.
475 the return value of the L</comparer> method) of the invocant.
476  
477 I<Since C<0.08>>
478  
479 =over 4
480  
481 =item gtlt example 1
482  
483 package main;
484  
485 my $example = Example->new;
486  
487 my $result = $example->gtlt('1', 3);
488  
489 # 1
490  
491 =back
492  
493 =over 4
494  
495 =item gtlt example 2
496  
497 package main;
498  
499 my $example = Example->new;
500  
501 my $result = $example->gtlt({1..2}, {1..4});
502  
503 # 0
504  
505 =back
506  
507 =over 4
508  
509 =item gtlt example 3
510  
511 package main;
512  
513 my $example = Example->new;
514  
515 my $result = $example->gtlt('.', ['.']);
516  
517 # 1
518  
519 =back
520  
521 =cut
522  
523 =head2 is
524  
525 is(any $arg) (boolean)
526  
527 The is method performs an I<"is-exactly"> operation using the invocant and the
528 argument provided. If the argument provided is blessed and exactly the same as
529 the invocant (i.e. shares the same address space) the operation will return
530 truthy.
531  
532 I<Since C<1.80>>
533  
534 =over 4
535  
536 =item is example 1
537  
538 package main;
539  
540 my $example = Example->new;
541  
542 my $result = $example->is($example);
543  
544 # 1
545  
546 =back
547  
548 =over 4
549  
550 =item is example 2
551  
552 package main;
553  
554 my $example = Example->new;
555  
556 my $result = $example->is([1,2]);
557  
558 # 0
559  
560 =back
561  
562 =over 4
563  
564 =item is example 3
565  
566 package main;
567  
568 my $example = Example->new;
569  
570 my $result = $example->is(Example->new);
571  
572 # 0
573  
574 =back
575  
576 =cut
577  
578 =head2 le
579  
580 le(any $arg) (boolean)
581  
582 The le method performs a I<"lesser-than-or-equal-to"> operation using the
583 invocant and argument provided. The operation will be performed as either a
584 numerical or stringwise operation based upon the preference (i.e. the return
585 value of the L</comparer> method) of the invocant.
586  
587 I<Since C<0.08>>
588  
589 =over 4
590  
591 =item le example 1
592  
593 package main;
594  
595 my $example = Example->new;
596  
597 my $result = $example->le('9');
598  
599 # 1
600  
601 =back
602  
603 =over 4
604  
605 =item le example 2
606  
607 package main;
608  
609 my $example = Example->new;
610  
611 my $result = $example->le([1..2]);
612  
613 # 1
614  
615 =back
616  
617 =over 4
618  
619 =item le example 3
620  
621 package main;
622  
623 my $example = Example->new;
624  
625 my $result = $example->le(\1);
626  
627 # 0
628  
629 =back
630  
631 =cut
632  
633 =head2 lt
634  
635 lt(any $arg) (boolean)
636  
637 The lt method performs a I<"lesser-than"> operation using the invocant and
638 argument provided. The operation will be performed as either a numerical or
639 stringwise operation based upon the preference (i.e. the return value of the
640 L</comparer> method) of the invocant.
641  
642 I<Since C<0.08>>
643  
644 =over 4
645  
646 =item lt example 1
647  
648 package main;
649  
650 my $example = Example->new;
651  
652 my $result = $example->lt(qr/.*/);
653  
654 # 1
655  
656 =back
657  
658 =over 4
659  
660 =item lt example 2
661  
662 package main;
663  
664 my $example = Example->new;
665  
666 my $result = $example->lt('.*');
667  
668 # 0
669  
670 =back
671  
672 =over 4
673  
674 =item lt example 3
675  
676 package main;
677  
678 my $example = Example->new;
679  
680 my $result = $example->lt('5');
681  
682 # 1
683  
684 =back
685  
686 =cut
687  
688 =head2 ne
689  
690 ne(any $arg) (boolean)
691  
692 The ne method performs a I<"not-equal-to"> operation using the invocant and
693 argument provided. The operation will be performed as either a numerical or
694 stringwise operation based upon the preference (i.e. the return value of the
695 L</comparer> method) of the invocant.
696  
697 I<Since C<0.08>>
698  
699 =over 4
700  
701 =item ne example 1
702  
703 package main;
704  
705 my $example = Example->new;
706  
707 my $result = $example->ne([1,2]);
708  
709 # 1
710  
711 =back
712  
713 =over 4
714  
715 =item ne example 2
716  
717 package main;
718  
719 my $example = Example->new;
720  
721 my $result = $example->ne([2]);
722  
723 # 1
724  
725 =back
726  
727 =over 4
728  
729 =item ne example 3
730  
731 package main;
732  
733 my $example = Example->new;
734  
735 my $result = $example->ne(qr/2/);
736  
737 # 1
738  
739 =back
740  
741 =cut
742  
743 =head2 st
744  
745 st(object $arg) (boolean)
746  
747 The st method performs a I<"same-type"> operation using the invocant and
748 argument provided. If the argument provided is an instance of the invocant, or
749 a subclass, the operation will return truthy.
750  
751 I<Since C<1.80>>
752  
753 =over 4
754  
755 =item st example 1
756  
757 package main;
758  
759 my $example = Example->new;
760  
761 my $result = $example->st($example);
762  
763 # 1
764  
765 =back
766  
767 =over 4
768  
769 =item st example 2
770  
771 package main;
772  
773 use Venus::Number;
774  
775 my $example = Example->new;
776  
777 my $result = $example->st(Venus::Number->new(2));
778  
779 # 0
780  
781 =back
782  
783 =over 4
784  
785 =item st example 3
786  
787 package main;
788  
789 use Venus::String;
790  
791 my $example = Example->new;
792  
793 my $result = $example->st(Venus::String->new('2'));
794  
795 # 0
796  
797 =back
798  
799 =over 4
800  
801 =item st example 4
802  
803 package Example2;
804  
805 use base 'Example';
806  
807 package main;
808  
809 use Venus::String;
810  
811 my $example = Example2->new;
812  
813 my $result = $example->st(Example2->new);
814  
815 # 1
816  
817 =back
818  
819 =cut
820  
821 =head2 tv
822  
823 tv(any $arg) (boolean)
824  
825 The tv method performs a I<"type-and-value-equal-to"> operation using the
826 invocant and argument provided. The operation will be performed as either a
827 numerical or stringwise operation based upon the preference (i.e. the return
828 value of the L</comparer> method) of the invocant.
829  
830 I<Since C<0.08>>
831  
832 =over 4
833  
834 =item tv example 1
835  
836 package main;
837  
838 my $example = Example->new;
839  
840 my $result = $example->tv($example);
841  
842 # 1
843  
844 =back
845  
846 =over 4
847  
848 =item tv example 2
849  
850 package main;
851  
852 use Venus::Number;
853  
854 my $example = Example->new;
855  
856 my $result = $example->tv(Venus::Number->new(2));
857  
858 # 0
859  
860 =back
861  
862 =over 4
863  
864 =item tv example 3
865  
866 package main;
867  
868 use Venus::String;
869  
870 my $example = Example->new;
871  
872 my $result = $example->tv(Venus::String->new('2'));
873  
874 # 0
875  
876 =back
877  
878 =over 4
879  
880 =item tv example 4
881  
882 package main;
883  
884 use Venus::String;
885  
886 my $example = Example->new;
887  
888 my $result = $example->tv(Example->new);
889  
890 # 1
891  
892 =back
893  
894 =cut
895  
896 =head1 AUTHORS
897  
898 Awncorp, C<awncorp@cpan.org>
899  
900 =cut
901  
902 =head1 LICENSE
903  
904 Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>.
905  
906 This program is free software, you can redistribute it and/or modify it under
907 the terms of the Apache license version 2.0.
908  
909 =cut
« blib/lib/Venus/Role/Throwable.pm ↑ Summary blib/lib/Venus/Prototype.pm »