X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F050_metaclasses%2F019_create_anon_with_required_attr.t;h=70bddd63a7ec1562f0b767f646dee350a649e79e;hb=53a4d826caec4b82f5b23e0bc0a4e8e2f44243b9;hp=61c9c75b39976301c6a8cddfa0f21af25bd29b0d;hpb=478b11a96fdfd6d0b2cc20214fb9e4645b6ef75c;p=gitmo%2FMoose.git diff --git a/t/050_metaclasses/019_create_anon_with_required_attr.t b/t/050_metaclasses/019_create_anon_with_required_attr.t index 61c9c75..70bddd6 100644 --- a/t/050_metaclasses/019_create_anon_with_required_attr.t +++ b/t/050_metaclasses/019_create_anon_with_required_attr.t @@ -7,7 +7,7 @@ use strict; use warnings; use Test::More; -use Test::Fatal; +use Test::Exception; { package HasFoo; @@ -30,29 +30,29 @@ use Test::Fatal; package main; my $anon; -ok ! exception { +lives_ok { $anon = My::Metaclass->create_anon_class( foo => 'this' ); -}, 'create anon class with required attr'; +} 'create anon class with required attr'; isa_ok( $anon, 'My::Metaclass' ); cmp_ok( $anon->foo, 'eq', 'this', 'foo is this' ); -ok exception { +dies_ok { $anon = My::Metaclass->create_anon_class(); -}, 'failed to create anon class without required attr'; +} 'failed to create anon class without required attr'; my $meta; -ok ! exception { +lives_ok { $meta = My::Metaclass->initialize( 'Class::Name1' => ( foo => 'that' ) ); -}, 'initialize a class with required attr'; +} 'initialize a class with required attr'; isa_ok( $meta, 'My::Metaclass' ); cmp_ok( $meta->foo, 'eq', 'that', 'foo is that' ); cmp_ok( $meta->name, 'eq', 'Class::Name1', 'for the correct class' ); -ok exception { +dies_ok { $meta = My::Metaclass->initialize( 'Class::Name2' ); -}, 'failed to initialize a class without required attr'; +} 'failed to initialize a class without required attr'; -ok ! exception { +lives_ok { eval qq{ package Class::Name3; use metaclass 'My::Metaclass' => ( @@ -61,28 +61,28 @@ ok ! exception { use Moose; }; die $@ if $@; -}, 'use metaclass with required attr'; +} 'use metaclass with required attr'; $meta = Class::Name3->meta; isa_ok( $meta, 'My::Metaclass' ); cmp_ok( $meta->foo, 'eq', 'another', 'foo is another' ); cmp_ok( $meta->name, 'eq', 'Class::Name3', 'for the correct class' ); -ok exception { +dies_ok { eval qq{ package Class::Name4; use metaclass 'My::Metaclass'; use Moose; }; die $@ if $@; -}, 'failed to use metaclass without required attr'; +} 'failed to use metaclass without required attr'; # how do we pass a required attribute to -traits? -ok exception { +dies_ok { eval qq{ package Class::Name5; use Moose -traits => 'HasFoo'; }; die $@ if $@; -}, 'failed to use trait without required attr'; +} 'failed to use trait without required attr'; done_testing;