[libmoo-perl] 08/43: track hints when clearing them in test

gregor herrmann gregoa at debian.org
Mon Dec 26 17:56:13 UTC 2016


This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to branch master
in repository libmoo-perl.

commit e9e238c4f8f10606633c40572ee584108daddc2e
Author: Graham Knop <haarg at haarg.org>
Date:   Mon Sep 19 18:52:52 2016 -0400

    track hints when clearing them in test
    
    In perl 5.10, it isn't possible to clear out open> or open< entries from
    %^H if perl is run with -C or PERL_UNICODE.  Instead of assuming we
    cleared it out, check what %^H contains after clearing it.
---
 t/sub-quote.t | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/t/sub-quote.t b/t/sub-quote.t
index 1fe7815..4da5598 100644
--- a/t/sub-quote.t
+++ b/t/sub-quote.t
@@ -1,3 +1,15 @@
+BEGIN {
+  %^H = ();
+  my %clear_hints = sub { %{(caller(0))[10]||{}} }->();
+  $INC{'ClearHintsHash.pm'} = __FILE__;
+  package ClearHintsHash;
+  sub hints { %clear_hints }
+  sub import {
+    $^H |= 0x020000;
+    %^H = hints;
+  }
+}
+
 use Moo::_strictures;
 use Test::More;
 use Test::Fatal;
@@ -209,10 +221,7 @@ BEGIN {
 {
   my %hints;
   {
-    BEGIN {
-      $^H |= 0x020000;
-      %^H = ();
-    }
+    use ClearHintsHash;
     use UseHintHash;
     BEGIN { %hints = %^H }
   }
@@ -221,10 +230,7 @@ BEGIN {
     local $TODO = 'hints hash from context not available on perl 5.8'
       if "$]" < 5.010_000;
 
-    BEGIN {
-      $^H |= 0x020000;
-      %^H = ();
-    }
+    use ClearHintsHash;
     use UseHintHash;
     is_deeply quote_sub(q{
       our %temp_hints_hash;
@@ -243,7 +249,7 @@ BEGIN {
 }
 
 {
-  BEGIN { %^H = () }
+  use ClearHintsHash;
   my $sub = quote_sub(q{
     our %temp_hints_hash;
     BEGIN { %temp_hints_hash = %^H }
@@ -254,7 +260,8 @@ BEGIN {
     my (undef, $code, $cap) = @{quoted_from_sub($sub)};
     quote_sub $code, $cap||();
   };
-  is_deeply $wrap_sub->(), {}, 'empty hints maintained when inlined';
+  is_deeply $wrap_sub->(), { ClearHintsHash::hints },
+    'empty hints maintained when inlined';
 }
 
 BEGIN {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmoo-perl.git



More information about the Pkg-perl-cvs-commits mailing list