line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
849
|
use Test::Most 'die'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use lib 'lib'; |
4
|
|
|
|
|
|
|
use Unknown::Values; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $value = unknown; |
7
|
|
|
|
|
|
|
throws_ok { $value + 1 } |
8
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
9
|
|
|
|
|
|
|
'Addition cannot be performed with unknown values'; |
10
|
|
|
|
|
|
|
throws_ok { 1 + $value } |
11
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
12
|
|
|
|
|
|
|
'Addition cannot be performed with unknown values'; |
13
|
|
|
|
|
|
|
throws_ok { $value - 1 } |
14
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
15
|
|
|
|
|
|
|
'Subtraction cannot be performed with unknown values'; |
16
|
|
|
|
|
|
|
throws_ok { $value * 1 } |
17
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
18
|
|
|
|
|
|
|
'Multiplication cannot be performed with unknown values'; |
19
|
|
|
|
|
|
|
throws_ok { $value / 1 } |
20
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
21
|
|
|
|
|
|
|
'Division cannot be performed with unknown values'; |
22
|
|
|
|
|
|
|
throws_ok { $value**1 } |
23
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
24
|
|
|
|
|
|
|
'Exponentiation cannot be performed with unknown values'; |
25
|
|
|
|
|
|
|
throws_ok { $value++ } |
26
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
27
|
|
|
|
|
|
|
'Post-increment cannot be performed with unknown values'; |
28
|
|
|
|
|
|
|
throws_ok { ++$value } |
29
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
30
|
|
|
|
|
|
|
'Pre-increment cannot be performed with unknown values'; |
31
|
|
|
|
|
|
|
throws_ok { $value-- } |
32
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
33
|
|
|
|
|
|
|
'Post-decrement cannot be performed with unknown values'; |
34
|
|
|
|
|
|
|
throws_ok { --$value } |
35
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
36
|
|
|
|
|
|
|
'Pre-decrement cannot be performed with unknown values'; |
37
|
|
|
|
|
|
|
throws_ok { $value += 1 } |
38
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
39
|
|
|
|
|
|
|
'+= cannot be performed with unknown values'; |
40
|
|
|
|
|
|
|
throws_ok { sin($value) } |
41
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
42
|
|
|
|
|
|
|
'sin() cannot be performed with unknown values'; |
43
|
|
|
|
|
|
|
throws_ok { abs($value) } |
44
|
|
|
|
|
|
|
qr/Math cannot be performed on unknown values/, |
45
|
|
|
|
|
|
|
'abs() cannot be performed with unknown values'; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
lives_ok { $value = 7 } |
48
|
|
|
|
|
|
|
'Assigning a value to an unknown object should succeed'; |
49
|
|
|
|
|
|
|
is $value, 7, '... and it should be a normal value'; |
50
|
|
|
|
|
|
|
lives_ok { $value++ } |
51
|
|
|
|
|
|
|
'... allowing you to manipulate it like normal'; |
52
|
|
|
|
|
|
|
is $value, 8, '... and it should be no longer unknown'; |
53
|
|
|
|
|
|
|
ok !is_unknown $value, '... or evaluate as unknown'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
lives_ok { $value = unknown } |
56
|
|
|
|
|
|
|
'We should be able to reset a value to unknown'; |
57
|
|
|
|
|
|
|
ok is_unknown $value, '... and it should compare as unknown'; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
ok is_unknown !unknown, 'not unknown should evaluate to unknown'; |
60
|
|
|
|
|
|
|
use 5.12.0; |
61
|
|
|
|
|
|
|
$value = unknown; |
62
|
|
|
|
|
|
|
my $should_be_unknown = $value ||= 2; |
63
|
|
|
|
|
|
|
ok is_unknown $should_be_unknown, |
64
|
|
|
|
|
|
|
'unknown ||= anything must return unknown because we cannot know if unknown was false'; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$value = unknown; |
67
|
|
|
|
|
|
|
my $should_be_unknown2 = $value //= 2; |
68
|
|
|
|
|
|
|
ok is_unknown $should_be_unknown2, |
69
|
|
|
|
|
|
|
'unknown //= anything must return unknown because we cannot know if unknown was defined'; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
done_testing; |