* added typed-ness to collections
[gitmo/MooseX-AttributeHelpers.git] / t / 003_basic_hash.t
CommitLineData
d26633fc 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More no_plan => 1;
7
8BEGIN {
9 use_ok('MooseX::AttributeHelpers');
10}
11
12{
13 package Stuff;
14 use Moose;
15
16 has 'options' => (
17 metaclass => 'Collection::Hash',
18 is => 'ro',
19 isa => 'HashRef',
20 default => sub { {} },
21 provides => {
22 'set' => 'set_option',
23 'get' => 'get_option',
24 }
25 );
26}
27
28my $stuff = Stuff->new();
29isa_ok($stuff, 'Stuff');
30
31is_deeply($stuff->options, {}, '... no options yet');
32
33$stuff->set_option(foo => 'bar');
34is_deeply($stuff->options, { foo => 'bar' }, '... got options now');
35
36$stuff->set_option(bar => 'baz');
37is_deeply($stuff->options, { foo => 'bar', bar => 'baz' }, '... got more options now');
38
39is($stuff->get_option('foo'), 'bar', '... got the right option');
40
41
42