summaryrefslogtreecommitdiff
path: root/cpan/version
diff options
context:
space:
mode:
authorJohn Peacock <jpeacock@cpan.org>2016-02-16 21:34:52 -0600
committerRicardo Signes <rjbs@cpan.org>2016-03-17 20:51:15 -0400
commit14f3031b13a4d4c094ca37dc42e1cbb34863a050 (patch)
tree2d2e04389368288ced76779111d3975001235ea2 /cpan/version
parentdf0d64c4362a87d672ee4136a9487b7671c48aab (diff)
downloadperl-14f3031b13a4d4c094ca37dc42e1cbb34863a050.tar.gz
Import version.pm 0.9914 from CPAN
Diffstat (limited to 'cpan/version')
-rw-r--r--cpan/version/lib/version.pm6
-rw-r--r--cpan/version/lib/version.pod6
-rw-r--r--cpan/version/lib/version/Internals.pod4
-rw-r--r--cpan/version/lib/version/regex.pm2
-rw-r--r--cpan/version/t/01base.t7
-rw-r--r--cpan/version/t/02derived.t7
-rw-r--r--cpan/version/t/03require.t7
-rw-r--r--cpan/version/t/05sigdie.t2
-rw-r--r--cpan/version/t/06noop.t2
-rw-r--r--cpan/version/t/07locale.t89
-rw-r--r--cpan/version/t/08_corelist.t2
-rw-r--r--cpan/version/t/09_list_util.t2
-rw-r--r--cpan/version/t/10_lyon.t44
-rw-r--r--cpan/version/t/coretests.pm72
14 files changed, 213 insertions, 39 deletions
diff --git a/cpan/version/lib/version.pm b/cpan/version/lib/version.pm
index f8afd8435b..d20427cc1c 100644
--- a/cpan/version/lib/version.pm
+++ b/cpan/version/lib/version.pm
@@ -3,10 +3,14 @@ package version;
use 5.006002;
use strict;
+use warnings::register;
+if ($] >= 5.015) {
+ warnings::register_categories(qw/version/);
+}
use vars qw(@ISA $VERSION $CLASS $STRICT $LAX *declare *qv);
-$VERSION = 0.9909;
+$VERSION = 0.9914;
$CLASS = 'version';
# avoid using Exporter
diff --git a/cpan/version/lib/version.pod b/cpan/version/lib/version.pod
index 40ceee2063..42691b1e0c 100644
--- a/cpan/version/lib/version.pod
+++ b/cpan/version/lib/version.pod
@@ -12,8 +12,8 @@ version - Perl extension for Version Objects
# Declaring a dotted-decimal $VERSION (keep on one line!)
use version; our $VERSION = version->declare("v1.2.3"); # formal
- use version; our $VERSION = qv("v1.2.3"); # shorthand
- use version; our $VERSION = qv("v1.2_3"); # alpha
+ use version; our $VERSION = qv("v1.2.3"); # deprecated
+ use version; our $VERSION = qv("v1.2_3"); # deprecated
# Declaring an old-style decimal $VERSION (use quotes!)
@@ -270,7 +270,7 @@ Returns a value representing the object in a pure decimal form without
trailing zeroes.
version->declare('v1.2')->numify; # 1.002
- version->parse('1.2')->numify; # 1.2
+ version->parse('1.2')->numify; # 1.200
=head2 stringify()
diff --git a/cpan/version/lib/version/Internals.pod b/cpan/version/lib/version/Internals.pod
index 95be844881..dd784fe4c8 100644
--- a/cpan/version/lib/version/Internals.pod
+++ b/cpan/version/lib/version/Internals.pod
@@ -21,14 +21,14 @@ There are actually two distinct kinds of version objects:
=over 4
-=item Decimal Versions
+=item Decimal versions
Any version which "looks like a number", see L<Decimal Versions>. This
also includes versions with a single decimal point and a single embedded
underscore, see L<Alpha Versions>, even though these must be quoted
to preserve the underscore formatting.
-=item Dotted-Decimal Versions
+=item Dotted-Decimal versions
Also referred to as "Dotted-Integer", these contains more than one decimal
point and may have an optional embedded underscore, see L<Dotted-Decimal
diff --git a/cpan/version/lib/version/regex.pm b/cpan/version/lib/version/regex.pm
index f73296383a..dc769c28dd 100644
--- a/cpan/version/lib/version/regex.pm
+++ b/cpan/version/lib/version/regex.pm
@@ -4,7 +4,7 @@ use strict;
use vars qw($VERSION $CLASS $STRICT $LAX);
-$VERSION = 0.9909;
+$VERSION = 0.9914;
#--------------------------------------------------------------------------#
# Version regexp components
diff --git a/cpan/version/t/01base.t b/cpan/version/t/01base.t
index 6174194b8a..4c1a23dd49 100644
--- a/cpan/version/t/01base.t
+++ b/cpan/version/t/01base.t
@@ -5,11 +5,14 @@
#########################
use Test::More qw/no_plan/;
+use File::Spec;
BEGIN {
- (my $coretests = $0) =~ s'[^/]+\.t'coretests.pm';
+ my $coretests = File::Spec->catpath(
+ (File::Spec->splitpath($0))[0,1], 'coretests.pm'
+ );
require $coretests;
- use_ok('version', 0.9909);
+ use_ok('version', 0.9914);
}
BaseTests("version","new","qv");
diff --git a/cpan/version/t/02derived.t b/cpan/version/t/02derived.t
index a5aa2e48ff..ac0dea9130 100644
--- a/cpan/version/t/02derived.t
+++ b/cpan/version/t/02derived.t
@@ -5,12 +5,15 @@
#########################
use Test::More qw/no_plan/;
+use File::Spec;
use File::Temp qw/tempfile/;
BEGIN {
- (my $coretests = $0) =~ s'[^/]+\.t'coretests.pm';
+ my $coretests = File::Spec->catpath(
+ (File::Spec->splitpath($0))[0,1], 'coretests.pm'
+ );
require $coretests;
- use_ok("version", 0.9909);
+ use_ok("version", 0.9914);
# If we made it this far, we are ok.
}
diff --git a/cpan/version/t/03require.t b/cpan/version/t/03require.t
index f6100ef4f6..ed437be64f 100644
--- a/cpan/version/t/03require.t
+++ b/cpan/version/t/03require.t
@@ -5,16 +5,19 @@
#########################
use Test::More qw/no_plan/;
+use File::Spec;
BEGIN {
- (my $coretests = $0) =~ s'[^/]+\.t'coretests.pm';
+ my $coretests = File::Spec->catpath(
+ (File::Spec->splitpath($0))[0,1], 'coretests.pm'
+ );
require $coretests;
}
# Don't want to use, because we need to make sure that the import doesn't
# fire just yet (some code does this to avoid importing qv() and delare()).
require_ok("version");
-is $version::VERSION, 0.9909, "Make sure we have the correct class";
+is $version::VERSION, 0.9914, "Make sure we have the correct class";
ok(!"main"->can("qv"), "We don't have the imported qv()");
ok(!"main"->can("declare"), "We don't have the imported declare()");
diff --git a/cpan/version/t/05sigdie.t b/cpan/version/t/05sigdie.t
index 0b82313df0..fad9139acf 100644
--- a/cpan/version/t/05sigdie.t
+++ b/cpan/version/t/05sigdie.t
@@ -14,7 +14,7 @@ BEGIN {
}
BEGIN {
- use version 0.9909;
+ use version 0.9914;
}
pass "Didn't get caught by the wrong DIE handler, which is a good thing";
diff --git a/cpan/version/t/06noop.t b/cpan/version/t/06noop.t
index ed24602e41..e9f7187145 100644
--- a/cpan/version/t/06noop.t
+++ b/cpan/version/t/06noop.t
@@ -7,7 +7,7 @@
use Test::More qw/no_plan/;
BEGIN {
- use_ok('version', 0.9909);
+ use_ok('version', 0.9914);
}
my $v1 = version->new('1.2');
diff --git a/cpan/version/t/07locale.t b/cpan/version/t/07locale.t
index 7af61b5725..22b9def883 100644
--- a/cpan/version/t/07locale.t
+++ b/cpan/version/t/07locale.t
@@ -7,11 +7,11 @@
use File::Basename;
use File::Temp qw/tempfile/;
use POSIX qw/locale_h/;
-use Test::More tests => 7;
+use Test::More tests => 8;
use Config;
BEGIN {
- use_ok('version', 0.9909);
+ use_ok('version', 0.9914);
}
SKIP: {
@@ -20,7 +20,7 @@ SKIP: {
if(!$Config{d_setlocale});
# test locale handling
- my $warning;
+ my $warning = '';
local $SIG{__WARN__} = sub { $warning = $_[0] };
@@ -38,7 +38,7 @@ SKIP: {
$loc = setlocale( LC_ALL, $_);
last if $loc && localeconv()->{decimal_point} eq ',';
}
- skip 'Cannot test locale handling without a comma locale', 5
+ skip 'Cannot test locale handling without a comma locale', 6
unless $loc and localeconv()->{decimal_point} eq ',';
setlocale(LC_NUMERIC, $loc);
@@ -50,11 +50,14 @@ SKIP: {
ok ($v eq "1.23", "Locale doesn't apply to version objects");
ok ($v == $ver, "Comparison to locale floating point");
+ TODO: { # Resolve https://rt.cpan.org/Ticket/Display.html?id=102272
+ local $TODO = 'Fails for Perl 5.x.0 < 5.19.0';
+ $ver = version->new($]);
+ is "$ver", "$]", 'Use PV for dualvars';
+ }
setlocale( LC_ALL, $orig_loc); # reset this before possible skip
skip 'Cannot test RT#46921 with Perl < 5.008', 1
if ($] < 5.008);
- skip 'Cannot test RT#46921 with pure Perl module', 1
- if exists $INC{'version/vpp.pm'};
my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1);
(my $package = basename($filename)) =~ s/\.pm$//;
print $fh <<"EOF";
@@ -79,169 +82,243 @@ EOF
__DATA__
af_ZA
af_ZA.utf8
+af_ZA.UTF-8
an_ES
an_ES.utf8
+an_ES.UTF-8
az_AZ.utf8
+az_AZ.UTF-8
be_BY
be_BY.utf8
+be_BY.UTF-8
bg_BG
bg_BG.utf8
+bg_BG.UTF-8
br_FR
br_FR@euro
br_FR.utf8
+br_FR.UTF-8
bs_BA
bs_BA.utf8
+bs_BA.UTF-8
ca_ES
ca_ES@euro
ca_ES.utf8
+ca_ES.UTF-8
cs_CZ
cs_CZ.utf8
+cs_CZ.UTF-8
da_DK
da_DK.utf8
+da_DK.UTF-8
de_AT
de_AT@euro
de_AT.utf8
+de_AT.UTF-8
de_BE
de_BE@euro
de_BE.utf8
+de_BE.UTF-8
de_DE
de_DE@euro
de_DE.utf8
+de_DE.UTF-8
+de_DE.UTF-8
de_LU
de_LU@euro
de_LU.utf8
+de_LU.UTF-8
el_GR
el_GR.utf8
+el_GR.UTF-8
en_DK
en_DK.utf8
+en_DK.UTF-8
es_AR
es_AR.utf8
+es_AR.UTF-8
es_BO
es_BO.utf8
+es_BO.UTF-8
es_CL
es_CL.utf8
+es_CL.UTF-8
es_CO
es_CO.utf8
+es_CO.UTF-8
es_EC
es_EC.utf8
+es_EC.UTF-8
es_ES
es_ES@euro
es_ES.utf8
+es_ES.UTF-8
es_PY
es_PY.utf8
+es_PY.UTF-8
es_UY
es_UY.utf8
+es_UY.UTF-8
es_VE
es_VE.utf8
+es_VE.UTF-8
et_EE
et_EE.iso885915
et_EE.utf8
+et_EE.UTF-8
eu_ES
eu_ES@euro
eu_ES.utf8
+eu_ES.UTF-8
fi_FI
fi_FI@euro
fi_FI.utf8
+fi_FI.UTF-8
fo_FO
fo_FO.utf8
+fo_FO.UTF-8
fr_BE
fr_BE@euro
fr_BE.utf8
+fr_BE.UTF-8
fr_CA
fr_CA.utf8
+fr_CA.UTF-8
fr_CH
fr_CH.utf8
+fr_CH.UTF-8
fr_FR
fr_FR@euro
fr_FR.utf8
+fr_FR.UTF-8
fr_LU
fr_LU@eu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.UTF-8
sv_SE
sv_SE.iso885915
sv_SE.utf8
+sv_SE.UTF-8
tg_TJ
tg_TJ.utf8
+tg_TJ.UTF-8
tr_TR
tr_TR.utf8
+tr_TR.UTF-8
tt_RU.utf8
+tt_RU.UTF-8
uk_UA
uk_UA.utf8
+uk_UA.UTF-8
vi_VN
vi_VN.tcvn
wa_BE
wa_BE@euro
wa_BE.utf8
+wa_BE.UTF-8
diff --git a/cpan/version/t/08_corelist.t b/cpan/version/t/08_corelist.t
index d7829c1c92..d8cd147949 100644
--- a/cpan/version/t/08_corelist.t
+++ b/cpan/version/t/08_corelist.t
@@ -5,7 +5,7 @@
#########################
use Test::More tests => 3;
-use_ok("version", 0.9909);
+use_ok("version", 0.9914);
# do strict lax tests in a sub to isolate a package to test importing
SKIP: {
diff --git a/cpan/version/t/09_list_util.t b/cpan/version/t/09_list_util.t
index dbd387dbd4..bb6d3ec443 100644
--- a/cpan/version/t/09_list_util.t
+++ b/cpan/version/t/09_list_util.t
@@ -4,7 +4,7 @@
#########################
use strict;
-use_ok("version", 0.9909);
+use_ok("version", 0.9914);
use Test::More;
BEGIN {
diff --git a/cpan/version/t/10_lyon.t b/cpan/version/t/10_lyon.t
new file mode 100644
index 0000000000..4f927aa65f
--- /dev/null
+++ b/cpan/version/t/10_lyon.t
@@ -0,0 +1,44 @@
+#! perl
+
+use Test::More qw/no_plan/;
+
+use version;
+
+# These values are from the Lyon consensus, as taken from
+# https://gist.github.com/dagolden/9559280
+
+ok(version->new(1.0203) == version->new('1.0203'));
+ok(version->new(1.02_03) == version->new('1.02_03'));
+ok(version->new(v1.2.3) == version->new('v1.2.3'));
+if ($] >= 5.008_001) {
+ ok(version->new(v1.2.3_0) == version->new('v1.2.3_0'));
+}
+
+cmp_ok(version->new(1.0203), '==', version->new('1.0203'));
+cmp_ok(version->new(1.02_03), '==', version->new('1.02_03'));
+cmp_ok(version->new(v1.2.3), '==', version->new('v1.2.3'));
+if ($] >= 5.008_001) {
+ cmp_ok(version->new(v1.2.3_0), '==', version->new('v1.2.3_0'));
+}
+
+cmp_ok(version->new('1.0203')->numify, '==', '1.0203');
+is(version->new('1.0203')->normal, 'v1.20.300');
+
+cmp_ok(version->new('1.02_03')->numify, '==', '1.0203');
+is(version->new('1.02_03')->normal, 'v1.20.300');
+
+cmp_ok(version->new('v1.2.30')->numify, '==', '1.002030');
+is(version->new('v1.2.30')->normal, 'v1.2.30');
+cmp_ok(version->new('v1.2.3_0')->numify, '==', '1.002030');
+is(version->new('v1.2.3_0')->normal, 'v1.2.30');
+
+is(version->new("1.0203")->stringify, "1.0203");
+is(version->new("1.02_03")->stringify, "1.02_03");
+is(version->new("v1.2.30")->stringify, "v1.2.30");
+is(version->new("v1.2.3_0")->stringify, "v1.2.3_0");
+is(version->new(1.0203)->stringify, "1.0203");
+is(version->new(1.02_03)->stringify, "1.0203");
+is(version->new(v1.2.30)->stringify, "v1.2.30");
+if ($] >= 5.008_001) {
+ is(version->new(v1.2.3_0)->stringify, "v1.2.30");
+}
diff --git a/cpan/version/t/coretests.pm b/cpan/version/t/coretests.pm
index 17bf9ec5fc..07cc82e614 100644
--- a/cpan/version/t/coretests.pm
+++ b/cpan/version/t/coretests.pm
@@ -10,7 +10,7 @@ if ($Test::More::VERSION < 0.48) { # Fix for RT#48268
*main::use_ok = sub ($;@) {
my ($pkg, $req, @args) = @_;
eval "use $pkg $req ".join(' ',@args);
- is ${"$pkg\::VERSION"}, $req, 'Had to manually use version';
+ is ${"$pkg\::VERSION"}, eval($req), 'Had to manually use version';
# If we made it this far, we are ok.
};
}
@@ -132,8 +132,8 @@ sub BaseTests {
ok ( $version != $new_version, '$version != $new_version' );
$version = $CLASS->$method("1.2.4");
- ok ( $version > $new_version, '$version > $new_version' );
- ok ( $new_version < $version, '$new_version < $version' );
+ ok ( $version < $new_version, '$version < $new_version' );
+ ok ( $new_version > $version, '$new_version > $version' );
ok ( $version != $new_version, '$version != $new_version' );
# now test with alpha version form with object
@@ -146,24 +146,22 @@ sub BaseTests {
ok ( $new_version->is_alpha, '$new_version->is_alpha');
$version = $CLASS->$method("1.2.4");
- ok ( $version > $new_version, '$version > $new_version' );
- ok ( $new_version < $version, '$new_version < $version' );
+ ok ( $version < $new_version, '$version < $new_version' );
+ ok ( $new_version > $version, '$new_version > $version' );
ok ( $version != $new_version, '$version != $new_version' );
- $version = $CLASS->$method("1.2.3.4");
+ $version = $CLASS->$method("1.2.34");
$new_version = $CLASS->$method("1.2.3_4");
- ok ( $version > $new_version, '$version > $new_version' );
- ok ( $new_version < $version, '$new_version < $version' );
- ok ( $version != $new_version, '$version != $new_version' );
+ ok ( $version == $new_version, '$version == $new_version' );
- $version = $CLASS->$method("v1.2.3");
- $new_version = $CLASS->$method("1.2.3.0");
+ $version = $CLASS->$method("v1.2.30");
+ $new_version = $CLASS->$method("1.2.30.0");
ok ( $version == $new_version, '$version == $new_version' );
$new_version = $CLASS->$method("1.2.3_0");
ok ( $version == $new_version, '$version == $new_version' );
- $new_version = $CLASS->$method("1.2.3.1");
+ $new_version = $CLASS->$method("1.2.30.1");
ok ( $version < $new_version, '$version < $new_version' );
- $new_version = $CLASS->$method("1.2.3_1");
+ $new_version = $CLASS->$method("1.2.30_1");
ok ( $version < $new_version, '$version < $new_version' );
$new_version = $CLASS->$method("1.1.999");
ok ( $version > $new_version, '$version > $new_version' );
@@ -348,9 +346,10 @@ SKIP: {
skip 'Cannot test bare alpha v-strings with Perl < 5.8.1', 2
if $] lt 5.008_001;
$version = $CLASS->$method(v1.2.3_4);
- is($version, "v1.2.3_4", '"$version" eq "v1.2.3_4"');
+ $DB::single = 1;
+ is($version, "v1.2.34", '"$version" eq "v1.2.34"');
$version = $CLASS->$method(eval "v1.2.3_4");
- is($version, "v1.2.3_4", '"$version" eq "v1.2.3_4" (from eval)');
+ is($version, "v1.2.34", '"$version" eq "v1.2.34" (from eval)');
}
# trailing zero testing (reported by Andreas Koenig).
@@ -592,7 +591,48 @@ SKIP: {
eval {my $v = $CLASS->new({1 => 2}) };
like $@, qr/Invalid version format/, 'Do not crash for garbage';
}
-
+ { # https://rt.cpan.org/Ticket/Display.html?id=93603
+ eval {my $v = $CLASS->$method('.1.')};
+ like $@, qr/trailing decimal/, 'Forbid trailing decimals';
+ eval {my $v = $CLASS->$method('.1.2.')};
+ like $@, qr/trailing decimal/, 'Forbid trailing decimals';
+ }
+ { # https://rt.cpan.org/Ticket/Display.html?id=93715
+ eval {my $v = $CLASS->new(v1.2)};
+ unlike $@, qr/non-numeric data/, 'Handle short v-strings';
+ eval {my $v = $CLASS->new(v1)};
+ unlike $@, qr/non-numeric data/, 'Handle short v-strings';
+ }
+ {
+ my $two31 = '2147483648';
+ my $v = $CLASS->new($two31);
+ is "$v", 'v.Inf', 'Element Exceeds VERSION_MAX';
+ like $warning, qr/Integer overflow in version/, 'Overflow warning';
+ $v = $CLASS->new("1.$two31.$two31");
+ is "$v", 'v.Inf', 'Element Exceeds VERSION_MAX';
+ like $warning, qr/Integer overflow in version/, 'Overflow warning';
+ }
+ {
+ # now as a number
+ $two31 = 2**31;
+ $v = $CLASS->new($two31);
+ is "$v", 'v.Inf', 'Element Exceeds VERSION_MAX';
+ like $warning, qr/Integer overflow in version/, 'Overflow warning';
+ }
+ { # https://rt.cpan.org/Ticket/Display.html?id=101628
+ undef $warning;
+ $v = $CLASS->new('1.1.00000000010');
+ is $v->normal, "v1.1.10", 'Ignore leading zeros';
+ unlike $warning, qr/Integer overflow in version/, 'No overflow warning';
+ }
+ { # https://rt.cpan.org/Ticket/Display.html?id=93340
+ $v = $CLASS->parse(q[2.6_01]);
+ is $v->normal, 'v2.601.0', 'Normal strips underscores from alphas'
+ }
+ { # https://rt.cpan.org/Ticket/Display.html?id=98744
+ $v = $CLASS->new("1.02_003");
+ is $v->numify, '1.020030', 'Ignore underscores for numify';
+ }
}
1;