Skip Menu |

This queue is for tickets about the MooseX-StrictConstructor CPAN distribution.

Report information
The Basics
Id: 59236
Status: resolved
Priority: 0/
Queue: MooseX-StrictConstructor

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

Bug Information
Severity: Normal
Broken in: 0.08
Fixed in: 0.10



Subject: __INSTANCE__ should be ignored as a constructor arg
patch attached
Subject: instance.patch
diff -Nur MooseX-StrictConstructor-0.08/lib/MooseX/StrictConstructor/Role/Meta/Method/Constructor.pm MooseX-StrictConstructor-0.08-new/lib/MooseX/StrictConstructor/Role/Meta/Method/Constructor.pm --- MooseX-StrictConstructor-0.08/lib/MooseX/StrictConstructor/Role/Meta/Method/Constructor.pm 2009-04-07 11:13:01.000000000 -0500 +++ MooseX-StrictConstructor-0.08-new/lib/MooseX/StrictConstructor/Role/Meta/Method/Constructor.pm 2010-07-09 19:24:23.625076795 -0500 @@ -16,7 +16,8 @@ $source .= ";\n" if $source; my @attrs = - ( map { "$_ => 1," } + ( "__INSTANCE__ => 1,", + map { "$_ => 1," } grep { defined } map { $_->init_arg() } @{ $self->_attributes() } diff -Nur MooseX-StrictConstructor-0.08/lib/MooseX/StrictConstructor/Role/Object.pm MooseX-StrictConstructor-0.08-new/lib/MooseX/StrictConstructor/Role/Object.pm --- MooseX-StrictConstructor-0.08/lib/MooseX/StrictConstructor/Role/Object.pm 2009-04-07 11:13:01.000000000 -0500 +++ MooseX-StrictConstructor-0.08-new/lib/MooseX/StrictConstructor/Role/Object.pm 2010-07-09 19:22:37.860547284 -0500 @@ -12,7 +12,8 @@ my $params = shift; my %attrs = - ( map { $_ => 1 } + ( __INSTANCE__ => 1, + map { $_ => 1 } grep { defined } map { $_->init_arg() } $self->meta()->get_all_attributes() diff -Nur MooseX-StrictConstructor-0.08/t/instance.t MooseX-StrictConstructor-0.08-new/t/instance.t --- MooseX-StrictConstructor-0.08/t/instance.t 1969-12-31 18:00:00.000000000 -0600 +++ MooseX-StrictConstructor-0.08-new/t/instance.t 2010-07-09 19:23:29.823899909 -0500 @@ -0,0 +1,25 @@ +use strict; +use warnings; + +use Test::More tests => 4; + +{ + package Foo; + use Moose; + use MooseX::StrictConstructor; +} + +{ + eval { + Foo->new(__INSTANCE__ => Foo->new); + }; + ok(!$@, "__INSTANCE__ is ignored"); + eval { + Foo->meta->new_object(__INSTANCE__ => Foo->new); + }; + ok(!$@, "__INSTANCE__ is ignored"); + if (Foo->meta->is_mutable) { + Foo->meta->make_immutable; + redo; + } +};