File Coverage

t/logic.t
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1 1     1   1032 use Test::Most 'die';
  0            
  0            
2              
3             use lib 'lib';
4             use 5.12.0;
5             use Unknown::Values;
6              
7             # Kleene's three-value logic
8              
9             use constant true => 1;
10             use constant false => 0;
11             my $value = unknown;
12              
13             sub is_false($) {
14             my $value = shift;
15             return ( !$value && !is_unknown($value) );
16             }
17              
18             # sanity
19             ok is_unknown unknown, 'unknown should be unknown';
20             ok !is_unknown undef, 'undef is not unknown';
21             ok !is_unknown false, 'a defined false value is not unknown';
22             ok !is_unknown true, 'a defined true value is not unknown';
23              
24             # negation
25             ok is_unknown !unknown, 'not unknown should evaluate to unknown';
26              
27             # logical or
28             ok unknown || true, 'unknown || true should be true';
29             ok is_unknown unknown || false, 'unknown || false should be unknown';
30             ok is_unknown unknown || unknown, 'unknown || unknown should be unknown';
31              
32             ok + ( unknown or true ), 'unknown or true should be true';
33             ok + ( is_unknown unknown or false ), 'unknown or false should be unknown';
34             ok + ( is_unknown unknown or unknown ), 'unknown or unknown should be unknown';
35              
36             # logical and
37             ok is_unknown unknown && true, 'unknown && true should be unknown';
38             ok is_false( unknown && false ), 'unknown && false should be false';
39             ok is_unknown unknown && unknown, 'unknown && unknown should be unknown';
40              
41             ok + ( is_unknown unknown and true ), 'unknown and true should be unknown';
42             ok + ( is_false( unknown and false ) ), 'unknown and false should be false';
43             ok + ( is_unknown unknown and unknown ),
44             'unknown and unknown should be unknown';
45              
46             done_testing;