Commits

Toby Inkster committed 62f3fd8

Additional tests

Comments (0)

Files changed (2)

t/04stashobject.t

+use Test::More tests => 6;
+use Object::Stash;
+
+{
+	package Local::TestClass;
+	use Object::Stash -type => 'object';
+	sub new {bless[@_],shift}
+}
+
+my $obj = Local::TestClass->new;
+
+is(
+	ref $obj->stash,
+	'Local::TestClass::stash'
+	);
+
+$obj->stash(foo => 'bar');
+
+is(
+	$obj->stash->{foo},
+	'bar'
+	);
+
+is(
+	$obj->stash->foo,
+	'bar'
+	);
+
+$obj->stash->foo = 'baz';
+
+is(
+	$obj->stash->{foo},
+	'baz'
+	);
+
+$obj->stash->foo('quux');
+
+is(
+	$obj->stash->{foo},
+	'quux'
+	);
+
+$obj->stash->foo++;
+
+is(
+	$obj->stash->foo,
+	'quuy'
+	);

t/05multiretrieval.t

+use Test::More tests => 4;
+use Object::Stash;
+
+{
+	package Local::TestClass;
+	use Object::Stash;
+	sub new {bless[@_],shift}
+}
+
+my $obj = Local::TestClass->new;
+$obj->stash(foo=>1, bar=>2, baz=>3);
+
+my @return = $obj->stash([qw/baz bar/]);
+is($return[0], 3);
+is($return[1], 2);
+
+my $return = $obj->stash([qw/baz foo/]);
+is($return->[0], 3);
+is($return->[1], 1);