On Sat, Jan 22, 2011 at 3:40 PM, Stevan Little <[email protected]> wrote: > Quick disclaimer: I don't use MooseX::Declare personally and I never have, > the level of sugar never appealed to me. That said .... > > Honestly, I think the answer is to stop using MooseX::Declare. > > After I saw your nopaste on #moose last night, I was looking over > MX::Declare and noticed that no major work has really been done on it in > over a year. It is and has always been *highly* experimental and it is only > recommend for production use if you are willing to deal with some of it's > fragility and odd edge cases.
Although I don't use MooseX::Declare either, and agree with your sentiments. The problem isn't MooseX::Declare in this case. Because I apparently have nothing better to do with my Saturday afternoon, I spent 30 minutes cleaning up the code so that I could actually run it as separate files. The code split out is available in this gist: https://gist.github.com/dedc59a759c2183c418b Once I got the code so I could see what was going on, removed the calls to code that wasn't provided. I discovered the following. The tests assume that $manager->Hire($person) do the following: my $employee = $manager->Hire($person); isa_ok( $employee, $class_person ); isa_ok( $employee, $class_employee ); cmp_ok( $employee->name, 'eq', 'Jack Smith', 'BAD' ); cmp_ok( $employee->alias, 'eq', 'Jackie', 'BAD' ); cmp_ok( $employee->dateOfBirth, 'eq', '07/17/1980', 'BAD' ); However the code for the Hire method is defined like so: method Hire (Person $person!) { # THIS IS BROKEN!!!! my $employee = Employee->new( name => 'Bill Gates', alias => 'Mr Evil', dateOfBirth => '05/27/1965', hireDate => '01/01/2010', ); # the object returned ISA Person and Employee but has none of the Person attributes! die unless $employee->isa('Person'); die unless $employee->isa('Employee'); #print Dumper($employee); return $employee; } } That is it *always* returns an instance of Employee who is Bill Gates. Um. I have no clue how inheritance would make this any different. Non-working code is non-working. -Chris
