From: Stevan Little Date: Wed, 26 Apr 2006 14:23:06 +0000 (+0000) Subject: fixed X-Git-Tag: 0_05~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fcb7afc22e2823398088ffbcbbda75b321484900;p=gitmo%2FMoose.git fixed --- diff --git a/Changes b/Changes index 759ec1e..2e10fea 100644 --- a/Changes +++ b/Changes @@ -13,6 +13,7 @@ Revision history for Perl extension Moose experimental feature and probably not finished see t/038_attribute_inherited_slot_specs.t for more details, or ask about it on #moose + - added tests for this * Moose::Role - keywords are now exported with Sub::Exporter diff --git a/MANIFEST b/MANIFEST index 4024218..b9b8e10 100644 --- a/MANIFEST +++ b/MANIFEST @@ -40,7 +40,7 @@ t/030_attribute_reader_generation.t t/031_attribute_writer_generation.t t/032_attribute_accessor_generation.t t/033_attribute_triggers.t -t/034_does_attribute_option.t +t/034_attribute_does.t t/040_meta_role.t t/041_role.t t/042_apply_role.t diff --git a/lib/Moose.pm b/lib/Moose.pm index 9365583..6c3b619 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -47,7 +47,7 @@ use Moose::Util::TypeConstraints; $meta = Moose::Meta::Class->initialize($class); $meta->add_method('meta' => sub { # re-initialize so it inherits properly - Moose::Meta::Class->initialize($class); + Moose::Meta::Class->initialize(blessed($_[0]) || $_[0]); }) } @@ -154,14 +154,14 @@ use Moose::Util::TypeConstraints; } }); - sub import { + sub import { $CALLER = caller(); # we should never export to main return if $CALLER eq 'main'; goto $exporter; - }; + } } ## Utility functions diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 9173ca1..28194c7 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -42,8 +42,8 @@ sub clone_and_inherit_options { delete $options{$legal_option}; } } - # isa can be changed, but only if the new type - # is a subtype + # isa can be changed, but only if the + # new type is a subtype if ($options{isa}) { my $type_constraint; if (blessed($options{isa}) && $options{isa}->isa('Moose::Meta::TypeConstraint')) { diff --git a/t/103_subclass_use_base_bug.t b/t/103_subclass_use_base_bug.t new file mode 100644 index 0000000..8d45bc7 --- /dev/null +++ b/t/103_subclass_use_base_bug.t @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 3; + +BEGIN { + use_ok('Moose'); +} + +=pod + +This just makes sure that the Bar gets +a metaclass initialized for it correctly. + +=cut + +{ + package Foo; + use strict; + use warnings; + use Moose; + + package Bar; + use strict; + use warnings; + + use base 'Foo'; +} + +my $bar = Bar->new; +isa_ok($bar, 'Bar'); +isa_ok($bar, 'Foo'); \ No newline at end of file