4 use Test::More tests => 15;
28 } qr/You cannot auto-dereference without specifying a type constraint on attribute \(any\)/;
36 } qr/You cannot auto-dereference anything other than a ArrayRef or HashRef on attribute \(scalar\)/;
42 } qr/auto_deref without defaults don't explode on new/;
44 my ($array, @array, $hash, %hash);
53 } qr/auto_deref without default doesn't explode on get/;
55 is($obj->array, undef, "array without value is undef in scalar context");
56 is($obj->hash, undef, "hash without value is undef in scalar context");
58 is(@array, 0, "array without value is empty in list context");
59 is(keys %hash, 0, "hash without value is empty in list context");
61 @array = $obj->array([1, 2, 3]);
62 %hash = $obj->hash({foo => 1, bar => 2});
64 is_deeply(\@array, [1, 2, 3], "setter returns the dereferenced list");
65 is_deeply(\%hash, {foo => 1, bar => 2}, "setter returns the dereferenced hash");
75 } qr/auto_deref without default doesn't explode on get/;
77 is_deeply($array, [1, 2, 3], "auto_deref in scalar context gives the reference");
78 is_deeply($hash, {foo => 1, bar => 2}, "auto_deref in scalar context gives the reference");
80 is_deeply(\@array, [1, 2, 3], "auto_deref in list context gives the list");
81 is_deeply(\%hash, {foo => 1, bar => 2}, "auto_deref in list context gives the hash");