summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xPorting/Maintainers.pl2
-rw-r--r--cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm8
-rw-r--r--cpan/CPAN-Meta-Requirements/t/basic.t18
-rw-r--r--cpan/CPAN-Meta-Requirements/t/strings.t15
4 files changed, 38 insertions, 5 deletions
diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl
index 0aa1a2f163..0fb3137296 100755
--- a/Porting/Maintainers.pl
+++ b/Porting/Maintainers.pl
@@ -294,7 +294,7 @@ use File::Glob qw(:case);
},
'CPAN::Meta::Requirements' => {
- 'DISTRIBUTION' => 'DAGOLDEN/CPAN-Meta-Requirements-2.131.tar.gz',
+ 'DISTRIBUTION' => 'DAGOLDEN/CPAN-Meta-Requirements-2.132.tar.gz',
'FILES' => q[cpan/CPAN-Meta-Requirements],
'EXCLUDED' => [
qw(CONTRIBUTING.mkdn),
diff --git a/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm b/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm
index e86dd561d4..8348559498 100644
--- a/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm
+++ b/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm
@@ -3,7 +3,7 @@ use warnings;
package CPAN::Meta::Requirements;
# ABSTRACT: a set of version requirements for a CPAN dist
-our $VERSION = '2.131';
+our $VERSION = '2.132';
#pod =head1 SYNOPSIS
#pod
@@ -119,7 +119,7 @@ sub _version_object {
}
eval {
- if (not defined $version or $version eq '0') {
+ if (not defined $version or (!ref($version) && $version eq '0')) {
$vobj = $V0;
}
elsif ( ref($version) eq 'version' || _isa_version($version) ) {
@@ -229,7 +229,7 @@ BEGIN {
sub add_minimum {
my ($self, $name, $version) = @_;
- if (not defined $version or $version eq '0') {
+ if (not defined $version or (!ref($version) && $version eq '0')) {
return $self if $self->__entry_for($name);
Carp::confess("can't add new requirements to finalized requirements")
if $self->is_finalized;
@@ -787,7 +787,7 @@ CPAN::Meta::Requirements - a set of version requirements for a CPAN dist
=head1 VERSION
-version 2.131
+version 2.132
=head1 SYNOPSIS
diff --git a/cpan/CPAN-Meta-Requirements/t/basic.t b/cpan/CPAN-Meta-Requirements/t/basic.t
index 882e32466e..ba029f427b 100644
--- a/cpan/CPAN-Meta-Requirements/t/basic.t
+++ b/cpan/CPAN-Meta-Requirements/t/basic.t
@@ -233,4 +233,22 @@ sub foo_1 {
is ( $scalar, undef, "requirements_for_module() returns undef for not found (scalar)" );
}
+{
+ my $req = CPAN::Meta::Requirements->new;
+
+ $req->add_minimum(Foo => "0.00");
+
+ my $req2 = CPAN::Meta::Requirements->new;
+ $req2->add_requirements($req);
+
+ is_deeply(
+ $req2->as_string_hash,
+ {
+ Foo => '0.00'
+ },
+ "0.00 precision preserved",
+ );
+
+}
+
done_testing;
diff --git a/cpan/CPAN-Meta-Requirements/t/strings.t b/cpan/CPAN-Meta-Requirements/t/strings.t
index 94a52367a4..55a28bee6b 100644
--- a/cpan/CPAN-Meta-Requirements/t/strings.t
+++ b/cpan/CPAN-Meta-Requirements/t/strings.t
@@ -55,6 +55,21 @@ ok(!$req->accepts_module('A::Tribe::Called' => '1.2'), 'lower version (>=, <=, !
ok(!$req->accepts_module('A::Tribe::Called' => '2.1'), 'higher version (>=, <=, !)');
ok(!$req->accepts_module('A::Tribe::Called' => '1.6'), 'excluded version (>=, <=, !)');
+# Test precision
+{
+ my $req = CPAN::Meta::Requirements->new;
+
+ $req->add_string_requirement(Foo => "0.00");
+
+ is_deeply(
+ $req->as_string_hash,
+ {
+ Foo => '0.00'
+ },
+ "0.00 precision preserved",
+ );
+}
+
# Test fatal errors
dies_ok { $req->add_string_requirement('Foo::Bar', "not really a version") }
qr/Can't convert/,