Move component-group test to its own testfile
Peter Rabbitson [Fri, 10 Sep 2010 11:41:21 +0000 (11:41 +0000)]
Switch some tests to Test::Exception
Bump minimum M::I version for developes

Makefile.PL
t/component.t
t/inherited.t
t/lib/AccessorGroups.pm
t/lib/AccessorGroupsComp.pm [new file with mode: 0644]

index f8c5bbc..4921ca4 100644 (file)
@@ -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 =>
index d151644..d0a5dd8 100644 (file)
@@ -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);
index 942c309..8a3dc02 100644 (file)
@@ -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');
index 0fb5a7c..eda9b80 100644 (file)
@@ -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 (file)
index 0000000..952a383
--- /dev/null
@@ -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;