Cure perl 5.6 problem
[p5sagit/Class-Accessor-Grouped.git] / t / accessors.t
index 7a72e5e..c04ece2 100644 (file)
@@ -1,4 +1,4 @@
-use Test::More tests => 62;
+use Test::More tests => 98;
 use strict;
 use warnings;
 use lib 't/lib';
@@ -24,12 +24,6 @@ use AccessorGroupsSubclass;
     my $name = 'multiple1';
     my $alias = "_${name}_accessor";
 
-    for my $meth ($name, $alias) {
-        my $cv = svref_2object( $obj->can($meth) );
-        is($cv->GV->NAME, $meth, "$meth accessor is named");
-        is($cv->GV->STASH->NAME, 'AccessorGroups', "$meth class correct");
-    }
-
     my $warned = 0;
     local $SIG{__WARN__} = sub {
         if  (shift =~ /DESTROY/i) {
@@ -44,7 +38,6 @@ use AccessorGroupsSubclass;
     ok($warned);
 };
 
-
 my $obj = AccessorGroupsSubclass->new;
 
 my $test_accessors = {
@@ -64,7 +57,6 @@ my $test_accessors = {
     },
 };
 
-
 for my $name (sort keys %$test_accessors) {
     my $alias = "_${name}_accessor";
     my $field = $test_accessors->{$name}{custom_field} || $name;
@@ -74,6 +66,12 @@ for my $name (sort keys %$test_accessors) {
     ok(!$obj->can($field))
       if $field ne $name;
 
+    for my $meth ($name, $alias) {
+        my $cv = svref_2object( $obj->can($meth) );
+        is($cv->GV->NAME, $meth, "$meth accessor is named");
+        is($cv->GV->STASH->NAME, 'AccessorGroups', "$meth class correct");
+    }
+
     is($obj->$name, undef);
     is($obj->$alias, undef);
 
@@ -92,6 +90,17 @@ for my $name (sort keys %$test_accessors) {
 
     # alias gets same as name
     is($obj->$name, 'b');
+
+    for my $meth ($name, $alias) {
+        my $cv = svref_2object( $obj->can($meth) );
+        is($cv->GV->NAME, $meth, "$meth accessor is named after operations");
+        is(
+          $cv->GV->STASH->NAME,
+          # XS lazyinstalls install into each caller, not into the original parent
+          $test_accessors->{$name}{is_xs} ? 'AccessorGroupsSubclass' :'AccessorGroups',
+          "$meth class correct after operations",
+        );
+    }
 };
 
 # important