line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Run::Obj::IntOrUnknown; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Test::Run::Obj::IntOrUnknown - an object representing a int or unknown. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Inherits from Test::Run::Base::Struct. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 METHODS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
14
|
|
|
14
|
|
77
|
use strict; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
434
|
|
16
|
14
|
|
|
14
|
|
73
|
use warnings; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
509
|
|
17
|
|
|
|
|
|
|
|
18
|
14
|
|
|
14
|
|
75
|
use vars qw(@fields); |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
618
|
|
19
|
|
|
|
|
|
|
|
20
|
14
|
|
|
14
|
|
76
|
use Moose; |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
102
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
extends('Test::Run::Base::Struct'); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has '_is_unknown' => (is => "rw", isa => "Bool"); |
25
|
|
|
|
|
|
|
has '_val' => (is => "rw", isa => "Maybe[Int]"); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 $class->create_unknown() |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Creates an unknown value. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub create_unknown |
34
|
|
|
|
|
|
|
{ |
35
|
10
|
|
|
10
|
1
|
26
|
my $class = shift; |
36
|
|
|
|
|
|
|
|
37
|
10
|
|
|
|
|
71
|
return $class->new({_is_unknown => 1}); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 $class->create_int($integer) |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Creates an integer value. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub create_int |
47
|
|
|
|
|
|
|
{ |
48
|
28
|
|
|
28
|
1
|
83
|
my $class = shift; |
49
|
28
|
|
|
|
|
55
|
my $integer = shift; |
50
|
|
|
|
|
|
|
|
51
|
28
|
|
|
|
|
253
|
return $class->new({_is_unknown => 0, _val => $integer}); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 zero() |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
A new 0 constant. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub zero |
61
|
|
|
|
|
|
|
{ |
62
|
1
|
|
|
1
|
1
|
4
|
my $class = shift; |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
10
|
return $class->create_int(0); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 $class->init_from_string("??" | [Integer]) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Inits a value from a string. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub init_from_string |
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
76
|
0
|
|
|
|
|
0
|
my $string = shift; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return |
79
|
|
|
|
|
|
|
( |
80
|
0
|
0
|
|
|
|
0
|
($string eq "??") |
81
|
|
|
|
|
|
|
? $class->create_unknown() |
82
|
|
|
|
|
|
|
: $class->create_int(int($string)) |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 $self->get_string_val() |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns "??" if the value is undefined or its numeric value otherwise. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub get_string_val |
93
|
|
|
|
|
|
|
{ |
94
|
20
|
|
|
20
|
1
|
315
|
my $self = shift; |
95
|
|
|
|
|
|
|
|
96
|
20
|
100
|
|
|
|
829
|
return ($self->_is_unknown() ? "??" : $self->_val()); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SEE ALSO |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L<Test::Run::Base::Struct>, L<Test::Run::Obj>, L<Test::Run::Core> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Copyright by Shlomi Fish, 2009. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 LICENSE |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This file is freely distributable under the MIT X11 license. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L<http://www.opensource.org/licenses/mit-license.php> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Shlomi Fish, L<http://www.shlomifish.org/>. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|