Skip distro which requires rpm
[gitmo/Moose.git] / t / metaclasses / meta_name.t
CommitLineData
1c3304e6 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More;
5
6{
7 # so we don't pick up stuff from Moose::Object
8 package Base;
9 sub foo { } # touch it so that 'extends' doesn't try to load it
10}
11
12{
13 package Foo;
14 use Moose;
15 extends 'Base';
16 no Moose;
17}
18can_ok('Foo', 'meta');
19is(Foo->meta, Class::MOP::class_of('Foo'));
20isa_ok(Foo->meta->get_method('meta'), 'Moose::Meta::Method::Meta');
21
22{
23 package Bar;
24 use Moose -meta_name => 'bar_meta';
25 extends 'Base';
26 no Moose;
27}
28ok(!Bar->can('meta'));
29can_ok('Bar', 'bar_meta');
30is(Bar->bar_meta, Class::MOP::class_of('Bar'));
31isa_ok(Bar->bar_meta->get_method('bar_meta'), 'Moose::Meta::Method::Meta');
32
33{
34 package Baz;
35 use Moose -meta_name => undef;
36 extends 'Base';
37 no Moose;
38}
39ok(!Baz->can('meta'));
acf10496 40
41my $universal_method_count = scalar Class::MOP::class_of('UNIVERSAL')->get_all_methods;
1c3304e6 42# 1 because of the dummy method we installed in Base
acf10496 43is( ( scalar Class::MOP::class_of('Baz')->get_all_methods )
44 - $universal_method_count, 1 );
1c3304e6 45
46done_testing;