6 use Test::More tests => 28;
11 use_ok('Class::MOP::Method');
14 my $method = Class::MOP::Method->wrap(
16 package_name => 'main',
19 is($method->meta, Class::MOP::Method->meta, '... instance and class both lead to the same meta');
21 is($method->package_name, 'main', '... our package is main::');
22 is($method->name, '__ANON__', '... our sub name is __ANON__');
23 is($method->fully_qualified_name, 'main::__ANON__', '... our subs full name is main::__ANON__');
25 dies_ok { Class::MOP::Method->wrap } '... cant call this method without some code';
26 dies_ok { Class::MOP::Method->wrap([]) } '... cant call this method without some code';
27 dies_ok { Class::MOP::Method->wrap(bless {} => 'Fail') } '... cant call this method without some code';
29 dies_ok { Class::MOP::Method->name } '... cant call this method with a class';
30 dies_ok { Class::MOP::Method->package_name } '... cant call this method with a class';
31 dies_ok { Class::MOP::Method->fully_qualified_name } '... cant call this method with a class';
33 my $meta = Class::MOP::Method->meta;
34 isa_ok($meta, 'Class::MOP::Class');
36 foreach my $method_name (qw(
41 ok($meta->has_method($method_name), '... Class::MOP::Method->has_method(' . $method_name . ')');
42 my $method = $meta->get_method($method_name);
43 is($method->package_name, 'Class::MOP::Method', '... our package is Class::MOP::Method');
44 is($method->name, $method_name, '... our sub name is "' . $method_name . '"');
48 Class::MOP::Method->wrap()
49 } '... bad args for &wrap';
52 Class::MOP::Method->wrap('Fail')
53 } '... bad args for &wrap';
56 Class::MOP::Method->wrap([])
57 } '... bad args for &wrap';
60 Class::MOP::Method->wrap(sub { 'FAIL' })
61 } '... bad args for &wrap';
64 Class::MOP::Method->wrap(sub { 'FAIL' }, package_name => 'main')
65 } '... bad args for &wrap';
68 Class::MOP::Method->wrap(sub { 'FAIL' }, name => '__ANON__')
69 } '... bad args for &wrap';