Skip to content

Commit

Permalink
Merge pull request #5 from dolmen/fix/FIELDS-once
Browse files Browse the repository at this point in the history
Fix injected %FIELDS by T::MO::Extends
  • Loading branch information
chromatic committed Apr 7, 2014
2 parents 14926b3 + 7885276 commit 9c19e1a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Test/MockObject/Extends.pm
Expand Up @@ -4,8 +4,6 @@ use strict;
use warnings;

use Test::MockObject;
use Hash::Util ();
use fields ();

sub import
{
Expand All @@ -17,6 +15,8 @@ sub import
use Devel::Peek 'CvGV';
use Scalar::Util 'blessed';

use constant PERL_5_9 => $^V gt v5.9.0;

sub new
{
my ($class, $fake_class) = @_;
Expand All @@ -28,9 +28,9 @@ sub new
my $self = blessed( $fake_class ) ? $fake_class : {};

# Fields now locks the hash as of 5.9.0 - #84535
if ($^V gt v5.9.0 && blessed( $fake_class ) && do {
if (PERL_5_9 && blessed( $fake_class ) && do {
no strict 'refs';
(%{$parent_class . '::FIELDS'}) # uses fields
exists ${$parent_class . '::'}{FIELDS} # uses fields
}) {
# bypass prototypes
&Hash::Util::unlock_hash(\%$fake_class);
Expand Down

0 comments on commit 9c19e1a

Please sign in to comment.