use our own pragma for hints hash test
Graham Knop [Fri, 13 Jun 2014 11:21:06 +0000 (07:21 -0400)]
t/hints.t
t/lib/hint_hash_pragma.pm [new file with mode: 0644]

index f5681b3..1e101b5 100644 (file)
--- a/t/hints.t
+++ b/t/hints.t
@@ -10,6 +10,7 @@ use strictures 1;
 
 use Test::More;
 use Eval::WithLexicals;
+use lib 't/lib';
 
 my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new(prelude => '');
 
@@ -44,13 +45,12 @@ is_deeply(
 );
 
 # Assumption about perl internals: sort pragma will set a key in %^H.
-
-$eval->eval(q{ { use sort 'stable' } }),
-ok !exists $eval->hints->{q{%^H}}->{sort},
+$eval->eval(q{ { use hint_hash_pragma 'param' } }),
+ok !exists $eval->hints->{q{%^H}}->{hint_hash_pragma},
   "Lexical pragma used below main scope not captured";
 
-$eval->eval(q{ use sort 'stable' }),
-ok exists $eval->hints->{q{%^H}}->{sort},
+$eval->eval(q{ use hint_hash_pragma 'param' }),
+is $eval->hints->{q{%^H}}->{hint_hash_pragma}, 'param',
   "Lexical pragma captured";
 
 done_testing;
diff --git a/t/lib/hint_hash_pragma.pm b/t/lib/hint_hash_pragma.pm
new file mode 100644 (file)
index 0000000..98dcf6c
--- /dev/null
@@ -0,0 +1,10 @@
+package hint_hash_pragma;
+use strictures 1;
+
+sub import {
+  my ($class, $val) = @_;
+  $^H |= 0x20000;
+  $^H{hint_hash_pragma} = $val;
+}
+
+1;