Stop leaking extra methods into the inheritance chain
[p5sagit/Class-Accessor-Grouped.git] / t / component.t
CommitLineData
874177a3 1use Test::More tests => 8;
18026fd5 2use Test::Exception;
331e820d 3use strict;
4use warnings;
5use lib 't/lib';
18026fd5 6use AccessorGroupsComp;
331e820d 7
18026fd5 8is(AccessorGroupsComp->result_class, undef);
331e820d 9
874177a3 10## croak on set where class can't be loaded and it's a physical class
18026fd5 11my $dying = AccessorGroupsComp->new;
12throws_ok {
ba8c183b 13 $dying->result_class('NotReallyAClass');
18026fd5 14} qr/Could not load result_class 'NotReallyAClass'/;
331e820d 15is($dying->result_class, undef);
16
874177a3 17
18## don't croak when the class isn't available but not loaded for people
19## who create class/packages on the fly
20$dying->result_class('JunkiesNeverInstalled');
21is($dying->result_class, 'JunkiesNeverInstalled');
22
6d0e8ff2 23ok(! $INC{'BaseInheritedGroups.pm'});
18026fd5 24AccessorGroupsComp->result_class('BaseInheritedGroups');
6d0e8ff2 25ok($INC{'BaseInheritedGroups.pm'});
18026fd5 26is(AccessorGroupsComp->result_class, 'BaseInheritedGroups');
331e820d 27
28## unset it
18026fd5 29AccessorGroupsComp->result_class(undef);
30is(AccessorGroupsComp->result_class, undef);