Sidef/Types/Bool/Bool.pm

filter: Statementstmt 59.0% 36 / 61 Branchbran 0.0% 0 / 18 Conditioncond 25.0% 2 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 27.2% 6 / 22 Podpod 80.0% 8 / 10 totaltotal 42.2% 52 / 123 CC 11 SCAR 14.0
CC
11
Cov
44%
__ANON__
9.3
new
6.0
pick
6.0
CRAP 4.1
« Sidef/Types/Array/Vector.pm ↑ Summary Sidef/Types/Block/Fork.pm »
1 package Sidef::Types::Bool::Bool;
2  
3 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶$JSON::PP::true //= 1;
Condition50%1/2
$JSON::PP::true //= 1
l!l
01
MC/DC0%0/1
$JSON::PP::true //= 1
$JSON::PP::true
Truth table50%1/2
A
A= $JSON::PP::true
Aresult
11
00
7 1 ▶$JSON::PP::false //= 0;
Condition50%1/2
$JSON::PP::false //= 0
l!l
01
MC/DC0%0/1
$JSON::PP::false //= 0
$JSON::PP::false
Truth table50%1/2
A
A= $JSON::PP::false
Aresult
11
00
8  
9 use overload
10 0 ▶ q{bool} => sub { ${$_[0]} },
Subroutine BEGIN: called CC=1 SCAR=3.3
Subroutine __ANON__: not called CC=1 SCAR=6.9
11 0 ▶ q{0+} => sub { ${$_[0]} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
12 0 ▶ q{""} => sub { ${$_[0]} ? 'true' : 'false' };
Subroutine __ANON__: not called CC=2 SCAR=10.1
Branch: 1 branch
BranchTrueFalseTotal
${$_[0];} ? : 0 0 0
13  
14 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 TRUE => (bless \(my $t = 1), __PACKAGE__),
16 FALSE => (bless \(my $f = 0), __PACKAGE__),
17 1 };
18  
19 1 ▶use parent qw(Sidef::Object::Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
22 0 ▶ $_[1] ? (TRUE) : (FALSE);
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 0 0 0
23 }
24  
25 1 *call = \&new;
26  
27 0 ▶sub run {
Subroutine run: not called CC=1 SCAR=6.9
Pod documented
28 0 $_[0];
29 }
30  
31 0 ▶sub true { (TRUE) }
Subroutine true: not called CC=1 SCAR=6.9
Pod documented
32 0 ▶sub false { (FALSE) }
Subroutine false: not called CC=1 SCAR=6.9
Pod documented
33  
34 0 ▶sub pick {
Subroutine pick: not called CC=2 SCAR=17.9
Pod documented
35 0 ▶ CORE::rand(1) < 0.5 ? (TRUE) : (FALSE);
Branch: 1 branch
BranchTrueFalseTotal
CORE::rand 1 < 0.5 ? : 0 0 0
36 }
37  
38 1 *rand = \&pick;
39  
40 0 ▶sub get_value { ${$_[0]} ? $JSON::PP::true : $JSON::PP::false }
Subroutine get_value: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
${$_[0];} ? : 0 0 0
41 0 ▶sub to_bool { $_[0] }
Subroutine to_bool: not called CC=1 SCAR=6.9
Pod undocumented
42  
43 1 *to_b = \&to_bool;
44  
45 {
46 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 1 ▶ *{__PACKAGE__ . '::' . '|'} = sub {
Subroutine __ANON__: not called CC=2 SCAR=14.0
49 0 my ($self, $arg) = @_;
50 0 ▶ $$self ? $self : $arg;
Branch: 1 branch
BranchTrueFalseTotal
$$self ? : 0 0 0
51 1 };
52  
53 1 ▶ *{__PACKAGE__ . '::' . '&'} = sub {
Subroutine __ANON__: not called CC=2 SCAR=14.0
54 0 my ($self, $arg) = @_;
55 0 ▶ $$self ? $arg : $self;
Branch: 1 branch
BranchTrueFalseTotal
$$self ? : 0 0 0
56 1 };
57  
58 1 ▶ *{__PACKAGE__ . '::' . '^'} = sub {
Subroutine __ANON__: not called CC=3 SCAR=22.3
59 0 my ($self, $arg) = @_;
60 0 ▶ ($$self xor $arg) ? (TRUE) : (FALSE);
Branch: 1 branch
BranchTrueFalseTotal
$$self ^^ $arg ? : 0 0 0
Condition0%0/4
$$self xor $arg
l&&rl&&!r!l&&r!l&&!r
0000
MC/DC0%0/2
$$self xor $arg
$$self $arg
Truth table0%0/4
A xor B
A= $$selfB= $arg
ABresult
110
101
011
000
61 1 };
62 }
63  
64 0 ▶sub is_true { $_[0] }
Subroutine is_true: not called CC=1 SCAR=6.9
Pod documented
65  
66 0 ▶sub not {
Subroutine not: not called CC=2 SCAR=17.9
Pod documented
67 0 ▶ ${$_[0]} ? (FALSE) : (TRUE);
Branch: 1 branch
BranchTrueFalseTotal
${$_[0];} ? : 0 0 0
68 }
69  
70 1 *is_false = \&not;
71 1 *flip = \&not;
72 1 *toggle = \&not;
73 1 *neg = \&not;
74  
75 0 ▶sub dump {
Subroutine dump: not called CC=2 SCAR=17.9
Pod documented
76 0 my ($self) = @_;
77 0 ▶ Sidef::Types::String::String->new($$self ? 'true' : 'false');
Branch: 1 branch
BranchTrueFalseTotal
$$self ? : 0 0 0
78 }
79  
80 1 *to_s = \&dump;
81 1 *to_str = \&dump;
82  
83 1 1
« Sidef/Types/Array/Vector.pm ↑ Summary Sidef/Types/Block/Fork.pm »