Subject: | missing do FILE support |
Compile-time do FILE suffers from the same bug (perl #68590) as compile-time require on perls < 5.11.0 (tested on 5.8.9). Test case attached.
Ubuntu 12.04
Perl 5.8.9
Lexical::SealRequireHints 0.007
Thanks,
chocolateboy.
Subject: | 0001-add-do-FILE-test-case-fails-on-perl-5.11.0.patch |
From ff16ec7a7b457e259ac3c33b3c9cde835f66fda2 Mon Sep 17 00:00:00 2001
From: chocolateboy <chocolate@cpan.org>
Date: Mon, 6 May 2013 21:18:05 +0100
Subject: [PATCH] add do FILE test case (fails on perl < 5.11.0)
---
t/do_file.t | 38 ++++++++++++++++++++++++++++++++++++++
t/do_file_1.pm | 14 ++++++++++++++
t/do_file_2.pm | 14 ++++++++++++++
3 files changed, 66 insertions(+)
create mode 100644 t/do_file.t
create mode 100644 t/do_file_1.pm
create mode 100644 t/do_file_2.pm
diff --git a/t/do_file.t b/t/do_file.t
new file mode 100644
index 0000000..0c9c9d6
--- /dev/null
+++ b/t/do_file.t
@@ -0,0 +1,38 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use File::Spec;
+use Lexical::SealRequireHints;
+use Test::More tests => 3;
+
+{
+ BEGIN {
+ $^H |= 0x20000;
+ $^H{'Lexical::SealRequireHints::Test'} = 1;
+ }
+
+ BEGIN {
+ my $file = File::Spec->catfile('t', 'do_file_1.pm');
+ do $file;
+ }
+
+ BEGIN {
+ is($^H{'Lexical::SealRequireHints::Test'}, 1, "compile-time do FILE doesn't clobber %^H");
+ }
+
+ ok(do_file_1::test(), 'compile-time do FILE');
+}
+
+{
+ BEGIN {
+ $^H |= 0x20000;
+ $^H{'Lexical::SealRequireHints::Test'} = 1;
+ }
+
+ my $file = File::Spec->catfile('t', 'do_file_2.pm');
+ do $file;
+
+ ok(do_file_2::test(), 'runtime do FILE');
+}
diff --git a/t/do_file_1.pm b/t/do_file_1.pm
new file mode 100644
index 0000000..4f52905
--- /dev/null
+++ b/t/do_file_1.pm
@@ -0,0 +1,14 @@
+package do_file_1;
+
+use strict;
+use warnings;
+
+our $test;
+
+# 0 for failure if the key has leaked
+# 1 for success if it hasn't
+BEGIN { $test = exists($^H{'Lexical::SealRequireHints::Test'}) ? 0 : 1 }
+
+sub test() { $test }
+
+1;
diff --git a/t/do_file_2.pm b/t/do_file_2.pm
new file mode 100644
index 0000000..bc1be1c
--- /dev/null
+++ b/t/do_file_2.pm
@@ -0,0 +1,14 @@
+package do_file_2;
+
+use strict;
+use warnings;
+
+our $test;
+
+# 0 for failure if the key has leaked
+# 1 for success if it hasn't
+BEGIN { $test = exists($^H{'Lexical::SealRequireHints::Test'}) ? 0 : 1 }
+
+sub test() { $test }
+
+1;
--
1.7.9.5