From: Dylan William Hardison Date: Thu, 11 Jun 2009 14:48:29 +0000 (+0000) Subject: add test that requires Moose -- skips if moose is not installed. X-Git-Tag: 0.86~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bad78bd3dacb1579e8f965603c521aba0aef7bb7;p=gitmo%2FClass-MOP.git add test that requires Moose -- skips if moose is not installed. --- diff --git a/t/310_immutable_destroy.t b/t/310_immutable_destroy.t index 774ded0..cac6108 100644 --- a/t/310_immutable_destroy.t +++ b/t/310_immutable_destroy.t @@ -3,28 +3,25 @@ use warnings; use Test::More tests => 1; use Class::MOP; -BEGIN { - package FooBar; - sub DESTROY { shift->name } +BEGIN { + if (not Class::MOP::load_class('Moose::Object')) { + skip 'test requires moose', 1; + exit 0; + } } + { - my $meta = Class::MOP::Class->initialize('FooBar'); - $meta->add_attribute( - Class::MOP::Attribute->new( - 'name' => ( - reader => 'name', - ) - ) - ); - - $meta->make_immutable( - inline_accessors => 1, - inline_constructor => 1, - inline_destructor => 1, - ); + package FooBar; + use Moose; + + has 'name' => ( is => 'ro' ); + + sub DESTROY { shift->name } + + __PACKAGE__->meta->make_immutable; } my $f = FooBar->new( name => 'SUSAN' ); -is( $f->DESTROY, 'SUSAN', 'Did class-mop overload DESTROY?' ); +is( $f->DESTROY, 'SUSAN', 'Did moose overload DESTROY?' );