| 1 | package Seis::Bool; | ||||||||||||||
| 2 | 25 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 25 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 25 | ▶ | use 5.018000; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | package # Hide from PAUSE | ||||||||||||||
| 7 | Bool; | ||||||||||||||
| 8 | |||||||||||||||
| 9 | 25 | my ($true, $false); | |||||||||||||
| 10 | |||||||||||||||
| 11 | use overload | ||||||||||||||
| 12 | 0 | ▶ | '""' => sub { ${$_[0]} ? 'True' : 'False' }, | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=3.8
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||
| 13 | 0 | ▶ | '!' => sub { ${$_[0]} ? $false : $true }, | ||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||
| 14 | 0 | ▶ | 'bool' => sub { !! ${$_[0]} }, | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 15 | 25 | fallback => 1; | |||||||||||||
| 16 | |||||||||||||||
| 17 | 25 | my ($true_val, $false_val, $bool_vals); | |||||||||||||
| 18 | |||||||||||||||
| 19 | 25 | ▶ | BEGIN { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | 25 | my $t = 1; | |||||||||||||
| 21 | 25 | my $f = 0; | |||||||||||||
| 22 | 25 | $true = do {bless \$t, 'Bool'}; | |||||||||||||
| 23 | 25 | $false = do {bless \$f, 'Bool'}; | |||||||||||||
| 24 | |||||||||||||||
| 25 | 25 | $true_val = overload::StrVal($true); | |||||||||||||
| 26 | 25 | $false_val = overload::StrVal($false); | |||||||||||||
| 27 | 25 | $bool_vals = {$true_val => 1, $false_val => 1}; | |||||||||||||
| 28 | } | ||||||||||||||
| 29 | 0 | ▶ | sub True() { $true } | ||||||||||||
|
Subroutine
True: not called CC=1 SCAR=6.9
| |||||||||||||||
| 30 | 0 | ▶ | sub False() { $false } | ||||||||||||
|
Subroutine
False: not called CC=1 SCAR=6.9
| |||||||||||||||
| 31 | |||||||||||||||
| 32 | 0 | ▶ | sub true() { $true } | ||||||||||||
|
Subroutine
true: not called CC=1 SCAR=6.9
| |||||||||||||||
| 33 | 0 | ▶ | sub false() { $false } | ||||||||||||
|
Subroutine
false: not called CC=1 SCAR=6.9
| |||||||||||||||
| 34 | 0 | ▶ | sub boolean($) { | ||||||||||||
|
Subroutine
boolean: not called CC=5 SCAR=34.0
| |||||||||||||||
| 35 | 0 | ▶ | die "Not enough arguments for Bool::boolean" if scalar(@_) == 0; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 36 | 0 | ▶ | die "Too many arguments for Bool::boolean" if scalar(@_) > 1; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 37 | 0 | ▶ | return not(defined $_[0]) ? false : | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 38 | "$_[0]" ? $true : $false; | ||||||||||||||
| 39 | } | ||||||||||||||
| 40 | 0 | ▶ | sub _isBoolean($) { | ||||||||||||
|
Subroutine
_isBoolean: not called CC=3 SCAR=24.8
| |||||||||||||||
| 41 | not(defined $_[0]) ? false : | ||||||||||||||
| 42 | 0 | ▶ | (exists $bool_vals->{overload::StrVal($_[0])}) ? true : false; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 43 | } | ||||||||||||||
| 44 | |||||||||||||||
| 45 | 0 | ▶ | sub TO_JSON { ${$_[0]} ? \1 : \0 } | ||||||||||||
|
Subroutine
TO_JSON: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||
| 46 | |||||||||||||||
| 47 | 0 | ▶ | sub isa { | ||||||||||||
|
Subroutine
isa: not called CC=2 SCAR=17.9
| |||||||||||||||
| 48 | 0 | my ($self, $stuff) = @_; | |||||||||||||
| 49 | 0 | ▶ | return UNIVERSAL::isa($self, $stuff->{name}) if UNIVERSAL::isa($stuff, 'Seis::Class'); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 50 | 0 | return UNIVERSAL::isa($self, $stuff); | |||||||||||||
| 51 | } | ||||||||||||||
| 52 | |||||||||||||||
| 53 | 25 | 1; | |||||||||||||