From: Jesse Luehrs Date: Thu, 23 Sep 2010 07:59:09 +0000 (-0500) Subject: tests for meta method object X-Git-Tag: 1.09~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aef4ceb3809fa6f67b31798aa6b62d7f8c9e830d;p=gitmo%2FClass-MOP.git tests for meta method object --- diff --git a/t/090_meta_method.t b/t/090_meta_method.t new file mode 100644 index 0000000..6567f49 --- /dev/null +++ b/t/090_meta_method.t @@ -0,0 +1,50 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Exception; +use Class::MOP; + +{ + can_ok('Class::MOP::Class', 'meta'); + isa_ok(Class::MOP::Class->meta->find_method_by_name('meta'), + 'Class::MOP::Method::Meta'); + + { + package Baz; + use metaclass; + } + can_ok('Baz', 'meta'); + isa_ok(Baz->meta->find_method_by_name('meta'), + 'Class::MOP::Method::Meta'); + + my $meta = Class::MOP::Class->create('Quux'); + can_ok('Quux', 'meta'); + isa_ok(Quux->meta->find_method_by_name('meta'), + 'Class::MOP::Method::Meta'); +} + +{ + { + package Foo; + use metaclass no_meta => 1; + } + + my $meta = Class::MOP::class_of('Foo'); + ok(!$meta->has_method('meta'), "no meta method was installed"); + $meta->add_method(meta => sub { die 'META' }); + lives_ok { $meta->find_method_by_name('meta') } "can do meta-level stuff"; + lives_ok { $meta->make_immutable } "can do meta-level stuff"; + lives_ok { $meta->class_precedence_list } "can do meta-level stuff"; +} + +{ + my $meta = Class::MOP::Class->create('Bar', no_meta => 1); + ok(!$meta->has_method('meta'), "no meta method was installed"); + $meta->add_method(meta => sub { die 'META' }); + lives_ok { $meta->find_method_by_name('meta') } "can do meta-level stuff"; + lives_ok { $meta->make_immutable } "can do meta-level stuff"; + lives_ok { $meta->class_precedence_list } "can do meta-level stuff"; +} + +done_testing; diff --git a/t/090_no_meta_method.t b/t/090_no_meta_method.t deleted file mode 100644 index 631442d..0000000 --- a/t/090_no_meta_method.t +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; -use Test::Exception; -use Class::MOP; - -{ - { - package Foo; - use metaclass no_meta => 1; - } - - my $meta = Class::MOP::class_of('Foo'); - ok(!$meta->has_method('meta'), "no meta method was installed"); - $meta->add_method(meta => sub { die 'META' }); - lives_ok { $meta->find_method_by_name('meta') } "can do meta-level stuff"; - lives_ok { $meta->make_immutable } "can do meta-level stuff"; - lives_ok { $meta->class_precedence_list } "can do meta-level stuff"; -} - -{ - my $meta = Class::MOP::Class->create('Bar', no_meta => 1); - ok(!$meta->has_method('meta'), "no meta method was installed"); - $meta->add_method(meta => sub { die 'META' }); - lives_ok { $meta->find_method_by_name('meta') } "can do meta-level stuff"; - lives_ok { $meta->make_immutable } "can do meta-level stuff"; - lives_ok { $meta->class_precedence_list } "can do meta-level stuff"; -} - -done_testing;