1 use Test::More tests => 58;
8 # we test the pure-perl versions only, but allow overrides
9 # from the accessor_xs test-umbrella
10 # Also make sure a rogue envvar will not interfere with
14 $Class::Accessor::Grouped::USE_XS = 0
15 unless defined $Class::Accessor::Grouped::USE_XS;
17 $use_xs = $Class::Accessor::Grouped::USE_XS;
22 my $obj = AccessorGroupsRO->new;
27 local $SIG{__WARN__} = sub {
28 if (shift =~ /DESTROY/i) {
34 local *AccessorGroupsRO::DESTROY = sub {};
36 $obj->mk_group_ro_accessors('warnings', 'DESTROY');
41 my $test_accessors = {
50 custom_field => 'lr1;field',
53 custom_field => "lr2'field",
55 fieldname_torture => {
56 custom_field => join ('', map { chr($_) } (0..255) ),
61 for my $name (sort keys %$test_accessors) {
63 my $alias = "_${name}_accessor";
64 my $field = $test_accessors->{$name}{custom_field} || $name;
66 can_ok($obj, $name, $alias);
68 ok(!$obj->can($field))
71 is($obj->$name, undef);
72 is($obj->$alias, undef);
78 # alias gets same as name
79 is($obj->$alias, 'a');
81 my $ro_regex = $test_accessors->{$name}{is_xs}
82 ? qr/Usage\:.+$name.*\(self\)/
83 : qr/$name(:?_accessor)?\Q' cannot alter its value (read-only attribute of class AccessorGroupsRO)/
87 local $TODO = "Class::XSAccessor emits broken error messages on 5.10 or -DDEBUGGING 5.8"
89 $test_accessors->{$name}{is_xs}
93 ( $] > '5.009' or $Config{config_args} =~ /DEBUGGING/ )
96 # die on set via name/alias
106 # value should be unchanged
107 is($obj->$name, 'a');
108 is($obj->$alias, 'a');