diff options
author | Nicholas Clark <nick@ccl4.org> | 2012-02-28 13:49:18 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2012-03-19 10:21:53 +0100 |
commit | a6087f241d4f8df274ed95db66813909e8eba7cc (patch) | |
tree | 60ccfa295652eb2b3885ba6a223da29abd148919 /dist/B-Deparse | |
parent | c4a350e6709d60f02654f36bb02d403e6763ecc1 (diff) | |
download | perl-a6087f241d4f8df274ed95db66813909e8eba7cc.tar.gz |
Add a 'context' feature to deparse.t, to better test ambient pragmas.
Call ambient_pragmas() before each deparse test. This will allow use to remove
the constraints of the current default, which is to always run under
use feature ":5.10";
Diffstat (limited to 'dist/B-Deparse')
-rw-r--r-- | dist/B-Deparse/t/deparse.t | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t index 5b9ab14064..f606479b92 100644 --- a/dist/B-Deparse/t/deparse.t +++ b/dist/B-Deparse/t/deparse.t @@ -26,25 +26,14 @@ use B::Deparse; my $deparse = B::Deparse->new(); isa_ok($deparse, 'B::Deparse', 'instantiate a B::Deparse object'); -# Tell B::Deparse about our ambient pragmas -{ my ($hint_bits, $warning_bits, $hinthash); - BEGIN { ($hint_bits, $warning_bits, $hinthash) = ($^H, ${^WARNING_BITS}, \%^H); } - $deparse->ambient_pragmas ( - hint_bits => $hint_bits, - warning_bits => $warning_bits, - '%^H' => $hinthash, - ); -} - $/ = "\n####\n"; while (<DATA>) { chomp; $tests ++; # This code is pinched from the t/lib/common.pl for TODO. # It's not clear how to avoid duplication - # Now tweaked a bit to do skip or todo - my %meta; - foreach my $what (qw(skip todo)) { + my %meta = (context => ''); + foreach my $what (qw(skip todo context)) { s/^#\s*\U$what\E\s*(.*)\n//m and $meta{$what} = $1; # If the SKIP reason starts ? then it's taken as a code snippet to # evaluate. This provides the flexibility to have conditional SKIPs @@ -75,7 +64,18 @@ while (<DATA>) { ($input, $expected) = ($_, $_); } - my $coderef = eval "sub {$input}"; + my $coderef = eval "$meta{context};\n" . <<'EOC' . "sub {$input}"; +# Tell B::Deparse about our ambient pragmas +my ($hint_bits, $warning_bits, $hinthash); +BEGIN { + ($hint_bits, $warning_bits, $hinthash) = ($^H, ${^WARNING_BITS}, \%^H); +} +$deparse->ambient_pragmas ( + hint_bits => $hint_bits, + warning_bits => $warning_bits, + '%^H' => $hinthash, +); +EOC if ($@) { is($@, "", "compilation of $desc"); |