Enable bitwise feature with ‘use v5.28’
authorFather Chrysostomos <sprout@cpan.org>
Sun, 31 Dec 2017 20:24:01 +0000 (12:24 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 31 Dec 2017 20:24:01 +0000 (12:24 -0800)
feature.h
lib/feature.pm
regen/feature.pl
t/op/bop.t

index 838d648..0e15fb5 100644 (file)
--- a/feature.h
+++ b/feature.h
@@ -14,6 +14,7 @@
 #define FEATURE_BUNDLE_511     2
 #define FEATURE_BUNDLE_515     3
 #define FEATURE_BUNDLE_523     4
+#define FEATURE_BUNDLE_527     5
 #define FEATURE_BUNDLE_CUSTOM  (HINT_FEATURE_MASK >> HINT_FEATURE_SHIFT)
 
 #define CURRENT_HINTS \
@@ -33,7 +34,7 @@
 #define FEATURE_FC_IS_ENABLED \
     ( \
        (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
-        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
+        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
         FEATURE_IS_ENABLED("fc")) \
     )
@@ -41,7 +42,7 @@
 #define FEATURE_SAY_IS_ENABLED \
     ( \
        (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
-        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
+        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
         FEATURE_IS_ENABLED("say")) \
     )
@@ -49,7 +50,7 @@
 #define FEATURE_STATE_IS_ENABLED \
     ( \
        (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
-        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
+        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
         FEATURE_IS_ENABLED("state")) \
     )
 #define FEATURE_SWITCH_IS_ENABLED \
     ( \
        (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_510 && \
-        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
+        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
         FEATURE_IS_ENABLED("switch")) \
     )
 
 #define FEATURE_BITWISE_IS_ENABLED \
     ( \
-       CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
-        FEATURE_IS_ENABLED("bitwise") \
+       CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_527 \
+     || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
+        FEATURE_IS_ENABLED("bitwise")) \
     )
 
 #define FEATURE_EVALBYTES_IS_ENABLED \
     ( \
        (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
-        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
+        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
         FEATURE_IS_ENABLED("evalbytes")) \
     )
@@ -92,7 +94,7 @@
 #define FEATURE___SUB___IS_ENABLED \
     ( \
        (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
-        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
+        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
         FEATURE_IS_ENABLED("__SUB__")) \
     )
 
 #define FEATURE_POSTDEREF_QQ_IS_ENABLED \
     ( \
-       CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_523 \
+       (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_523 && \
+        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
         FEATURE_IS_ENABLED("postderef_qq")) \
     )
 #define FEATURE_UNIEVAL_IS_ENABLED \
     ( \
        (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_515 && \
-        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
+        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
         FEATURE_IS_ENABLED("unieval")) \
     )
 #define FEATURE_UNICODE_IS_ENABLED \
     ( \
        (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_511 && \
-        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_523) \
+        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527) \
      || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
         FEATURE_IS_ENABLED("unicode")) \
     )
@@ -142,6 +145,9 @@ S_enable_feature_bundle(pTHX_ SV *ver)
     SV *comp_ver = sv_newmortal();
     PL_hints = (PL_hints &~ HINT_FEATURE_MASK)
             | (
+                 (sv_setnv(comp_ver, 5.027),
+                  vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
+                       ? FEATURE_BUNDLE_527 :
                  (sv_setnv(comp_ver, 5.023),
                   vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
                        ? FEATURE_BUNDLE_523 :
index 70df619..1ea74eb 100644 (file)
@@ -29,6 +29,7 @@ our %feature_bundle = (
     "5.11"    => [qw(array_base say state switch unicode_strings)],
     "5.15"    => [qw(current_sub evalbytes fc say state switch unicode_eval unicode_strings)],
     "5.23"    => [qw(current_sub evalbytes fc postderef_qq say state switch unicode_eval unicode_strings)],
+    "5.27"    => [qw(bitwise current_sub evalbytes fc postderef_qq say state switch unicode_eval unicode_strings)],
     "all"     => [qw(array_base bitwise current_sub declared_refs evalbytes fc postderef_qq refaliasing say signatures state switch unicode_eval unicode_strings)],
     "default" => [qw(array_base)],
 );
@@ -46,8 +47,7 @@ $feature_bundle{"5.22"} = $feature_bundle{"5.15"};
 $feature_bundle{"5.24"} = $feature_bundle{"5.23"};
 $feature_bundle{"5.25"} = $feature_bundle{"5.23"};
 $feature_bundle{"5.26"} = $feature_bundle{"5.23"};
-$feature_bundle{"5.27"} = $feature_bundle{"5.23"};
-$feature_bundle{"5.28"} = $feature_bundle{"5.23"};
+$feature_bundle{"5.28"} = $feature_bundle{"5.27"};
 $feature_bundle{"5.9.5"} = $feature_bundle{"5.10"};
 my %noops = (
     postderef => 1,
@@ -56,7 +56,7 @@ my %noops = (
 
 our $hint_shift   = 26;
 our $hint_mask    = 0x1c000000;
-our @hint_bundles = qw( default 5.10 5.11 5.15 5.23 );
+our @hint_bundles = qw( default 5.10 5.11 5.15 5.23 5.27 );
 
 # This gets set (for now) in $^H as well as in %^H,
 # for runtime speed of the uc/lc/ucfirst/lcfirst functions.
@@ -390,7 +390,7 @@ The following feature bundles are available:
 
   :5.28     say state switch unicode_strings
             unicode_eval evalbytes current_sub fc
-            postderef_qq
+            postderef_qq bitwise
 
 The C<:default> bundle represents the feature set that is enabled before
 any C<use feature> or C<no feature> declaration.
index 3ce2a6d..4005144 100755 (executable)
@@ -63,7 +63,7 @@ my %feature_bundle = (
     "5.25"   =>        [qw(say state switch unicode_strings unicode_eval
                    evalbytes current_sub fc postderef_qq)],
     "5.27"   =>        [qw(say state switch unicode_strings unicode_eval
-                   evalbytes current_sub fc postderef_qq)],
+                   evalbytes current_sub fc postderef_qq bitwise)],
 );
 
 my @noops = qw( postderef lexical_subs );
index c1be588..7b77500 100644 (file)
@@ -18,7 +18,7 @@ BEGIN {
 # If you find tests are failing, please try adding names to tests to track
 # down where the failure is, and supply your new names as a patch.
 # (Just-in-time test naming)
-plan tests => 477;
+plan tests => 491;
 
 # numerics
 ok ((0xdead & 0xbeef) == 0x9ead);
@@ -355,6 +355,38 @@ SKIP: {
  ok (($cusp >> 1) == ($cusp / 2) &&
     do { use integer; abs($cusp >> 1) } == ($cusp / 2));
 }
+# Repeat some of those, with 'use v5.27'
+{
+  use v5.27;
+
+  is "22" & "66", 2,    'numeric & with strings';
+  is "22" | "66", 86,   'numeric | with strings';
+  is "22" ^ "66", 84,   'numeric ^ with strings';
+  is ~"22" & 0xff, 233, 'numeric ~ with string';
+  is 22 &. 66, 22,     '&. with numbers';
+  is 22 |. 66, 66,     '|. with numbers';
+  is 22 ^. 66, "\4\4", '^. with numbers';
+  if ($::IS_EBCDIC) {
+    # ord('2') is 0xF2 on EBCDIC
+    is ~.22, "\x0d\x0d", '~. with number';
+  }
+  else {
+    # ord('2') is 0x32 on ASCII
+    is ~.22, "\xcd\xcd", '~. with number';
+  }
+  $_ = "22";
+  is $_ &= "66", 2,  'numeric &= with strings';
+  $_ = "22";
+  is $_ |= "66", 86, 'numeric |= with strings';
+  $_ = "22";
+  is $_ ^= "66", 84, 'numeric ^= with strings';
+  $_ = 22;
+  is $_ &.= 66, 22,     '&.= with numbers';
+  $_ = 22;
+  is $_ |.= 66, 66,     '|.= with numbers';
+  $_ = 22;
+  is $_ ^.= 66, "\4\4", '^.= with numbers';
+}
 
 # ref tests