diff options
author | David Golden <dagolden@cpan.org> | 2012-02-05 22:20:03 -0500 |
---|---|---|
committer | David Golden <dagolden@cpan.org> | 2012-02-05 22:20:03 -0500 |
commit | 8c72d15656ec9706955ec6a368ddeb493db7cc58 (patch) | |
tree | b7f901292a74a4308e90ac76f8a1d7cc6768a36f | |
parent | e67589ac03216f614436a2f92e098198c86f6b16 (diff) | |
download | perl-8c72d15656ec9706955ec6a368ddeb493db7cc58.tar.gz |
sync version.pm code with CPAN
Applied patch from John Peacock, but added whitespace fixes,
corrected pod link error and updated known Pod issues to reflect
a fix.
-rw-r--r-- | lib/version.pod | 19 | ||||
-rw-r--r-- | lib/version/t/07locale.t | 15 | ||||
-rw-r--r-- | t/porting/known_pod_issues.dat | 2 | ||||
-rw-r--r-- | util.c | 2 |
4 files changed, 20 insertions, 18 deletions
diff --git a/lib/version.pod b/lib/version.pod index fcaf5d6acc..f4328f5439 100644 --- a/lib/version.pod +++ b/lib/version.pod @@ -11,15 +11,15 @@ version - Perl extension for Version Objects # Declaring a dotted-decimal $VERSION (keep on one line!) - use version 0.77; our $VERSION = version->declare("v1.2.3"); # formal - use version 0.77; our $VERSION = qv("v1.2.3"); # shorthand - use version 0.77; our $VERSION = qv("v1.2_3"); # alpha + 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 # Declaring an old-style decimal $VERSION (use quotes!) our $VERSION = "1.0203"; # recommended - use version 0.77; our $VERSION = version->parse("1.0203"); # formal - use version 0.77; our $VERSION = version->parse("1.02_03"); # alpha + use version; our $VERSION = version->parse("1.0203"); # formal + use version; our $VERSION = version->parse("1.02_03"); # alpha # Comparing mixed version styles (decimals, dotted-decimals, objects) @@ -60,9 +60,10 @@ source file. Quoting is recommended, as it ensures that trailing zeroes The more modern form of version assignment, with 3 (or potentially more) integers separated by decimal points (e.g. v1.2.3). This is the form that -Perl itself has used since 5.6.0 was released. The leading "v" is now +Perl itself has used since 5.6.0 was released. The leading 'v' is now strongly recommended for clarity, and will throw a warning in a future -release if omitted. +release if omitted. A leading 'v' character is required to pass the +L</is_strict()> test. =back @@ -95,7 +96,7 @@ Then increment any of the dotted-decimal components (v1.20.1 or v1.21.0). =head2 How to C<declare()> a dotted-decimal version - use version 0.77; our $VERSION = version->declare("v1.2.3"); + use version; our $VERSION = version->declare("v1.2.3"); The C<declare()> method always creates dotted-decimal version objects. When used in a module, you B<must> put it on the same line as "use version" to @@ -194,7 +195,7 @@ for dotted-decimal formats strings: =item C<is_strict()> -If you want to limit youself to a much more narrow definition of what +If you want to limit yourself to a much more narrow definition of what a version string constitutes, C<is_strict()> is limited to version strings like the following list: diff --git a/lib/version/t/07locale.t b/lib/version/t/07locale.t index 616eba4feb..e5b0a8172c 100644 --- a/lib/version/t/07locale.t +++ b/lib/version/t/07locale.t @@ -7,33 +7,34 @@ use File::Basename; use File::Temp qw/tempfile/; use POSIX qw/locale_h/; -use Test::More qw/no_plan/; +use Test::More tests => 7; BEGIN { use_ok('version', 0.96); } SKIP: { + skip 'No locale testing for Perl < 5.6.0', 6 if $] < 5.006; # test locale handling my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; - my $v = eval { version->new('1,7') }; -# is( $@, "", 'Directly test comma as decimal compliance'); - my $ver = 1.23; # has to be floating point number - my $orig_loc = setlocale( LC_ALL ); my $loc; + my $orig_loc = setlocale(LC_NUMERIC); + is ($ver, '1.23', 'Not using locale yet'); while (<DATA>) { chomp; $loc = setlocale( LC_ALL, $_); last if localeconv()->{decimal_point} eq ','; } - skip 'Cannot test locale handling without a comma locale', 4 - unless ( $loc and ($ver eq '1,23') ); + skip 'Cannot test locale handling without a comma locale', 5 + unless $loc; diag ("Testing locale handling with $loc") unless $ENV{PERL_CORE}; + setlocale(LC_NUMERIC, $loc); + is ($ver, '1,23', "Using locale: $loc"); $v = version->new($ver); unlike($warning, qr/Version string '1,23' contains invalid data/, "Process locale-dependent floating point"); diff --git a/t/porting/known_pod_issues.dat b/t/porting/known_pod_issues.dat index a036c380a5..b1167c01cc 100644 --- a/t/porting/known_pod_issues.dat +++ b/t/porting/known_pod_issues.dat @@ -337,6 +337,6 @@ lib/tie/array.pm Verbatim line length including indents exceeds 79 by 1 lib/tie/hash.pm Verbatim line length including indents exceeds 79 by 3 lib/tie/scalar.pm Verbatim line length including indents exceeds 79 by 1 lib/utf8.pm Verbatim line length including indents exceeds 79 by 4 -lib/version.pod Verbatim line length including indents exceeds 79 by 2 +lib/version.pod Verbatim line length including indents exceeds 79 by 1 lib/version/internals.pod Verbatim line length including indents exceeds 79 by 2 lib/vmsish.pm Verbatim line length including indents exceeds 79 by 1 @@ -4549,7 +4549,7 @@ dotted_decimal_version: /* and we never support negative versions */ if ( *d == '-') { - BADVERSION(s,errstr,"Invalid version format (negative version number)"); + BADVERSION(s,errstr,"Invalid version format (negative version number)"); } /* consume all of the integer part */ |