3 use Test::More tests => 32;
6 require_ok("MooseX::Adopt::Class::Accessor::Fast");
8 my $class = "Testing::Class::Accessor::Fast";
12 @{"${class}::ISA"} = ('Class::Accessor::Fast');
13 *{"${class}::car"} = sub { shift->_car_accessor(@_); };
14 *{"${class}::mar"} = sub { return "Overloaded"; };
16 $class->mk_accessors(qw( foo bar yar car mar ));
17 $class->mk_ro_accessors(qw(static unchanged));
18 $class->mk_wo_accessors(qw(sekret double_sekret));
19 $class->follow_best_practice;
20 $class->mk_accessors(qw( best));
23 my %attrs = map{$_->name => $_} $class->meta->compute_all_applicable_attributes;
26 is(keys %attrs, 10, 'Correct number of attributes');
29 ok(exists $attrs{$_}, "Attribute ${_} created")
30 for qw( foo bar yar car mar static unchanged sekret double_sekret best );
33 ok($class->can("_${_}_accessor"), "Attribute ${_} created")
34 for qw( foo bar yar car mar static unchanged sekret double_sekret );
37 is( $attrs{$_}->accessor, $_, "Accessor ${_} created" )
41 ok( !$attrs{$_}->has_accessor, "Accessor ${_} not created" )
45 is( $attrs{$_}->reader, $_, "Reader ${_} created")
46 for qw( static unchanged );
49 is( $attrs{$_}->writer, $_, "Writer ${_} created")
50 for qw(sekret double_sekret);
53 is( $attrs{'best'}->reader, 'get_best', "Reader get_best created");
54 is( $attrs{'best'}->writer, 'set_best', "Writer set_best created");