}
sub _strip_traits {
- my $idx = first_index { $_ eq '-traits' } @_;
+ my $idx = first_index { ( $_ || '' ) eq '-traits' } @_;
return ( [], @_ ) unless $idx >= 0 && $#_ >= $idx + 1;
}
sub _strip_metaclass {
- my $idx = first_index { $_ eq '-metaclass' } @_;
+ my $idx = first_index { ( $_ || '' ) eq '-metaclass' } @_;
return ( undef, @_ ) unless $idx >= 0 && $#_ >= $idx + 1;
}
sub _strip_meta_name {
- my $idx = first_index { $_ eq '-meta_name' } @_;
+ my $idx = first_index { ( $_ || '' ) eq '-meta_name' } @_;
return ( 'meta', @_ ) unless $idx >= 0 && $#_ >= $idx + 1;
--- /dev/null
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+{
+ # so we don't pick up stuff from Moose::Object
+ package Base;
+ sub foo { } # touch it so that 'extends' doesn't try to load it
+}
+
+{
+ package Foo;
+ use Moose;
+ extends 'Base';
+ no Moose;
+}
+can_ok('Foo', 'meta');
+is(Foo->meta, Class::MOP::class_of('Foo'));
+isa_ok(Foo->meta->get_method('meta'), 'Moose::Meta::Method::Meta');
+
+{
+ package Bar;
+ use Moose -meta_name => 'bar_meta';
+ extends 'Base';
+ no Moose;
+}
+ok(!Bar->can('meta'));
+can_ok('Bar', 'bar_meta');
+is(Bar->bar_meta, Class::MOP::class_of('Bar'));
+isa_ok(Bar->bar_meta->get_method('bar_meta'), 'Moose::Meta::Method::Meta');
+
+{
+ package Baz;
+ use Moose -meta_name => undef;
+ extends 'Base';
+ no Moose;
+}
+ok(!Baz->can('meta'));
+# 1 because of the dummy method we installed in Base
+is(scalar Class::MOP::class_of('Baz')->get_all_methods, 1);
+
+done_testing;