| 1 | package Dallycot::AST::Defined; | ||||||||||||||||||||||||||||
| 2 | 29 | our $AUTHORITY = 'cpan:JSMITH'; | |||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Test if expression evaluates to a defined value | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 29 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 29 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 29 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 29 | ▶ | use parent 'Dallycot::AST'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 29 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | sub to_string { | ||||||||||||||||||||||||||||
| 15 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
to_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | return "?(" . ( $self->[0]->to_string ) . ")"; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub to_rdf { | ||||||||||||||||||||||||||||
| 21 | 0 | ▶ | my($self, $model) = @_; | ||||||||||||||||||||||||||
|
Subroutine
to_rdf: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | return $model -> apply( | |||||||||||||||||||||||||||
| 24 | $model -> meta_uri('loc:not-empty'), | ||||||||||||||||||||||||||||
| 25 | [ $self->[0] ], | ||||||||||||||||||||||||||||
| 26 | {} | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | # my $bnode = $model -> bnode; | ||||||||||||||||||||||||||||
| 29 | # $model -> add_type($bnode, 'loc:NotEmpty'); | ||||||||||||||||||||||||||||
| 30 | # $model -> add_expression($self -> [0]); | ||||||||||||||||||||||||||||
| 31 | # return $bnode; | ||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | sub execute { | ||||||||||||||||||||||||||||
| 35 | 291 | ▶ | my ( $self, $engine ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
execute: called CC=1 SCAR=0.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | return $engine->execute( $self->[0] )->then( | ||||||||||||||||||||||||||||
| 38 | sub { | ||||||||||||||||||||||||||||
| 39 | 288 | ▶ | my ($result) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||
| 40 | 288 | ▶ | if ( blessed $result ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 288 | ▶ | return ( $result->is_defined && !$result->is_empty ? $engine->TRUE : $engine->FALSE ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$result->is_defined and not $result->is_empty
MC/DC50%1/2
$result->is_defined and not $result->is_empty
$result->is_defined
not $result->is_empty
Truth table66%2/3
A and not(B)
A= $result->is_definedB= not $result->is_empty
| |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | else { | ||||||||||||||||||||||||||||
| 44 | 0 | return ( $engine->FALSE ); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 291 | ); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 29 | 1; | |||||||||||||||||||||||||||