6 use Test::More tests => 19;
10 use_ok('MooseX::AttributeHelpers');
16 use MooseX::AttributeHelpers;
18 has 'word_histogram' => (
19 metaclass => 'Collection::Bag',
23 'get' => 'get_count_for',
24 'has_items' => 'has_any_words',
25 'is_empty' => 'has_no_words',
26 'count' => 'num_words',
27 'delete' => 'delete_word',
32 my $stuff = Stuff->new();
33 isa_ok($stuff, 'Stuff');
35 can_ok($stuff, $_) for qw[
44 ok($stuff->has_no_words, '... we have no words');
45 is($stuff->num_words, 0, '... we have no words');
48 $stuff->add_word('bar');
49 } '... set the words okay';
51 ok($stuff->has_any_words, '... we have words');
52 is($stuff->num_words, 1, '... we have 1 word(s)');
53 is($stuff->get_count_for('bar'), 1, '... got words now');
56 $stuff->add_word('foo');
57 $stuff->add_word('bar') for 0 .. 3;
58 $stuff->add_word('baz') for 0 .. 10;
59 } '... set the words okay';
61 is($stuff->num_words, 3, '... we still have 1 word(s)');
62 is($stuff->get_count_for('foo'), 1, '... got words now');
63 is($stuff->get_count_for('bar'), 5, '... got words now');
64 is($stuff->get_count_for('baz'), 11, '... got words now');