Blame t/chained.t

Packit 647083
#!perl -w
Packit 647083
use strict;
Packit 647083
use Test::More tests => 6;
Packit 647083
Packit 647083
package Foo;
Packit 647083
use base 'Class::Accessor::Chained';
Packit 647083
__PACKAGE__->mk_accessors(qw( foo bar baz ));
Packit 647083
package main;
Packit 647083
Packit 647083
my $foo = Foo->new->foo(1)->baz(2)->bar(4);
Packit 647083
isa_ok( $foo, 'Foo' );
Packit 647083
is( $foo->bar, 4, "get gets the value" );
Packit 647083
is( $foo->foo( 5 ), $foo, "set gets the object" );
Packit 647083
Packit 647083
# and again, but with Fast accessors
Packit 647083
package Bar;
Packit 647083
use base 'Class::Accessor::Chained::Fast';
Packit 647083
__PACKAGE__->mk_accessors(qw( foo bar baz ));
Packit 647083
package main;
Packit 647083
Packit 647083
my $bar = Bar->new->foo(1)->baz(2)->bar(4);
Packit 647083
isa_ok( $bar, 'Bar' );
Packit 647083
is( $bar->bar, 4, "get gets the value" );
Packit 647083
is( $bar->foo( 5 ), $bar, "set gets the object" );