Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid bug with immutable / around new in Moose by using BUILD method …
…instead. Test constructing objects in various ways / in various lineages to demonstrate the issue.
- Loading branch information
Showing
3 changed files
with
82 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
0.00300 Jul XX, 2008 | ||
- Replace around 'new' with a BUILD method. Faster and avoids Moose | ||
bug with around/immutable and sub-classes. | ||
0.00200 Mar 28, 2008 | ||
- Extend BUILDALL to store constructor keys in the obj. hashref | ||
- Minor fix to make sure Adopt doesn't trip PAUSE perms | ||
- Bye bye auto_install. | ||
0.00100 Mar 15, 2008 | ||
- Initial Release! | ||
- Initial Release! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!perl | ||
use strict; | ||
use Test::More tests => 9; | ||
|
||
#1 | ||
require_ok("MooseX::Emulate::Class::Accessor::Fast"); | ||
|
||
{ | ||
package MyClass; | ||
use Moose; | ||
with 'MooseX::Emulate::Class::Accessor::Fast'; | ||
} | ||
|
||
{ | ||
package MyClass::MooseChild; | ||
use Moose; | ||
extends 'MyClass'; | ||
} | ||
|
||
{ | ||
package MyClass::ImmutableMooseChild; | ||
use Moose; | ||
extends 'MyClass'; | ||
__PACKAGE__->meta->make_immutable; | ||
} | ||
|
||
{ | ||
package MyClass::TraditionalChild; | ||
use base qw(MyClass); | ||
} | ||
|
||
{ | ||
package MyImmutableClass; | ||
use Moose; | ||
with 'MooseX::Emulate::Class::Accessor::Fast'; | ||
__PACKAGE__->meta->make_immutable; | ||
} | ||
|
||
{ | ||
package MyImmutableClass::MooseChild; | ||
use Moose; | ||
extends 'MyImmutableClass'; | ||
} | ||
|
||
{ | ||
package MyImmutableClass::ImmutableMooseChild; | ||
use Moose; | ||
extends 'MyImmutableClass'; | ||
__PACKAGE__->meta->make_immutable; | ||
} | ||
|
||
{ | ||
package MyImmutableClass::TraditionalChild; | ||
use base qw(MyImmutableClass); | ||
} | ||
|
||
# 2-9 | ||
foreach my $class (qw/ | ||
MyClass | ||
MyImmutableClass | ||
MyClass::MooseChild | ||
MyClass::ImmutableMooseChild | ||
MyClass::TraditionalChild | ||
MyImmutableClass::MooseChild | ||
MyImmutableClass::ImmutableMooseChild | ||
MyImmutableClass::TraditionalChild | ||
/) { | ||
my $instance = $class->new(foo => 'bar'); | ||
is($instance->{foo}, 'bar', $class . " has CAF construction behavior"); | ||
} | ||
|