Change 33247 by [EMAIL PROTECTED] on 2008/02/08 09:43:16

        Subject: [PATCH] feature bundles are the same across all subversions
        From: Steffen Mueller <[EMAIL PROTECTED]>
        Date: Sun, 13 Jan 2008 22:45:37 +0100
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/MANIFEST#1669 edit
... //depot/perl/lib/feature.pm#26 edit
... //depot/perl/t/lib/feature/bundle#1 add

Differences ...

==== //depot/perl/MANIFEST#1669 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#1668~33237~   2008-02-05 06:00:00.000000000 -0800
+++ perl/MANIFEST       2008-02-08 01:43:16.000000000 -0800
@@ -3548,6 +3548,7 @@
 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

==== //depot/perl/lib/feature.pm#26 (text) ====
Index: perl/lib/feature.pm
--- perl/lib/feature.pm#25~32648~       2007-12-19 05:58:46.000000000 -0800
+++ perl/lib/feature.pm 2008-02-08 01:43:16.000000000 -0800
@@ -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 @@
 # 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 @@
 It's possible to load a whole slew of features in one go, using
 a I<feature bundle>. 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<use feature ":5.10"> and C<use feature ":5.10.0">,
-which both are equivalent to C<use feature qw(switch say state)>.
+only feature bundle is C<use feature ":5.10"> which is equivalent
+to C<use feature qw(switch say state)>.
 
-In the forthcoming 5.10.X perl releases, C<use feature ":5.10"> will be
-equivalent to the latest C<use feature ":5.10.X">.
+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 @@
 
 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<perlfunc/use>), you may prefer:
 
@@ -154,7 +152,10 @@
        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 @@
        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;

==== //depot/perl/t/lib/feature/bundle#1 (text) ====
Index: perl/t/lib/feature/bundle
--- /dev/null   2008-02-07 15:46:55.589080784 -0800
+++ perl/t/lib/feature/bundle   2008-02-08 01:43:16.000000000 -0800
@@ -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+
End of Patch.

Reply via email to