3 use Test::More tests => 6;
6 use base 'Class::Accessor::Chained';
7 __PACKAGE__->mk_accessors(qw( foo bar baz ));
10 my $foo = Foo->new->foo(1)->baz(2)->bar(4);
11 isa_ok( $foo, 'Foo' );
12 is( $foo->bar, 4, "get gets the value" );
13 is( $foo->foo( 5 ), $foo, "set gets the object" );
15 # and again, but with Fast accessors
17 use base 'Class::Accessor::Chained::Fast';
18 __PACKAGE__->mk_accessors(qw( foo bar baz ));
21 my $bar = Bar->new->foo(1)->baz(2)->bar(4);
22 isa_ok( $bar, 'Bar' );
23 is( $bar->bar, 4, "get gets the value" );
24 is( $bar->foo( 5 ), $bar, "set gets the object" );