Skip to content

Commit

Permalink
cpan/version: Update to version 0.9933
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultduponchelle authored and jkeenan committed Sep 14, 2024
1 parent a3f1028 commit 5bde80d
Show file tree
Hide file tree
Showing 16 changed files with 256 additions and 74 deletions.
2 changes: 1 addition & 1 deletion cpan/version/lib/version.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if ($] >= 5.015) {
warnings::register_categories(qw/version/);
}

our $VERSION = '0.9930';
our $VERSION = '0.9933';
our $CLASS = 'version';
our (@ISA, $STRICT, $LAX);

Expand Down
29 changes: 29 additions & 0 deletions cpan/version/lib/version.pod
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,30 @@ Returns a value representing the object in a pure decimal.
version->declare('v1.2')->numify; # 1.002000
version->parse('1.2')->numify; # 1.200

=head2 to_decimal

This returns a new version object for the numified version, much like C<< version->parse($v->numify) >> would.

version->parse('v1.2')->to_decimal; # 1.002000

=head2 to_dotted_decimal

This returns a new version object for the normalized version, much like C<< version->parse($v->normal) >> would.

version->parse('1.002')->to_dotted_decimal; # v1.2.0

=head2 tuple()

This turns the components of the version into a list. E.g.

version->parse('1.2.3')->tuple; # (1, 2, 3)

=head2 from_tuple(...)

This takes a list of components and creates a dotted decimal version out of it. E.g.

version->from_tuple(1, 2, 3) # v1.2.3

=head2 stringify()

Returns a string that is as close to the original representation as possible.
Expand All @@ -282,6 +306,11 @@ a version object is interpolated into a string.
version->parse('1.200')->stringify; # 1.2
version->parse(1.02_30)->stringify; # 1.023

=head2 tuple

Returns an array of non-negative integers that is used for comparison purposes with
other version objects.

=head1 EXPORTED FUNCTIONS

=head2 qv()
Expand Down
52 changes: 0 additions & 52 deletions cpan/version/lib/version/Internals.pod
Original file line number Diff line number Diff line change
Expand Up @@ -300,58 +300,6 @@ determine whether the v-string encoding was used.
form that has a leading 'v' character, for the simple reason that sometimes
it is impossible to tell whether one was present initially.

=head2 Version Object Internals

version.pm provides an overloaded version object that is designed to both
encapsulate the author's intended $VERSION assignment as well as make it
completely natural to use those objects as if they were numbers (e.g. for
comparisons). To do this, a version object contains both the original
representation as typed by the author, as well as a parsed representation
to ease comparisons. Version objects employ L<overload> methods to
simplify code that needs to compare, print, etc the objects.

The internal structure of version objects is a blessed hash with several
components:

bless( {
'original' => 'v1.2.3_4',
'alpha' => 1,
'qv' => 1,
'version' => [
1,
2,
3,
4
]
}, 'version' );

=over 4

=item original

A faithful representation of the value used to initialize this version
object. The only time this will not be precisely the same characters
that exist in the source file is if a short dotted-decimal version like
v1.2 was used (in which case it will contain 'v1.2'). This form is
B<STRONGLY> discouraged, in that it will confuse you and your users.

=item qv

A boolean that denotes whether this is a decimal or dotted-decimal version.
See L<version/is_qv()>.

=item alpha

A boolean that denotes whether this is an alpha version. NOTE: that the
underscore can only appear in the last position. See L<version/is_alpha()>.

=item version

An array of non-negative integers that is used for comparison purposes with
other version objects.

=back

=head2 Replacement UNIVERSAL::VERSION

In addition to the version objects, this modules also replaces the core
Expand Down
2 changes: 1 addition & 1 deletion cpan/version/lib/version/regex.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package version::regex;

use strict;

our $VERSION = '0.9930';
our $VERSION = '0.9933';

#--------------------------------------------------------------------------#
# Version regexp components
Expand Down
2 changes: 1 addition & 1 deletion cpan/version/t/01base.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BEGIN {
)
);
require $coretests;
use_ok('version', 0.9930);
use_ok('version', 0.9933);
}

BaseTests("version","new","qv");
Expand Down
2 changes: 1 addition & 1 deletion cpan/version/t/02derived.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BEGIN {
)
);
require $coretests;
use_ok("version", 0.9930);
use_ok("version", 0.9933);
# If we made it this far, we are ok.
}

Expand Down
2 changes: 1 addition & 1 deletion cpan/version/t/03require.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BEGIN {
# 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.9930', "Make sure we have the correct class";
is $version::VERSION, '0.9933', "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()");

Expand Down
2 changes: 1 addition & 1 deletion cpan/version/t/05sigdie.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BEGIN {
}

BEGIN {
use version 0.9930;
use version 0.9933;
}

pass "Didn't get caught by the wrong DIE handler, which is a good thing";
2 changes: 1 addition & 1 deletion cpan/version/t/06noop.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Test::More qw/no_plan/;

BEGIN {
use_ok('version', 0.9930);
use_ok('version', 0.9933);
}

my $v1 = 'version'->new('1.2');
Expand Down
99 changes: 91 additions & 8 deletions cpan/version/t/07locale.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,29 @@ use Test::More tests => 8;
use Config;

BEGIN {
use_ok('version', 0.9930);
use_ok('version', 0.9933);
}

sub radix { # Returns the radix character for the current locale.

# Use localeconv() on earlier perls; if it is just a stub, assume a dot.
if (! $^V or $^V lt v5.37.4) {
return localeconv()->{decimal_point} || ".";
}

# localeconv() may be a stub on some platforms. But on later perls,
# langinfo() will always exist and returns the best available value.
use if $^V && $^V ge v5.37.4, 'I18N::Langinfo' => qw(langinfo RADIXCHAR);
return langinfo(RADIXCHAR);
}

SKIP: {
skip 'No locale testing for Perl < 5.6.0', 7 if $] < 5.006;
skip 'No locale testing without d_setlocale', 7
if(!$Config{d_setlocale});
eval "&POSIX::LC_NUMERIC";
skip 'No locale testing without LC_NUMERIC', 7
if($Config{ccflags}) =~ /-DNO_LOCALE_NUMERIC\b/;
if $@ || $Config{ccflags} =~ /-DNO_LOCALE_NUMERIC\b/;

# test locale handling
my $warning = '';
Expand All @@ -37,11 +51,11 @@ SKIP: {

while (<DATA>) {
chomp;
$loc = setlocale( LC_ALL, $_);
last if $loc && localeconv()->{decimal_point} eq ',';
$loc = setlocale( LC_NUMERIC, $_);
last if $loc && radix() eq ',';
}
skip 'Cannot test locale handling without a comma locale', 6
unless $loc and localeconv()->{decimal_point} eq ',';
unless $loc and radix() eq ',';

setlocale(LC_NUMERIC, $loc);
$ver = 1.23; # has to be floating point number
Expand All @@ -57,7 +71,7 @@ SKIP: {
$ver = 'version'->new($]);
is "$ver", "$]", 'Use PV for dualvars';
}
setlocale( LC_ALL, $orig_loc); # reset this before possible skip
setlocale( LC_NUMERIC, $orig_loc); # reset this before possible skip
skip 'Cannot test RT#46921 with Perl < 5.008', 1
if ($] < 5.008);
my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1);
Expand All @@ -68,10 +82,10 @@ use locale;
use POSIX qw(locale_h);
\$^W = 1;
use version;
setlocale (LC_ALL, '$loc');
setlocale (LC_NUMERIC, '$loc');
use version ;
eval "use Socket 1.7";
setlocale( LC_ALL, '$orig_loc');
setlocale( LC_NUMERIC, '$orig_loc');
1;
EOF
close $fh;
Expand Down Expand Up @@ -324,3 +338,72 @@ wa_BE
wa_BE@euro
wa_BE.utf8
wa_BE.UTF-8
Afrikaans
Albanian
Arabic
Basque
Breton
Brezhoneg
Bulgarian
Bulgarski
Chinese
Croatian
Cymraeg
Czech
Danish
Dansk
Deutsch
Dutch
Eesti
Ellada
Esperanto
Estonian
Euskaraz
Finnish
Flamish
Frysk
Gaeilge
Galego
Galician
German
Greek
Greenlandic
Hebrew
Hrvatski
Hungarian
Indonesian
Irish
Italian
Italiano
Japanese
Korean
Latin
Latine
Latvian
Lithuanian
Macedonian
Maltese
Moldovan
Nederlands
Nihongo
Norsk
Norwegian
Occitan
Polish
Polski
Rumanian
Russian
Russki
Serbian
Serbski
Slovak
Slovene
Slovenian
Sqhip
Suomi
Svenska
Swedish
Thai
Turkish
Welsh
Yiddish
2 changes: 1 addition & 1 deletion cpan/version/t/08_corelist.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#########################

use Test::More tests => 3;
use_ok("version", 0.9930);
use_ok("version", 0.9933);

# do strict lax tests in a sub to isolate a package to test importing
SKIP: {
Expand Down
2 changes: 1 addition & 1 deletion cpan/version/t/09_list_util.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#########################

use strict;
use_ok("version", 0.9930);
use_ok("version", 0.9933);
use Test::More;

BEGIN {
Expand Down
17 changes: 17 additions & 0 deletions cpan/version/t/coretests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ sub BaseTests {
$version = $CLASS->$method("v1.2.3_4");
is ( "$version" , "v1.2.3_4" , 'alpha version 1.2.3_4 eq v1.2.3_4' );

my $version = $CLASS->$method("v1.2.3.4");
is_deeply ([ $version->tuple ], [1, 2, 3, 4], 'Tuple seems to work');
is_deeply ($version, $CLASS->from_tuple(1, 2, 3, 4), 'Equals from_tuple');

# test illegal formats
eval {my $version = $CLASS->$method("1.2_3_4")};
like($@, qr/multiple underscores/,
Expand Down Expand Up @@ -633,6 +637,19 @@ SKIP: {
$v = $CLASS->new("1.02_003");
is $v->numify, '1.020030', 'Ignore underscores for numify';
}

{
$v = $CLASS->parse("v1.2.3");
$v2 = $v->to_decimal;
isa_ok $v2, $CLASS;
is $v2, "1.002003";
}
{
$v = $CLASS->parse("1.002003");
$v2 = $v->to_dotted_decimal;
isa_ok $v2, $CLASS;
is "$v2", "v1.2.3";
}
}

1;
Expand Down
10 changes: 5 additions & 5 deletions vutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ Perl_new_version(pTHX_ SV *ver)
if(svp)
(void)hv_stores(MUTABLE_HV(hv), "original", newSVsv(*svp));
}
sav = AV_FROM_REF(*hv_fetchs(MUTABLE_HV(ver), "version", FALSE));
sav = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(ver), "version", FALSE)));
/* This will get reblessed later if a derived class*/
for ( key = 0; key <= av_len(sav); key++ )
{
Expand Down Expand Up @@ -994,7 +994,7 @@ Perl_vnumify(pTHX_ SV *vs)
}

/* attempt to retrieve the version array */
if ( !(av = AV_FROM_REF(*hv_fetchs(MUTABLE_HV(vs), "version", FALSE)) ) ) {
if ( !(av = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(vs), "version", FALSE))) ) ) {
return newSVpvs("0");
}

Expand Down Expand Up @@ -1056,7 +1056,7 @@ Perl_vnormal(pTHX_ SV *vs)
if ( ! vs )
Perl_croak(aTHX_ "Invalid version object");

av = AV_FROM_REF(*hv_fetchs(MUTABLE_HV(vs), "version", FALSE));
av = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(vs), "version", FALSE)));

len = av_len(av);
if ( len == -1 )
Expand Down Expand Up @@ -1161,10 +1161,10 @@ Perl_vcmp(pTHX_ SV *lhv, SV *rhv)
Perl_croak(aTHX_ "Invalid version object");

/* get the left hand term */
lav = AV_FROM_REF(*hv_fetchs(MUTABLE_HV(lhv), "version", FALSE));
lav = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(lhv), "version", FALSE)));

/* and the right hand term */
rav = AV_FROM_REF(*hv_fetchs(MUTABLE_HV(rhv), "version", FALSE));
rav = MUTABLE_AV(SvRV(*hv_fetchs(MUTABLE_HV(rhv), "version", FALSE)));

l = av_len(lav);
r = av_len(rav);
Expand Down
Loading

0 comments on commit 5bde80d

Please sign in to comment.