1 use Test::More tests => 48;
7 # we test the pure-perl versions only, but allow overrides
8 # from the accessor_xs test-umbrella
9 # Also make sure a rogue envvar will not interfere with
13 $Class::Accessor::Grouped::USE_XS = 0
14 unless defined $Class::Accessor::Grouped::USE_XS;
16 $use_xs = $Class::Accessor::Grouped::USE_XS;
21 my $obj = AccessorGroupsRO->new;
26 local $SIG{__WARN__} = sub {
27 if (shift =~ /DESTROY/i) {
33 local *AccessorGroupsRO::DESTROY = sub {};
35 $obj->mk_group_ro_accessors('warnings', 'DESTROY');
40 my $test_accessors = {
49 custom_field => 'lr1;field',
52 custom_field => "lr2'field",
56 for my $name (sort keys %$test_accessors) {
58 my $alias = "_${name}_accessor";
59 my $field = $test_accessors->{$name}{custom_field} || $name;
61 can_ok($obj, $name, $alias);
63 ok(!$obj->can($field))
66 is($obj->$name, undef);
67 is($obj->$alias, undef);
73 # alias gets same as name
74 is($obj->$alias, 'a');
76 my $ro_regex = $test_accessors->{$name}{is_xs}
77 ? qr/Usage\:.+$name.*\(self\)/
78 : qr/cannot alter the value of '\Q$field\E'/
81 # die on set via name/alias
90 # value should be unchanged
92 is($obj->$alias, 'a');