perl - Test::MockObject::Extends with 'fields' gives error -


so trying upgrade old test modules written other people support newer perls. of tests using test::mockobject::extends, i've found running following code errors out.

#!/usr/bin/env perl  package mymodule; use strict; use warnings; use fields qw(field1 field2);  sub new {     $self = shift;     unless (ref $self) {         $self = fields::new($self);     }     return $self; }  package main; use strict; use warnings; use test::mockobject::extends; use data::dumper;  $var1 = mymodule->new(); print data::dumper::dumper($var1); $var2 = test::mockobject::extends->new($var1); 

error:

$ perl $var1 = bless( {}, 'mymodule' ); modification of read-only value attempted @ /usr/local/share/perl/5.14.2/test/mockobject/extends.pm line 31. 

i've looked @ changelog test::mockobject , perl 5.10 , can't see directly looks causes this. suspect been broken while , new 5.10 illuminated it.

i think what's happening here result of using fields::new. perldoc page:

       perl 5.9.0 , higher:  fields::new() creates , blesses       restricted-hash comprised of fields declared using "fields"       pragma specified class. 

i think test::mockobject::extends wants modify hash, hence boom.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -