{ use strict; package MyHolder; use Moose; has 'name' => (is => 'rw', isa => 'Str'); has 'things' => (is => 'rw', isa => 'ArrayRef'); } 1; #### #!/usr/bin/perl use lib 'lib'; use strict; use warnings; use MyHolder; use Test::More tests => 7; BEGIN { use_ok( 'MyHolder' ); } require_ok( 'MyHolder' ) or exit; my @temp = (); my $cup_holder = MyHolder->new(); # name $cup_holder->name("cupboard"); is ($cup_holder->name(), "cupboard", "name of cup holder should be cupboard"); # things my @cups = qw(blue green green yellow); $cup_holder->things(\@cups); @temp = @{$cup_holder->things()}; is (scalar @temp, 4, "there should be four things in the cupboard"); # add an element to the array... you've got to be kidding me # push($cup_holder->things(), "red"); @temp = @{$cup_holder->things()}; push(@temp, "red"); $cup_holder->things(\@temp); @temp = @{$cup_holder->things()}; is (scalar @temp, 5, "there should be five things in the cupboard"); # remove the last element from the array... (!) # my $thing = pop $cup_holder->things(); @temp = @{$cup_holder->things()}; my $thing = pop @temp; $cup_holder->things(\@temp); @temp = @{$cup_holder->things()}; is (scalar @temp, 4, "there should be four things in the cupboard"); is ($thing, "red", "the cup should be red");