diff options
author | David Golden <dagolden@cpan.org> | 2010-01-13 21:47:30 -0500 |
---|---|---|
committer | David Golden <dagolden@cpan.org> | 2010-01-13 22:04:08 -0500 |
commit | 91152fc19d1c59a1213e39f74ac8a80f4a015f5e (patch) | |
tree | 13df618732832e19928bf20a21a4f6dbf7a9bc67 /dist/XSLoader | |
parent | 32709fdf41543f067562e0dc9944448dd11d2c28 (diff) | |
download | perl-91152fc19d1c59a1213e39f74ac8a80f4a015f5e.tar.gz |
Omnibus strict and lax version parsing
Authors: John Peacock, David Golden and Zefram
The goal of this mega-patch is to enforce strict rules for version
numbers provided to 'package NAME VERSION' while formalizing the prior,
lax rules used for version object creation. Parsing for use() is
unchanged.
version.pm adds two globals, $STRICT and $LAX, containing regular
expressions that define the rules. There are two additional functions
-- version::is_strict and version::is_lax -- that test an argument
against these rules.
However, parsing of strings that might contain version numbers is done
in core via the Perl_scan_version function, which may be called during
compilation or may be called later when version objects are created by
Perl_new_version or Perl_upg_version.
A new helper function, Perl_prescan_version, has been added to validate
a string under either strict or lax rules. This is used in toke.c for
'package NAME VERSION' in strict mode and by Perl_scan_version in lax
mode. It matches the behavior of the verison.pm regular expressions,
but does not use them directly.
A new test file, comp/packagev.t, validates strict and lax behaviors of
'package NAME VERSION' and 'version->new(VERSION)' respectively and
verifies their behavior against the $STRICT and $LAX regular
expressions, as well. Validating these two implementation should help
ensure they each work as intended.
Other files and tests have been modified as necessary to support these
changes.
There is remaining work to be done in a few areas:
* documenting all changes in behavior and new functions
* determining proper treatment of "," as decimal separators in
various locales
* updating diagnostics for new error messages
* porting changes back to the version.pm distribution on CPAN,
including pure-Perl versions
Diffstat (limited to 'dist/XSLoader')
-rw-r--r-- | dist/XSLoader/t/XSLoader.t | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/dist/XSLoader/t/XSLoader.t b/dist/XSLoader/t/XSLoader.t index 038986ed4b..211c4d8455 100644 --- a/dist/XSLoader/t/XSLoader.t +++ b/dist/XSLoader/t/XSLoader.t @@ -30,7 +30,7 @@ my %modules = ( 'Time::HiRes'=> q| ::can_ok( 'Time::HiRes' => 'usleep' ) |, # 5.7.3 ); -plan tests => keys(%modules) * 4 + 5; +plan tests => keys(%modules) * 3 + 5; # Try to load the module use_ok( 'XSLoader' ); @@ -65,11 +65,9 @@ for my $module (sort keys %modules) { SKIP: { skip "$module not available", 4 if $extensions !~ /\b$module\b/; - eval qq{ package $module; XSLoader::load('$module', "qunckkk"); }; - like( $@, "/^$module object version \\S+ does not match bootstrap parameter (?:qunckkk|0)/", + eval qq{ package $module; XSLoader::load('$module', "12345678"); }; + like( $@, "/^$module object version \\S+ does not match bootstrap parameter (?:12345678|0)/", "calling XSLoader::load() with a XS module and an incorrect version" ); - like( $warnings, "/^\$|^Version string 'qunckkk' contains invalid data; ignoring: 'qunckkk'/", - "in Perl 5.10, DynaLoader warns about the incorrect version string" ); eval qq{ package $module; XSLoader::load('$module'); }; is( $@, '', "XSLoader::load($module)"); |