Skip Menu |

This queue is for tickets about the Constant-Export-Lazy CPAN distribution.

Report information
The Basics
Id: 95756
Status: resolved
Priority: 0/
Queue: Constant-Export-Lazy

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.07
Fixed in: (no value)



Subject: Consider to not use Data::Dump::Streamer in tests
Data::Dump::Streamer regularly breaks for newer perl versions (i.e. right now it is broken for 5.19.x/5.20.0) and fixing happens usually quite slowly. This means that your module does not get tested for these perl versions (see http://matrix.cpantesters.org/?dist=Constant-Export-Lazy+0.07 , normally there should be a lot of reports for 5.19.x and 5.20.0). Maybe you should do t/actually_constant.t optional, as you already considered (putting things in test_requires does not help here). Or even better, how about rewriting the test to use Data::Dumper, which is a core module and unlikely to break? Regards, Slaven
On 2014-05-18T09:55:30-04:00, SREZIC wrote: Show quoted text
> Data::Dump::Streamer regularly breaks for newer perl versions (i.e. > right now it is broken for 5.19.x/5.20.0) and fixing happens usually > quite slowly. This means that your module does not get tested for > these perl versions (see http://matrix.cpantesters.org/?dist=Constant- > Export-Lazy+0.07 , normally there should be a lot of reports for > 5.19.x and 5.20.0). Maybe you should do t/actually_constant.t > optional, as you already considered (putting things in test_requires > does not help here). Or even better, how about rewriting the test to > use Data::Dumper, which is a core module and unlikely to break?
Thanks for filing this bug, I appreciate it. The reason I added these Data::Dump::Streamer tests is that in the 5.19.* series defining of constant subroutines was actually broken: https://github.com/avar/constant-export-lazy/commit/330e1db5c352a93c682900af7993e084be9b1169#diff-d41d8cd98f00b204e9800998ecf8427e Which I fixed in this perl5.git commit: http://perl5.git.perl.org/perl.git/commitdiff/d3f8a93 So that it's broken for some 5.19.x versions is actually intended, those versions were *broken* with regards to constant subroutines. So I want to keep these tests in the distribution, not having them meant that I noticed this breakage in perl core later than I otherwise would. I.e. this *should* fail: http://www.cpantesters.org/cpan/report/3603fa0f-6c04-1014-a63d-ab0de7db2d7b http://www.cpantesters.org/cpan/report/4e0ef8a5-72ac-1014-8295-f5d73567e6ce But there's a problem with the *implementation* of the test where it fails on some strawberry perl versions due to not being able to invoke an external process: http://www.cpantesters.org/cpan/report/e01db157-6c5d-1014-a1cb-184055012b15 Maybe I'll just make that a TODO test on Win32 if it fails, I'll watch for smoke from this new release to see how it does. But I'm marking this as a wontfix, I'm not removing this test because it's the only test I have for whether this module is actually working as advertised. I *could* use something else than Data::Dump::Streamer which is capable of deparsing the optree though if that's more reliable, patches welcome. But it seems to me that this Just Works now, aside from that obscure Win32 issue which I'll get to fixing in a subsequent release.
On Fri Aug 29 07:27:20 2014, AVAR wrote: Show quoted text
> On 2014-05-18T09:55:30-04:00, SREZIC wrote:
> > Data::Dump::Streamer regularly breaks for newer perl versions (i.e. > > right now it is broken for 5.19.x/5.20.0) and fixing happens usually > > quite slowly. This means that your module does not get tested for > > these perl versions (see > > http://matrix.cpantesters.org/?dist=Constant- > > Export-Lazy+0.07 , normally there should be a lot of reports for > > 5.19.x and 5.20.0). Maybe you should do t/actually_constant.t > > optional, as you already considered (putting things in test_requires > > does not help here). Or even better, how about rewriting the test to > > use Data::Dumper, which is a core module and unlikely to break?
> > Thanks for filing this bug, I appreciate it. The reason I added these > Data::Dump::Streamer tests is that in the 5.19.* series defining of > constant subroutines was actually broken: > > https://github.com/avar/constant-export- > lazy/commit/330e1db5c352a93c682900af7993e084be9b1169#diff- > d41d8cd98f00b204e9800998ecf8427e > > Which I fixed in this perl5.git commit: > > http://perl5.git.perl.org/perl.git/commitdiff/d3f8a93 > > So that it's broken for some 5.19.x versions is actually intended, > those versions were *broken* with regards to constant subroutines. > > So I want to keep these tests in the distribution, not having them > meant that I noticed this breakage in perl core later than I otherwise > would. > > I.e. this *should* fail: > > http://www.cpantesters.org/cpan/report/3603fa0f-6c04-1014-a63d- > ab0de7db2d7b > http://www.cpantesters.org/cpan/report/4e0ef8a5-72ac-1014-8295- > f5d73567e6ce > > But there's a problem with the *implementation* of the test where it > fails on some strawberry perl versions due to not being able to invoke > an external process: > > http://www.cpantesters.org/cpan/report/e01db157-6c5d-1014-a1cb- > 184055012b15 > > Maybe I'll just make that a TODO test on Win32 if it fails, I'll watch > for smoke from this new release to see how it does. > > But I'm marking this as a wontfix, I'm not removing this test because > it's the only test I have for whether this module is actually working > as advertised. I *could* use something else than Data::Dump::Streamer > which is capable of deparsing the optree though if that's more > reliable, patches welcome. > > But it seems to me that this Just Works now, aside from that obscure > Win32 issue which I'll get to fixing in a subsequent release.
You are testing that DDS outputs a code ref, not a sub definition, which it does for XSUBs. That is one heavyweight way of checking for an XSUB! See the attached patch, which uses B instead. If you don’t like the idea, fine, just ignore me. :-)
Subject: open_ZOyu7URL.txt
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 an XSUB", 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_ISXSUB'; 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)->FLAGS & CVf_ISXSUB, CVf_ISXSUB, + sprintf HASH->{fmt}, $what); } } else { fail(HASH->{out});
On 2014-11-05T19:56:22-05:00, SPROUT wrote: Show quoted text
> On Fri Aug 29 07:27:20 2014, AVAR wrote:
> > On 2014-05-18T09:55:30-04:00, SREZIC wrote:
> > > Data::Dump::Streamer regularly breaks for newer perl versions (i.e. > > > right now it is broken for 5.19.x/5.20.0) and fixing happens > > > usually > > > quite slowly. This means that your module does not get tested for > > > these perl versions (see > > > http://matrix.cpantesters.org/?dist=Constant- > > > Export-Lazy+0.07 , normally there should be a lot of reports for > > > 5.19.x and 5.20.0). Maybe you should do t/actually_constant.t > > > optional, as you already considered (putting things in > > > test_requires > > > does not help here). Or even better, how about rewriting the test > > > to > > > use Data::Dumper, which is a core module and unlikely to break?
> > > > Thanks for filing this bug, I appreciate it. The reason I added these > > Data::Dump::Streamer tests is that in the 5.19.* series defining of > > constant subroutines was actually broken: > > > > https://github.com/avar/constant-export- > > lazy/commit/330e1db5c352a93c682900af7993e084be9b1169#diff- > > d41d8cd98f00b204e9800998ecf8427e > > > > Which I fixed in this perl5.git commit: > > > > http://perl5.git.perl.org/perl.git/commitdiff/d3f8a93 > > > > So that it's broken for some 5.19.x versions is actually intended, > > those versions were *broken* with regards to constant subroutines. > > > > So I want to keep these tests in the distribution, not having them > > meant that I noticed this breakage in perl core later than I > > otherwise > > would. > > > > I.e. this *should* fail: > > > > http://www.cpantesters.org/cpan/report/3603fa0f-6c04-1014-a63d- > > ab0de7db2d7b > > http://www.cpantesters.org/cpan/report/4e0ef8a5-72ac-1014-8295- > > f5d73567e6ce > > > > But there's a problem with the *implementation* of the test where it > > fails on some strawberry perl versions due to not being able to > > invoke > > an external process: > > > > http://www.cpantesters.org/cpan/report/e01db157-6c5d-1014-a1cb- > > 184055012b15 > > > > Maybe I'll just make that a TODO test on Win32 if it fails, I'll > > watch > > for smoke from this new release to see how it does. > > > > But I'm marking this as a wontfix, I'm not removing this test because > > it's the only test I have for whether this module is actually working > > as advertised. I *could* use something else than Data::Dump::Streamer > > which is capable of deparsing the optree though if that's more > > reliable, patches welcome. > > > > But it seems to me that this Just Works now, aside from that obscure > > Win32 issue which I'll get to fixing in a subsequent release.
> > You are testing that DDS outputs a code ref, not a sub definition, > which it does for XSUBs. That is one heavyweight way of checking for > an XSUB! > > See the attached patch, which uses B instead. If you don’t like the > idea, fine, just ignore me. :-)
I'd be happy to use something more lightweight. But I don't understand how this tests for what I need to test for. $ perl -MTest::More=no_plan -MB=svref_2object,CVf_ISXSUB -wE 'sub CONST { 123 } is(svref_2object(\&CONST)->FLAGS & CVf_ISXSUB, CVf_ISXSUB, "Is an XSUB")' ok 1 - Is an XSUB 1..1 $ perl -MTest::More=no_plan -MB=svref_2object,CVf_ISXSUB -wE 'sub CONST () { 123 } is(svref_2object(\&CONST)->FLAGS & CVf_ISXSUB, CVf_ISXSUB, "Is an XSUB")' ok 1 - Is an XSUB 1..1 This returns true for both of those sub objects, even though only one is inlined.
On Sun Nov 23 14:16:44 2014, AVAR wrote: Show quoted text
> I'd be happy to use something more lightweight. But I don't understand > how this tests for what I need to test for. > > $ perl -MTest::More=no_plan -MB=svref_2object,CVf_ISXSUB -wE 'sub > CONST { 123 } is(svref_2object(\&CONST)->FLAGS & CVf_ISXSUB, > CVf_ISXSUB, "Is an XSUB")' > ok 1 - Is an XSUB > 1..1 > $ perl -MTest::More=no_plan -MB=svref_2object,CVf_ISXSUB -wE 'sub > CONST () { 123 } is(svref_2object(\&CONST)->FLAGS & CVf_ISXSUB, > CVf_ISXSUB, "Is an XSUB")' > ok 1 - Is an XSUB > 1..1 > > This returns true for both of those sub objects, even though only one > is inlined.
Oops. I used FLAGS instead of CvFLAGS. $ ./perl -Ilib -MTest::More=no_plan -MB=svref_2object,CVf_ISXSUB -wE 'sub CONST { 123 } is(svref_2object(\&CONST)->CvFLAGS & CVf_ISXSUB, CVf_ISXSUB, "Is an XSUB")' not ok 1 - Is an XSUB # Failed test 'Is an XSUB' # at -e line 1. # got: '0' # expected: '8' 1..1 # Looks like you failed 1 test of 1. $ ./perl -Ilib -MTest::More=no_plan -MB=svref_2object,CVf_ISXSUB -wE 'sub CONST () { 123 } is(svref_2object(\&CONST)->CvFLAGS & CVf_ISXSUB, CVf_ISXSUB, "Is an XSUB")' ok 1 - Is an XSUB 1..1 Try the new attachment.
Subject: new patch.txt
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 an XSUB", 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_ISXSUB'; 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)->CvFLAGS & CVf_ISXSUB, CVf_ISXSUB, + sprintf HASH->{fmt}, $what); } } else { fail(HASH->{out});
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.
Subject: newer patch.txt
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");
On 2014-11-23T16:26:27-05:00, SPROUT wrote: Show quoted text
> On Sun Nov 23 16:12:03 2014, SPROUT wrote:
> > 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.
No need to keep re-sending me the full patch, if you can just provide an example of testing for a constant sub with B that's enough. But it doesn't look like CVf_CONST works either: $ /usr/bin/perl -MData::Dumper -MB=svref_2object,CVf_CONST -wE '$Data::Dumper::Sortkeys = 1; sub CONST () { 123 } my $flags = svref_2object(\&CONST)->FLAGS; say Dumper {v => $], flags => $flags, "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const => ($flags & CVf_CONST == CVf_CONST)} if CONST' $VAR1 = { 'CVf_CONST' => 4, 'FC_is_const' => 1, 'flags' => 17421, 'flags&' => 4, 'v' => '5.020001' }; $ /usr/bin/perl -MData::Dumper -MB=svref_2object,CVf_CONST -wE '$Data::Dumper::Sortkeys = 1; sub CONST { 123 } my $flags = svref_2object(\&CONST)->FLAGS; say Dumper {v => $], flags => $flags, "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const => ($flags & CVf_CONST == CVf_CONST)} if CONST' $VAR1 = { 'CVf_CONST' => 4, 'FC_is_const' => 1, 'flags' => 13, 'flags&' => 4, 'v' => '5.020001' }; The flags are different but both of them return true for $flags & CVf_CONST == CVf_CONST, even though only the former is a constant sub, as shown with -MO=Deparse.
On Mon Nov 24 12:52:22 2014, AVAR wrote: Show quoted text
> On 2014-11-23T16:26:27-05:00, SPROUT wrote:
> > On Sun Nov 23 16:12:03 2014, SPROUT wrote:
> > > 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.
> > No need to keep re-sending me the full patch, if you can just provide > an example of testing for a constant sub with B that's enough. > > But it doesn't look like CVf_CONST works either: > $ /usr/bin/perl -MData::Dumper -MB=svref_2object,CVf_CONST -wE > '$Data::Dumper::Sortkeys = 1; sub CONST () { 123 } my $flags = > svref_2object(\&CONST)->FLAGS; say Dumper {v => $], flags => $flags, > "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const => > ($flags & CVf_CONST == CVf_CONST)} if CONST' > $VAR1 = { > 'CVf_CONST' => 4, > 'FC_is_const' => 1, > 'flags' => 17421, > 'flags&' => 4, > 'v' => '5.020001' > }; > $ /usr/bin/perl -MData::Dumper -MB=svref_2object,CVf_CONST -wE > '$Data::Dumper::Sortkeys = 1; sub CONST { 123 } my $flags = > svref_2object(\&CONST)->FLAGS; say Dumper {v => $], flags => $flags, > "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const => > ($flags & CVf_CONST == CVf_CONST)} if CONST' > $VAR1 = { > 'CVf_CONST' => 4, > 'FC_is_const' => 1, > 'flags' => 13, > 'flags&' => 4, > 'v' => '5.020001' > }; > > > The flags are different but both of them return true for $flags & > CVf_CONST == CVf_CONST, even though only the former is a constant sub, > as shown with -MO=Deparse.
->CvFLAGS, not ->FLAGS. I made the same mistake at first. Also, == has higher precedence than &: $ /opt/testing/bin/perl5.8.7 -MData::Dumper -MB=svref_2object,CVf_CONST -we '$Data::Dumper::Sortkeys = 1; sub CONST () { 123 } my $flags = svref_2object(\&CONST)->CvFLAGS; print Dumper {v => $], flags => $flags, "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const => (($flags & CVf_CONST) == CVf_CONST)} if CONST' $VAR1 = { 'CVf_CONST' => 512, 'FC_is_const' => 1, 'flags' => 512, 'flags&' => 512, 'v' => '5.008007' }; $ /opt/testing/bin/perl5.8.7 -MData::Dumper -MB=svref_2object,CVf_CONST -we '$Data::Dumper::Sortkeys = 1; sub CONST { 123 } my $flags = svref_2object(\&CONST)->CvFLAGS; print Dumper {v => $], flags => $flags, "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const => (($flags & CVf_CONST) == CVf_CONST)} if CONST' $VAR1 = { 'CVf_CONST' => 512, 'FC_is_const' => '', 'flags' => 0, 'flags&' => 0, 'v' => '5.008007' }; $ perl5.21.7 -MData::Dumper -MB=svref_2object,CVf_CONST -we '$Data::Dumper::Sortkeys = 1; sub CONST () { 123 } my $flags = svref_2object(\&CONST)->CvFLAGS; print Dumper {v => $], flags => $flags, "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const => (($flags & CVf_CONST) == CVf_CONST)} if CONST' $VAR1 = { 'CVf_CONST' => 4, 'FC_is_const' => 1, 'flags' => 4108, 'flags&' => 4, 'v' => '5.021007' }; $ perl5.21.7 -MData::Dumper -MB=svref_2object,CVf_CONST -we '$Data::Dumper::Sortkeys = 1; sub CONST { 123 } my $flags = svref_2object(\&CONST)->CvFLAGS; print Dumper {v => $], flags => $flags, "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const => (($flags & CVf_CONST) == CVf_CONST)} if CONST' $VAR1 = { 'CVf_CONST' => 4, 'FC_is_const' => '', 'flags' => 32768, 'flags&' => 0, 'v' => '5.021007' }; $ perl5.21.7 -v | head -2 This is perl 5, version 21, subversion 7 (v5.21.7 (v5.21.6-42-g199670d)) built for darwin-2level
On 2014-11-25T00:43:10-05:00, SPROUT wrote: Show quoted text
> On Mon Nov 24 12:52:22 2014, AVAR wrote:
> > On 2014-11-23T16:26:27-05:00, SPROUT wrote:
> > > On Sun Nov 23 16:12:03 2014, SPROUT wrote:
> > > > 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.
> > > > No need to keep re-sending me the full patch, if you can just provide > > an example of testing for a constant sub with B that's enough. > > > > But it doesn't look like CVf_CONST works either: > > $ /usr/bin/perl -MData::Dumper -MB=svref_2object,CVf_CONST -wE > > '$Data::Dumper::Sortkeys = 1; sub CONST () { 123 } my $flags = > > svref_2object(\&CONST)->FLAGS; say Dumper {v => $], flags => $flags, > > "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const > > => > > ($flags & CVf_CONST == CVf_CONST)} if CONST' > > $VAR1 = { > > 'CVf_CONST' => 4, > > 'FC_is_const' => 1, > > 'flags' => 17421, > > 'flags&' => 4, > > 'v' => '5.020001' > > }; > > $ /usr/bin/perl -MData::Dumper -MB=svref_2object,CVf_CONST -wE > > '$Data::Dumper::Sortkeys = 1; sub CONST { 123 } my $flags = > > svref_2object(\&CONST)->FLAGS; say Dumper {v => $], flags => $flags, > > "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const > > => > > ($flags & CVf_CONST == CVf_CONST)} if CONST' > > $VAR1 = { > > 'CVf_CONST' => 4, > > 'FC_is_const' => 1, > > 'flags' => 13, > > 'flags&' => 4, > > 'v' => '5.020001' > > }; > > > > > > The flags are different but both of them return true for $flags & > > CVf_CONST == CVf_CONST, even though only the former is a constant > > sub, > > as shown with -MO=Deparse.
> > ->CvFLAGS, not ->FLAGS. I made the same mistake at first. Also, == > has higher precedence than &:
d'oh! Yes that works. Thanks very much. I've released 0.11 with a modified version of your patch, and I also made the -MO=Deparse test more resilient to failures: https://github.com/avar/constant-export-lazy/commit/ef35dd794cd898aeede9e5b5305cdfdd81f54a1d
On 2014-12-01T16:05:31-05:00, AVAR wrote: Show quoted text
> On 2014-11-25T00:43:10-05:00, SPROUT wrote:
> > On Mon Nov 24 12:52:22 2014, AVAR wrote:
> > > On 2014-11-23T16:26:27-05:00, SPROUT wrote:
> > > > On Sun Nov 23 16:12:03 2014, SPROUT wrote:
> > > > > 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.
> > > > > > No need to keep re-sending me the full patch, if you can just > > > provide > > > an example of testing for a constant sub with B that's enough. > > > > > > But it doesn't look like CVf_CONST works either: > > > $ /usr/bin/perl -MData::Dumper -MB=svref_2object,CVf_CONST -wE > > > '$Data::Dumper::Sortkeys = 1; sub CONST () { 123 } my $flags = > > > svref_2object(\&CONST)->FLAGS; say Dumper {v => $], flags => > > > $flags, > > > "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const > > > => > > > ($flags & CVf_CONST == CVf_CONST)} if CONST' > > > $VAR1 = { > > > 'CVf_CONST' => 4, > > > 'FC_is_const' => 1, > > > 'flags' => 17421, > > > 'flags&' => 4, > > > 'v' => '5.020001' > > > }; > > > $ /usr/bin/perl -MData::Dumper -MB=svref_2object,CVf_CONST -wE > > > '$Data::Dumper::Sortkeys = 1; sub CONST { 123 } my $flags = > > > svref_2object(\&CONST)->FLAGS; say Dumper {v => $], flags => > > > $flags, > > > "flags&" => $flags & CVf_CONST, CVf_CONST => CVf_CONST, FC_is_const > > > => > > > ($flags & CVf_CONST == CVf_CONST)} if CONST' > > > $VAR1 = { > > > 'CVf_CONST' => 4, > > > 'FC_is_const' => 1, > > > 'flags' => 13, > > > 'flags&' => 4, > > > 'v' => '5.020001' > > > }; > > > > > > > > > The flags are different but both of them return true for $flags & > > > CVf_CONST == CVf_CONST, even though only the former is a constant > > > sub, > > > as shown with -MO=Deparse.
> > > > ->CvFLAGS, not ->FLAGS. I made the same mistake at first. Also, == > > has higher precedence than &:
> > d'oh! Yes that works. Thanks very much. I've released 0.11 with a > modified version of your patch, and I also made the -MO=Deparse test > more resilient to failures: https://github.com/avar/constant-export- > lazy/commit/ef35dd794cd898aeede9e5b5305cdfdd81f54a1d