X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F006_new_and_clone_metaclasses.t;h=6c2a21d0fd1a84b920b6e335962554674a83cc9c;hb=67f694add1dd6c3c8d78a7aa991e65ff71dd1395;hp=b30e03be823bd47e4a9fdbd716e71fe41e8cfeb7;hpb=81c8a65bf02bb1b0e240d8f5b626b0ceabf9a37c;p=gitmo%2FClass-MOP.git diff --git a/t/006_new_and_clone_metaclasses.t b/t/006_new_and_clone_metaclasses.t index b30e03b..6c2a21d 100644 --- a/t/006_new_and_clone_metaclasses.t +++ b/t/006_new_and_clone_metaclasses.t @@ -1,14 +1,15 @@ -#!/usr/bin/perl - use strict; use warnings; -use Test::More tests => 36; +use FindBin; +use File::Spec::Functions; + +use Test::More; use Test::Exception; -BEGIN { - use_ok('Class::MOP'); -} +use Class::MOP; + +use lib catdir($FindBin::Bin, 'lib'); # make sure the Class::MOP::Class->meta does the right thing @@ -21,7 +22,7 @@ is($new_meta, $meta, '... it still creates the singleton'); my $cloned_meta = $meta->clone_object($meta); isa_ok($cloned_meta, 'Class::MOP::Class'); -is($cloned_meta, $meta, '... it creates the singleton even if you try to clone it'); +is($cloned_meta, $meta, '... it creates the singleton even if you try to clone it'); # make sure other metaclasses do the right thing @@ -35,13 +36,8 @@ isa_ok($foo_meta, 'Class::MOP::Class'); is($meta->new_object('package' => 'Foo'), $foo_meta, '... got the right Foo->meta singleton'); is($meta->clone_object($foo_meta), $foo_meta, '... cloning got the right Foo->meta singleton'); - -# make sure subclassed of Class::MOP::Class do the right thing -{ - package MyMetaClass; - use base 'Class::MOP::Class'; -} +# make sure subclassed of Class::MOP::Class do the right thing my $my_meta = MyMetaClass->meta; isa_ok($my_meta, 'Class::MOP::Class'); @@ -67,7 +63,7 @@ is($bar_meta->version, undef, '... Bar does not exists, so it has no version'); $bar_meta->superclasses('Foo'); -# check with MyMetaClass +# check with MyMetaClass { package Baz; @@ -106,14 +102,14 @@ isnt($cloned_foo, $foo, '... $cloned_foo is a new object different from $foo'); dies_ok { $foo_meta->clone_object($meta); -} '... this dies as expected'; +} '... this dies as expected'; # test stuff { package FooBar; use metaclass; - + FooBar->meta->add_attribute('test'); } @@ -124,7 +120,8 @@ my $attr_clone = $attr->clone(); isa_ok($attr_clone, 'Class::MOP::Attribute'); isnt($attr, $attr_clone, '... we successfully cloned our attributes'); -is($attr->associated_class, - $attr_clone->associated_class, +is($attr->associated_class, + $attr_clone->associated_class, '... we successfully did not clone our associated metaclass'); +done_testing;