package Mouse::Meta::Method::Accessor;
-use Mouse::Util; # enables strict and warnings
+use Mouse::Util qw(:meta); # enables strict and warnings
sub _inline_slot{
my(undef, $self_var, $attr_name) = @_;
package Mouse::Meta::Method::Constructor;
-use Mouse::Util; # enables strict and warnings
+use Mouse::Util qw(:meta); # enables strict and warnings
sub _inline_slot{
my(undef, $self_var, $attr_name) = @_;
package Mouse::Meta::Method::Delegation;
-use Mouse::Util; # enables strict and warnings
-use Scalar::Util qw(blessed);
+use Mouse::Util qw(:meta); # enables strict and warnings
+use Scalar::Util;
sub _generate_delegation{
my (undef, $attribute, $metaclass, $reader, $handle_name, $method_to_call) = @_;
my $instance = shift;
my $proxy = $instance->$reader();
- my $error = !defined($proxy) ? ' is not defined'
- : ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')}
- : undef;
+ my $error = !defined($proxy) ? ' is not defined'
+ : ref($proxy) && !Scalar::Util::blessed($proxy) ? qq{ is not an object (got '$proxy')}
+ : undef;
if ($error) {
$instance->meta->throw_error(
"Cannot delegate $handle_name to $method_to_call because "
package Mouse::Meta::Method::Destructor;
-use Mouse::Util; # enables strict and warnings
+use Mouse::Util qw(:meta); # enables strict and warnings
sub _empty_DESTROY{ }
XSLoader::load('Mouse', $VERSION);
Mouse::Util->import({ into => 'Mouse::Meta::Method::Constructor::XS' }, ':meta');
Mouse::Util->import({ into => 'Mouse::Meta::Method::Destructor::XS' }, ':meta');
+ Mouse::Util->import({ into => 'Mouse::Meta::Method::Accessor::XS' }, ':meta');
return 1;
};
#warn $@ if $@;
use strict;
use warnings;
-use Test::More tests => 6;
+use Test::More tests => 10;
-use Mouse ();
+{
+ package Class;
+ use Mouse;
-can_ok('Mouse::Meta::Class', 'meta');
-can_ok('Mouse::Meta::Role', 'meta');
+ has foo => (is => 'rw');
-my $meta = Mouse::Meta::Class->meta;
-can_ok($meta->constructor_class, 'meta');
-can_ok($meta->destructor_class, 'meta');
-can_ok($meta->attribute_metaclass, 'meta');
+ __PACKAGE__->meta->make_immutable; # ensure metaclasses loaded
-can_ok($meta->get_method('is_anon_class'), 'meta');
+ package Role;
+ use Mouse::Role;
+ sub bar {}
+}
+
+{
+ my $metaclass = Class->meta;
+
+ can_ok($metaclass, 'meta');
+
+ can_ok($metaclass->constructor_class, 'meta');
+ can_ok($metaclass->destructor_class, 'meta');
+ can_ok($metaclass->attribute_metaclass, 'meta');
+
+ can_ok($metaclass->get_method('foo'), 'meta');
+ can_ok($metaclass->get_attribute('foo'), 'meta');
+ can_ok($metaclass->get_attribute('foo')->accessor_metaclass, 'meta');
+ can_ok($metaclass->get_attribute('foo')->delegation_metaclass, 'meta');
+}
+
+{
+ my $metarole = Class->meta;
+
+ can_ok($metarole, 'meta');
+
+ can_ok($metarole->get_method('foo'), 'meta');
+}