From: Steffen Müller <0mgwtfbbq@sneakemail.com> Date: Sun, 13 Jan 2008 22:45:37 +0000 (+0100) Subject: feature bundles are the same across all subversions X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=82cfb3a2c3500989056cbc46cb030c206fcb3602;p=p5sagit%2Fp5-mst-13.2.git feature bundles are the same across all subversions Message-ID: <20080113214537.13226.qmail@lists.develooper.com> p4raw-id: //depot/perl@33247 --- diff --git a/MANIFEST b/MANIFEST index a49b81b..f664896 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3548,6 +3548,7 @@ t/lib/dprof/test8_t Perl code profiler tests t/lib/dprof/test8_v Perl code profiler tests t/lib/dprof/V.pm Perl code profiler tests t/lib/Dummy.pm Module for testing base.pm +t/lib/feature/bundle Tests for feature bundles t/lib/feature/implicit Tests for implicit loading of feature.pm t/lib/feature/nonesuch Tests for enabling/disabling nonexistent feature t/lib/feature/say Tests for enabling/disabling say feature diff --git a/lib/feature.pm b/lib/feature.pm index f4e2ef8..915b5c7 100644 --- a/lib/feature.pm +++ b/lib/feature.pm @@ -1,6 +1,6 @@ package feature; -our $VERSION = '1.12'; +our $VERSION = '1.13'; # (feature name) => (internal name, used in %^H) my %feature = ( @@ -12,15 +12,12 @@ my %feature = ( # NB. the latest bundle must be loaded by the -E switch (see toke.c) my %feature_bundle = ( - "5.10.0" => [qw(switch say state)], - "5.11.0" => [qw(switch say state)], + "5.10" => [qw(switch say state)], + "5.11" => [qw(switch say state)], ); -# latest version here -$feature_bundle{"5.11"} = $feature_bundle{sprintf("%vd",$^V)}; - -$feature_bundle{"5.10"} = $feature_bundle{"5.10.0"}; -$feature_bundle{"5.9.5"} = $feature_bundle{"5.10.0"}; +# special case +$feature_bundle{"5.9.5"} = $feature_bundle{"5.10"}; # TODO: # - think about versioned features (use feature switch => 2) @@ -103,11 +100,11 @@ See L for details. It's possible to load a whole slew of features in one go, using a I. The name of a feature bundle is prefixed with a colon, to distinguish it from an actual feature. At present, the -only feature bundles are C and C, -which both are equivalent to C. +only feature bundle is C which is equivalent +to C. -In the forthcoming 5.10.X perl releases, C will be -equivalent to the latest C. +Specifying sub-versions such as the C<0> in C<5.10.0> in feature bundles has +no effect: feature bundles are guaranteed to be the same for all sub-versions. =head1 IMPLICIT LOADING @@ -130,9 +127,10 @@ the C construct, and when the version is higher than or equal to will do an implicit - use feature ':5.10.0'; + use feature ':5.10'; -and so on. +and so on. Note how the trailing sub-version is automatically stripped from the +version. But to avoid portability warnings (see L), you may prefer: @@ -154,7 +152,10 @@ sub import { if (substr($name, 0, 1) eq ":") { my $v = substr($name, 1); if (!exists $feature_bundle{$v}) { - unknown_feature_bundle($v); + $v =~ s/^([0-9]+)\.([0-9]+).[0-9]+$/$1.$2/; + if (!exists $feature_bundle{$v}) { + unknown_feature_bundle(substr($name, 1)); + } } unshift @_, @{$feature_bundle{$v}}; next; @@ -180,7 +181,10 @@ sub unimport { if (substr($name, 0, 1) eq ":") { my $v = substr($name, 1); if (!exists $feature_bundle{$v}) { - unknown_feature_bundle($v); + $v =~ s/^([0-9]+)\.([0-9]+).[0-9]+$/$1.$2/; + if (!exists $feature_bundle{$v}) { + unknown_feature_bundle(substr($name, 1)); + } } unshift @_, @{$feature_bundle{$v}}; next; diff --git a/t/lib/feature/bundle b/t/lib/feature/bundle new file mode 100644 index 0000000..a869c75 --- /dev/null +++ b/t/lib/feature/bundle @@ -0,0 +1,50 @@ +Check feature bundles. + +__END__ +# Standard feature bundle +use feature ":5.10"; +say "Hello", "world"; +EXPECT +Helloworld +######## +# more specific: 5.10.0 maps to 5.10 +use feature ":5.10.0"; +say "Hello", "world"; +EXPECT +Helloworld +######## +# as does 5.10.1 +use feature ":5.10.1"; +say "Hello", "world"; +EXPECT +Helloworld +######## +# as does 5.10.99 +use feature ":5.10.99"; +say "Hello", "world"; +EXPECT +Helloworld +######## +# 5.9.5 also supported +use feature ":5.9.5"; +say "Hello", "world"; +EXPECT +Helloworld +######## +# 5.9 not supported +use feature ":5.9"; +EXPECT +OPTIONS regex +^Feature bundle "5.9" is not supported by Perl \d+\.\d+\.\d+ at - line \d+ +######## +# 5.9.4 not supported +use feature ":5.9.4"; +EXPECT +OPTIONS regex +^Feature bundle "5.9.4" is not supported by Perl \d+\.\d+\.\d+ at - line \d+ +######## +# 5.8.8 not supported +use feature ":5.8.8"; +EXPECT +OPTIONS regex +^Feature bundle "5.8.8" is not supported by Perl \d+\.\d+\.\d+ at - line \d+