Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix Moose tests after perl rt#118561 #25

Merged
merged 1 commit into from

4 participants

@haarg
Owner

Newer versions of base.pm will be more strict about when to ignore a failure finding the module file. It will only consider the module already loaded if there are any variables in the stash. Previously, it would also consider modules with existing submodules as loaded.

This fixes it by manually setting @ISA, avoiding base's heuristic entirely. If a different style is preferred, let me know.

@karenetheridge

What happens if we s/base/parent/ in these tests? We've talked a few times in the past about using parent.pm everywhere in Moose.

@haarg
Owner

You'd need to use -norequire, but it would work without issue.

Switching to parent sounds like a good idea to me. I just went with a low impact approach for the first cut of this patch.

@perigrin
Owner

Testing with base is probably best done at least explicitly even if we move other things to parent simply because base will be used in the Real World ™ and we need to be sure we haven't accidentally broken that. It's where I keep all my stuff.

@haarg haarg stop relying on base ignoring errors in some cases when module file d…
…oesn't exist

Future versions of base.pm will be more strict about what cases it
allows when it can't fine a module file.
6ab8bb0
@doy doy merged commit c1f5ffe into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 6, 2013
  1. @haarg

    stop relying on base ignoring errors in some cases when module file d…

    haarg authored
    …oesn't exist
    
    Future versions of base.pm will be more strict about what cases it
    allows when it can't fine a module file.
This page is out of date. Refresh to see the latest.
View
2  t/cmop/instance_metaclass_incompat.t
@@ -20,6 +20,7 @@ use metaclass;
$@ = undef;
eval {
package Foo;
+ BEGIN { $INC{'Foo.pm'} = __FILE__ }
metaclass->import('instance_metaclass' => 'Foo::Meta::Instance');
};
ok(!$@, '... Foo.meta => Foo::Meta is compatible') || diag $@;
@@ -27,6 +28,7 @@ ok(!$@, '... Foo.meta => Foo::Meta is compatible') || diag $@;
$@ = undef;
eval {
package Bar;
+ BEGIN { $INC{'Bar.pm'} = __FILE__ }
metaclass->import('instance_metaclass' => 'Bar::Meta::Instance');
};
ok(!$@, '... Bar.meta => Bar::Meta is compatible') || diag $@;
View
59 t/cmop/metaclass_incompatibility.t
@@ -6,28 +6,34 @@ use Test::Fatal;
use metaclass;
-my %metaclass_attrs = (
- 'Instance' => 'instance_metaclass',
- 'Attribute' => 'attribute_metaclass',
- 'Method' => 'method_metaclass',
- 'Method::Wrapped' => 'wrapped_method_metaclass',
- 'Method::Constructor' => 'constructor_class',
-);
-
-# meta classes
-for my $suffix ('Class', keys %metaclass_attrs) {
- Class::MOP::Class->create(
- "Foo::Meta::$suffix",
- superclasses => ["Class::MOP::$suffix"]
- );
- Class::MOP::Class->create(
- "Bar::Meta::$suffix",
- superclasses => ["Class::MOP::$suffix"]
- );
- Class::MOP::Class->create(
- "FooBar::Meta::$suffix",
- superclasses => ["Foo::Meta::$suffix", "Bar::Meta::$suffix"]
+my %metaclass_attrs;
+BEGIN {
+ %metaclass_attrs = (
+ 'Instance' => 'instance_metaclass',
+ 'Attribute' => 'attribute_metaclass',
+ 'Method' => 'method_metaclass',
+ 'Method::Wrapped' => 'wrapped_method_metaclass',
+ 'Method::Constructor' => 'constructor_class',
);
+
+ # meta classes
+ for my $suffix ('Class', keys %metaclass_attrs) {
+ Class::MOP::Class->create(
+ "Foo::Meta::$suffix",
+ superclasses => ["Class::MOP::$suffix"]
+ );
+ $INC{"Foo/Meta/$suffix.pm"} = __FILE__;
+ Class::MOP::Class->create(
+ "Bar::Meta::$suffix",
+ superclasses => ["Class::MOP::$suffix"]
+ );
+ $INC{"Bar/Meta/$suffix.pm"} = __FILE__;
+ Class::MOP::Class->create(
+ "FooBar::Meta::$suffix",
+ superclasses => ["Foo::Meta::$suffix", "Bar::Meta::$suffix"]
+ );
+ $INC{"FooBar/Meta/$suffix.pm"} = __FILE__;
+ }
}
# checking...
@@ -130,7 +136,11 @@ ok(!Foo::NoMeta->can('meta'), "non-cmop superclass doesn't get methods installed
isa_ok(Class::MOP::class_of('Foo::NoMeta2'), 'Class::MOP::Class');
isa_ok(Foo::NoMeta2::Sub->meta, 'Foo::Meta::Class');
-Foo::Meta::Class->create('Foo::WithMeta');
+
+BEGIN {
+ Foo::Meta::Class->create('Foo::WithMeta');
+ $INC{'Foo/WithMeta.pm'} = __FILE__;
+}
{
package Foo::WithMeta::Sub;
use base 'Foo::WithMeta';
@@ -144,7 +154,10 @@ isa_ok(Class::MOP::class_of('Foo::WithMeta'), 'Foo::Meta::Class');
isa_ok(Class::MOP::class_of('Foo::WithMeta::Sub'), 'Foo::Meta::Class');
isa_ok(Class::MOP::class_of('Foo::WithMeta::Sub::Sub'), 'Foo::Meta::Class');
-Foo::Meta::Class->create('Foo::WithMeta2');
+BEGIN {
+ Foo::Meta::Class->create('Foo::WithMeta2');
+ $INC{'Foo/WithMeta2.pm'} = __FILE__;
+}
{
package Foo::WithMeta2::Sub;
use base 'Foo::WithMeta2';
Something went wrong with that request. Please try again.