On Sun Nov 23 16:12:03 2014, SPROUT wrote:
Show quoted text> Try the new attachment.
Or, better yet, check CVf_CONST, since perl 5.8 doesn’t have CVf_ISXSUB. Plus fix some problems with the previous patch.
Attached again.
diff -rup Constant-Export-Lazy-0.10-HGlkJq-orig/Makefile.PL Constant-Export-Lazy-0.10-HGlkJq/Makefile.PL
--- Constant-Export-Lazy-0.10-HGlkJq-orig/Makefile.PL 2014-11-05 02:44:35.000000000 -0800
+++ Constant-Export-Lazy-0.10-HGlkJq/Makefile.PL 2014-11-05 16:48:35.000000000 -0800
@@ -25,9 +25,6 @@ my %WriteMakefileArgs = (
"constant" => 0,
"lib" => 0
},
- "TEST_REQUIRES" => {
- "Data::Dump::Streamer" => 0
- },
"VERSION" => "0.10",
"test" => {
"TESTS" => "t/*.t"
diff -rup Constant-Export-Lazy-0.10-HGlkJq-orig/t/actually_constant.t Constant-Export-Lazy-0.10-HGlkJq/t/actually_constant.t
--- Constant-Export-Lazy-0.10-HGlkJq-orig/t/actually_constant.t 2014-11-05 02:44:35.000000000 -0800
+++ Constant-Export-Lazy-0.10-HGlkJq/t/actually_constant.t 2014-11-05 16:53:52.000000000 -0800
@@ -5,10 +5,10 @@ use Constant::Export::Lazy (
constants => {
TRUE => sub { 1 },
FALSE => sub { 0 },
- ARRAY => sub { [qw/what like out/] },
+ ARRAY => sub { [qw/what sub/] },
HASH => sub {
+{
- fmt => "The output from dumping the <%s> constant should match <%s>, full output is <%s>",
+ fmt => "The <%s> constant is CONST",
out => "We shouldn't even have this in the syntax tree on -MO=Deparse",
},
},
@@ -25,62 +25,32 @@ BEGIN {
));
}
use Test::More 'no_plan';
-use Data::Dump::Streamer;
-# Maybe I'll want this later, but Data::Dump::Streamer is in
-# TestRequires now, and I want to see where this actually works.
-#
-# BEGIN {
-# eval {
-# require Data::Dump::Streamer;
-# Data::Dump::Streamer->import;
-# 1;
-# } or do {
-# my $error = $@ || "Zombie Error";
-# Test::More->import(skip_all => "We don't have Data::Dump::Streamer here, got <$error> trying to load it");
-# };
-# Test::More->import('no_plan');
-# };
+use B 'svref_2object', 'CVf_CONST';
my @tests = (
{
what => 'TRUE',
- out => "" . Dump(\&TRUE)->Out,
- like => do {
- #use re 'debug';
- qr/^\$CODE1 = \\&Constant::Export::Lazy::Ctx::__ANON__;$/s;
- },
+ sub => \&TRUE,
},
{
what => 'FALSE',
- out => "" . Dump(\&FALSE)->Out,
- like => do {
- #use re 'debug';
- qr/^\$CODE1 = \\&Constant::Export::Lazy::Ctx::__ANON__;$/s;
- },
+ sub => \&FALSE,
},
{
what => 'ARRAY',
- out => "" . Dump(\&ARRAY)->Out,
- like => do {
- #use re 'debug';
- qr/^\$CODE1 = \\&Constant::Export::Lazy::Ctx::__ANON__;$/s;
- },
+ sub => \&ARRAY,
},
{
what => 'HASH',
- out => "" . Dump(\&HASH)->Out,
- like => do {
- #use re 'debug';
- qr/^\$CODE1 = \\&Constant::Export::Lazy::Ctx::__ANON__;$/s;
- },
+ sub => \&HASH,
},
);
if (TRUE) {
for my $test (@tests) {
- my ($what, $like, $out) = @$test{@{ARRAY;}};
- chomp $out;
- like($out, qr/$like/, sprintf HASH->{fmt}, $what, $like, $out);
+ my ($what, $sub) = @$test{@{ARRAY;}};
+ is(svref_2object($test->{sub})->CvFLAGS & CVf_CONST, CVf_CONST,
+ sprintf HASH->{fmt}, $what);
}
} else {
fail(HASH->{out});
diff -rup Constant-Export-Lazy-0.10-AHCLxP-orig/t/actually_constant_deparse.t Constant-Export-Lazy-0.10-AHCLxP/t/actually_constant_deparse.t
--- Constant-Export-Lazy-0.10-AHCLxP-orig/t/actually_constant_deparse.t 2014-11-05 02:44:35.000000000 -0800
+++ Constant-Export-Lazy-0.10-AHCLxP/t/actually_constant_deparse.t 2014-11-23 13:23:52.000000000 -0800
@@ -8,5 +8,5 @@ chomp(my $output = qx[$^X -I"$Bin/../lib
ok($output, "The deparse output we got was: $output");
like($output, qr/use Constant::Export::Lazy/, "Is this thing on?");
unlike($output, qr/\bARRAY;/, "Our output should have the ARRAY; call optimized out");
-like($output, qr/'what', 'like', 'out'/, "That ARRAY; call should be inlined");
+like($output, qr/'what', 'sub'/, "That ARRAY; call should be inlined");
unlike($output, qr/\bfail\b/, "Our output should have the fail() call optimized out");