| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Valgrind::Version; |
|
2
|
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
14639
|
use strict; |
|
|
9
|
|
|
|
|
12
|
|
|
|
9
|
|
|
|
|
218
|
|
|
4
|
9
|
|
|
9
|
|
27
|
use warnings; |
|
|
9
|
|
|
|
|
10
|
|
|
|
9
|
|
|
|
|
332
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Test::Valgrind::Version - Object class for valgrind versions. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 1.19 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class is used to parse, store and compare C versions. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
9
|
|
|
9
|
|
28
|
use base 'Test::Valgrind::Carp'; |
|
|
9
|
|
|
|
|
9
|
|
|
|
9
|
|
|
|
|
759
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
9
|
|
|
9
|
|
36
|
use Scalar::Util (); |
|
|
9
|
|
|
|
|
12
|
|
|
|
9
|
|
|
|
|
2850
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $instanceof = sub { |
|
29
|
|
|
|
|
|
|
Scalar::Util::blessed($_[0]) && $_[0]->isa($_[1]); |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 C |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $vg_version = Test::Valgrind::Version->new( |
|
37
|
|
|
|
|
|
|
command_output => qx{valgrind --version}, |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $vg_version = Test::Valgrind::Version->new( |
|
41
|
|
|
|
|
|
|
string => '1.2.3', |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Creates a new L object representing a C version from one of these two sources : |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over 4 |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item * |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
if the C option is specified, then C will try to parse it as the output of C. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item * |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
otherwise the C option must be passed, and its value will be parsed as a 'dotted-integer' version number. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=back |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
An exception is raised if the version number cannot be inferred from the supplied data. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub new { |
|
63
|
109
|
|
|
109
|
1
|
125705
|
my ($class, %args) = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
109
|
|
|
|
|
145
|
my $output = $args{command_output}; |
|
66
|
109
|
|
|
|
|
114
|
my $string; |
|
67
|
109
|
100
|
|
|
|
220
|
if (defined $output) { |
|
68
|
24
|
|
|
|
|
211
|
($string) = $output =~ /^valgrind-([0-9]+(?:\.[0-9]+)*)/; |
|
69
|
|
|
|
|
|
|
} else { |
|
70
|
85
|
|
|
|
|
89
|
$string = $args{string}; |
|
71
|
85
|
50
|
|
|
|
130
|
return $string if $string->$instanceof(__PACKAGE__); |
|
72
|
85
|
100
|
100
|
|
|
744
|
if (defined $string and $string =~ /^([0-9]+(?:\.[0-9]+)*)/) { |
|
73
|
79
|
|
|
|
|
180
|
$string = $1; |
|
74
|
|
|
|
|
|
|
} else { |
|
75
|
6
|
|
|
|
|
7
|
$string = undef; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
} |
|
78
|
109
|
100
|
|
|
|
234
|
$class->_croak('Invalid argument') unless defined $string; |
|
79
|
|
|
|
|
|
|
|
|
80
|
98
|
|
|
|
|
556
|
my @digits = map int, split /\./, $string; |
|
81
|
98
|
|
|
|
|
167
|
my $last = $#digits; |
|
82
|
98
|
|
|
|
|
223
|
for my $i (reverse 0 .. $#digits) { |
|
83
|
152
|
100
|
|
|
|
315
|
last if $digits[$i]; |
|
84
|
54
|
|
|
|
|
63
|
--$last; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
bless { |
|
88
|
98
|
|
|
|
|
673
|
_digits => [ @digits[0 .. $last] ], |
|
89
|
|
|
|
|
|
|
_last => $last, |
|
90
|
|
|
|
|
|
|
}, $class; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
BEGIN { |
|
94
|
9
|
|
|
9
|
|
13
|
local $@; |
|
95
|
9
|
|
|
96
|
|
599
|
eval "sub $_ { \$_[0]->{$_} }" for qw<_digits _last>; |
|
|
96
|
|
|
87
|
|
307
|
|
|
|
87
|
|
|
|
|
167
|
|
|
96
|
9
|
50
|
|
|
|
1616
|
die $@ if $@; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 OVERLOADING |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This class overloads numeric comparison operators (C<< <=> >>, C<< < >>, C<< <= >>, C< == >, C<< => >> and C<< > >>), as well as stringification. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _spaceship { |
|
106
|
29
|
|
|
29
|
|
195
|
my ($left, $right, $swap) = @_; |
|
107
|
|
|
|
|
|
|
|
|
108
|
29
|
100
|
|
|
|
93
|
unless ($right->$instanceof(__PACKAGE__)) { |
|
109
|
2
|
|
|
|
|
46
|
$right = __PACKAGE__->new(string => $right); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
29
|
50
|
|
|
|
68
|
($right, $left) = ($left, $right) if $swap; |
|
112
|
|
|
|
|
|
|
|
|
113
|
29
|
|
|
|
|
879
|
my $left_digits = $left->_digits; |
|
114
|
29
|
|
|
|
|
560
|
my $right_digits = $right->_digits; |
|
115
|
|
|
|
|
|
|
|
|
116
|
29
|
|
|
|
|
543
|
my $last_cmp = $left->_last <=> $right->_last; |
|
117
|
29
|
100
|
|
|
|
569
|
my $last = ($last_cmp < 0) ? $left->_last : $right->_last; |
|
118
|
|
|
|
|
|
|
|
|
119
|
29
|
|
|
|
|
99
|
for my $i (0 .. $last) { |
|
120
|
46
|
|
|
|
|
57
|
my $cmp = $left_digits->[$i] <=> $right_digits->[$i]; |
|
121
|
46
|
100
|
|
|
|
207
|
return $cmp if $cmp; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
16
|
|
|
|
|
63
|
return $last_cmp; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub _stringify { |
|
128
|
38
|
|
|
38
|
|
74
|
my $self = shift; |
|
129
|
38
|
|
|
|
|
39
|
my @digits = @{ $self->_digits }; |
|
|
38
|
|
|
|
|
1037
|
|
|
130
|
38
|
|
|
|
|
140
|
push @digits, 0 until @digits >= 3; |
|
131
|
38
|
|
|
|
|
349
|
join '.', @digits; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
use overload ( |
|
135
|
9
|
|
|
|
|
69
|
'<=>' => \&_spaceship, |
|
136
|
|
|
|
|
|
|
'""' => \&_stringify, |
|
137
|
|
|
|
|
|
|
fallback => 1, |
|
138
|
9
|
|
|
9
|
|
5447
|
); |
|
|
9
|
|
|
|
|
4485
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Vincent Pit, C<< >>, L. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
You can contact me by mail or on C (vincent). |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 BUGS |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through the web interface at L. |
|
153
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 SUPPORT |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
perldoc Test::Valgrind::Component |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Copyright 2015,2016 Vincent Pit, all rights reserved. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; # End of Test::Valgrind::Version |