blib/lib/Logic/Relational/Goal/Unify.pm

filter: Statementstmt 92.3% 24 / 26 Branchbran 100% 2 / 2 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 77.7% 7 / 9 Podpod 50.0% 3 / 6 totaltotal 71.7% 38 / 53 CC 4 SCAR 6.5
CC
4
Cov
82%
expand
3.0
is_ground
2.5
left
2.0
CRAP 1.9
« lib/Logic/Relational/TraceEvent.pm ↑ Summary lib/Logic/Relational/ChangeEvent.pm »
1 package Logic::Relational::Goal::Unify;
2  
3 31 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 31 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 31 ▶use parent 'Logic::Relational::Goal';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Logic::Relational::Goal::Unify - Goal that unifies two terms.
10  
11 =cut
12  
13 83 ▶sub new ( $class, $left, $right ) {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
14 83 return bless { left => $left, right => $right }, $class;
15 }
16  
17 0 ▶sub left ($self) { return $self->{left}; }
Subroutine left: not called CC=1 SCAR=6.9
Pod undocumented
18 0 ▶sub right ($self) { return $self->{right}; }
Subroutine right: not called CC=1 SCAR=6.9
Pod undocumented
19  
20 45 ▶sub expand ( $self, %args ) {
Subroutine expand: called CC=3 SCAR=11.1
Pod documented
21 45 my $subst = $args{substitution};
22 45 my $remaining = $args{remaining};
23 45 my $state = $args{state};
24  
25 45 require Logic::Relational::Unifier;
26 my $new_subst =
27 Logic::Relational::Unifier::unify( $self->{left}, $self->{right},
28 45 $subst );
29  
30 45 ▶ if ($new_subst) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_subst) 32 13 45
31 32 my $succ = $state->derive(
32 substitution => $new_subst,
33 goals => $remaining,
34 );
35 32 ▶ return $succ // ();
Condition33%1/3
$succ // ()
l!l&&r!l&&!r
3200
MC/DC0%0/2
$succ // ()
$succ ()
Truth table33%1/3
A // B
A= $succB= ()
ABresult
1X1
011
000
36 }
37 13 return ();
38 }
39  
40 32 ▶sub freshen ( $self, $var_map ) {
Subroutine freshen: called CC=1 SCAR=0.0
Pod documented
41 32 require Logic::Relational::DSL;
42 my $fresh_l =
43 32 Logic::Relational::DSL::freshen_val( $self->{left}, $var_map );
44 my $fresh_r =
45 32 Logic::Relational::DSL::freshen_val( $self->{right}, $var_map );
46 32 return ref($self)->new( $fresh_l, $fresh_r );
47 }
48  
49 17 ▶sub is_ground ( $self, $subst ) {
Subroutine is_ground: called CC=2 SCAR=9.2
Pod documented
50 return $self->term_is_ground( $self->{left}, $subst )
51 17 ▶ && $self->term_is_ground( $self->{right}, $subst );
Condition33%1/3
$self->term_is_ground($self->{'left'}, $subst) && $self->term_is_ground($self->{'right'}, $subst)
!ll&&!rl&&r
0017
MC/DC0%0/2
$self->term_is_ground($self->{'left'}, $subst) && $self->term_is_ground($self->{'right'}, $subst)
$self->term_is_ground($self->{'left'}, $subst) $self->term_is_ground($self->{'right'}, $subst)
Truth table33%1/3
A && B
A= $self->term_is_ground($self->{'left'}, $subst)B= $self->term_is_ground($self->{'right'}, $subst)
ABresult
0X0
100
111
52 }
53  
54 31 1;
« lib/Logic/Relational/TraceEvent.pm ↑ Summary lib/Logic/Relational/ChangeEvent.pm »