Skip Menu |

This queue is for tickets about the Devel-EnforceEncapsulation CPAN distribution.

Report information
The Basics
Id: 77486
Status: resolved
Priority: 0/
Queue: Devel-EnforceEncapsulation

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

Bug Information
Severity: Unimportant
Broken in: 0.50
Fixed in: (no value)



Subject: Change in overload behavior in Perl 5.17.0 breaks t/api.t
In the "Selected Bug Fixes" section of the Perl 5.17.0 perldelta, it says that: Changes to overload settings now take effect immediately, as do changes to inheritance that affect overloading. They used to take effect only after "bless". Objects that were created before a class had any overloading used to remain non-overloaded even if the class gained overloading through "use overload" or @ISA changes, and even after "bless". This has been fixed [perl #112708]. Two of the tests in t/api.t in Devel-EnforceEncapsulation rely on the pre-5.17 behavior of Perl, and fail under 5.17.0. Yes, this is a development version of Perl, and it will be a year before this behavior sees the light of day, if then. That it why I have marked this unimportant, though it will become more important if this change actually makes 5.18. I have attached a patch to t/api.t, which changes the affected tests based on the value of $]. This has been tried under both 5.16.0 (old overload behavior) and 5.17.0 (new overload behavior). Eliminating the (possibly) problematic tests is another way to go.
Subject: Devel-EnforceEncapsulation.patch
--- t/api.old 2006-10-11 09:55:54.000000000 -0400 +++ t/api.t 2012-05-27 19:24:50.000000000 -0400 @@ -26,7 +26,12 @@ is $o->{secret}, 1, 'Unencapsulated classes are not affected'; Devel::EnforceEncapsulation->apply_to('Hash_class'); - is $o->{secret}, 1, 'Unencapsulated instances are still not affected'; + if ( $] >= 5.017 ) { + eval { my $val = $o->{secret}; }; + ok $@, 'Previously-unencapsulated instances are now encapsulated'; + } else { + is $o->{secret}, 1, 'Unencapsulated instances are still not affected'; + } $o = Hash_class->new; $o->foo(2); @@ -51,8 +56,12 @@ ok $@, 'Cannot reach into objects'; Devel::EnforceEncapsulation->remove_from('Hash_class'); - eval { my $val = $o->{secret}; $val = $s->{secret}; }; - ok $@, 'Still cannot reach into runtime injected objects'; + if ( $] >= 5.017 ) { + is $o->{secret}, 2, 'Encapsulated instances now unencapsulated'; + } else { + eval { my $val = $o->{secret}; $val = $s->{secret}; }; + ok $@, 'Still cannot reach into runtime injected objects'; + } $o = Hash_class->new; $o->foo(3);
Hey Chris, are you still maintaining this at all? Unless I force the installation, this bug blocks the author tests for Perl::Critic. Hope all is well with you :)
Thanks Jeff and Tom. I've now applied this patch and uploaded as v0.51