From: Peter Rabbitson Date: Fri, 10 Sep 2010 11:41:21 +0000 (+0000) Subject: Move component-group test to its own testfile X-Git-Tag: v0.09006~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=18026fd59c6721f71469134d1ef767755b265386;p=p5sagit%2FClass-Accessor-Grouped.git Move component-group test to its own testfile Switch some tests to Test::Exception Bump minimum M::I version for developes --- diff --git a/Makefile.PL b/Makefile.PL index f8c5bbc..4921ca4 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,7 +1,7 @@ # $Id$ use strict; use warnings; -use inc::Module::Install 0.91; +use inc::Module::Install 1; name 'Class-Accessor-Grouped'; license 'perl'; @@ -14,20 +14,16 @@ requires 'MRO::Compat'; requires 'Class::Inspector'; requires 'Sub::Name' => '0.04'; -# removed due to segfaults, see _hasXS() -#requires 'Class::XSAccessor'; - test_requires 'Sub::Identify'; +test_requires 'Test::Exception'; clean_files "Class-Accessor-Grouped-* t/var"; if (-e 'MANIFEST.SKIP') { system('pod2text lib/Class/Accessor/Grouped.pm > README'); + realclean_files 'README'; } -realclean_files 'README'; - -auto_provides; auto_install; resources repository => diff --git a/t/component.t b/t/component.t index d151644..d0a5dd8 100644 --- a/t/component.t +++ b/t/component.t @@ -1,18 +1,18 @@ use Test::More tests => 8; +use Test::Exception; use strict; use warnings; use lib 't/lib'; use Class::Inspector; -use AccessorGroups; +use AccessorGroupsComp; -is(AccessorGroups->result_class, undef); +is(AccessorGroupsComp->result_class, undef); ## croak on set where class can't be loaded and it's a physical class -my $dying = AccessorGroups->new; -eval { +my $dying = AccessorGroupsComp->new; +throws_ok { $dying->result_class('NotReallyAClass'); -}; -ok($@ =~ /Could not load result_class 'NotReallyAClass'/); +} qr/Could not load result_class 'NotReallyAClass'/; is($dying->result_class, undef); @@ -22,10 +22,10 @@ $dying->result_class('JunkiesNeverInstalled'); is($dying->result_class, 'JunkiesNeverInstalled'); ok(!Class::Inspector->loaded('BaseInheritedGroups')); -AccessorGroups->result_class('BaseInheritedGroups'); +AccessorGroupsComp->result_class('BaseInheritedGroups'); ok(Class::Inspector->loaded('BaseInheritedGroups')); -is(AccessorGroups->result_class, 'BaseInheritedGroups'); +is(AccessorGroupsComp->result_class, 'BaseInheritedGroups'); ## unset it -AccessorGroups->result_class(undef); -is(AccessorGroups->result_class, undef); \ No newline at end of file +AccessorGroupsComp->result_class(undef); +is(AccessorGroupsComp->result_class, undef); diff --git a/t/inherited.t b/t/inherited.t index 942c309..8a3dc02 100644 --- a/t/inherited.t +++ b/t/inherited.t @@ -1,4 +1,5 @@ use Test::More tests => 36; +use Test::Exception; use strict; use warnings; use lib 't/lib'; @@ -57,15 +58,13 @@ is(BaseInheritedGroups->basefield, 'All Your Base'); # croak on get/set on non hash-based object my $dying = NotHashBased->new; -eval { +throws_ok { $dying->killme; -}; -ok($@ =~ /Cannot get.*is not hash-based/); +} qr/Cannot get.*is not hash-based/; -eval { +throws_ok { $dying->killme('foo'); -}; -ok($@ =~ /Cannot set.*is not hash-based/); +} qr/Cannot set.*is not hash-based/; # make sure we're get defined items, even 0, '' BaseInheritedGroups->basefield('base'); diff --git a/t/lib/AccessorGroups.pm b/t/lib/AccessorGroups.pm index 0fb5a7c..eda9b80 100644 --- a/t/lib/AccessorGroups.pm +++ b/t/lib/AccessorGroups.pm @@ -6,7 +6,6 @@ use base 'Class::Accessor::Grouped'; __PACKAGE__->mk_group_accessors('simple', 'singlefield'); __PACKAGE__->mk_group_accessors('simple', qw/multiple1 multiple2/); __PACKAGE__->mk_group_accessors('simple', [qw/lr1name lr1;field/], [qw/lr2name lr2'field/]); -__PACKAGE__->mk_group_accessors('component_class', 'result_class'); sub new { return bless {}, shift; diff --git a/t/lib/AccessorGroupsComp.pm b/t/lib/AccessorGroupsComp.pm new file mode 100644 index 0000000..952a383 --- /dev/null +++ b/t/lib/AccessorGroupsComp.pm @@ -0,0 +1,12 @@ +package AccessorGroupsComp; +use strict; +use warnings; +use base 'Class::Accessor::Grouped'; + +__PACKAGE__->mk_group_accessors('component_class', 'result_class'); + +sub new { + return bless {}, shift; +}; + +1;