From: Stevan Little Date: Thu, 9 Feb 2006 22:55:54 +0000 (+0000) Subject: adding another test X-Git-Tag: 0_10~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=448af783a9e0cb39b939c86157f3e1cedd897c34;p=gitmo%2FClass-MOP.git adding another test --- diff --git a/MANIFEST b/MANIFEST index 2dd0654..913e996 100644 --- a/MANIFEST +++ b/MANIFEST @@ -26,6 +26,7 @@ t/011_create_class.t t/012_package_variables.t t/013_add_attribute_alternate.t t/014_attribute_introspection.t +t/015_metaclass_inheritance.t t/020_attribute.t t/030_method.t t/040_metaclass.t @@ -40,3 +41,4 @@ t/106_LazyClass_test.t t/pod.t t/pod_coverage.t t/lib/BinaryTree.pm +Makefile.PL diff --git a/t/015_metaclass_inheritance.t b/t/015_metaclass_inheritance.t new file mode 100644 index 0000000..d8ea970 --- /dev/null +++ b/t/015_metaclass_inheritance.t @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 10; +use Test::Exception; + +BEGIN { + use_ok('Class::MOP'); +} + +=pod + +Test that a default set up will cause metaclasses to inherit +the same metaclass type, but produce different metaclasses. + +=cut + +{ + package Foo; + use metaclass; + + package Bar; + use base 'Foo'; + + package Baz; + use base 'Bar'; +} + +my $foo_meta = Foo->meta; +isa_ok($foo_meta, 'Class::MOP::Class'); + +is($foo_meta->name, 'Foo', '... foo_meta->name == Foo'); + +my $bar_meta = Bar->meta; +isa_ok($bar_meta, 'Class::MOP::Class'); + +is($bar_meta->name, 'Bar', '... bar_meta->name == Bar'); +isnt($bar_meta, $foo_meta, '... Bar->meta != Foo->meta'); + +my $baz_meta = Baz->meta; +isa_ok($baz_meta, 'Class::MOP::Class'); + +is($baz_meta->name, 'Baz', '... baz_meta->name == Baz'); +isnt($baz_meta, $bar_meta, '... Baz->meta != Bar->meta'); +isnt($baz_meta, $foo_meta, '... Baz->meta != Foo->meta'); \ No newline at end of file