diff options
Diffstat (limited to 't/moose-tagged.t')
-rw-r--r-- | t/moose-tagged.t | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/t/moose-tagged.t b/t/moose-tagged.t index 1273bed..8e7dd97 100644 --- a/t/moose-tagged.t +++ b/t/moose-tagged.t @@ -39,6 +39,15 @@ subtest 'default' => sub { ok($obj->has_stuff,'has stuff'); is($obj->stuff,3,'default'); + + cmp_deeply( + [$obj->meta->get_attribute('stuff')->all_tags($obj)], + [undef], + 'stuff all_tags'); + cmp_deeply( + [$obj->meta->get_attribute('other')->all_tags($obj)], + [], + 'other all_tags'); }; subtest 'constructor param' => sub { @@ -49,6 +58,15 @@ subtest 'constructor param' => sub { is($obj->stuff,12,'param'); is($obj->other,'bar','param'); + + cmp_deeply( + [$obj->meta->get_attribute('stuff')->all_tags($obj)], + [undef], + 'stuff all_tags'); + cmp_deeply( + [$obj->meta->get_attribute('other')->all_tags($obj)], + [undef], + 'other all_tags'); }; subtest 'with tags' => sub { @@ -67,6 +85,22 @@ subtest 'with tags' => sub { is($obj->stuff,3,'default'); is($obj->stuff_tagged($opts),7,'stuff tagged'); is($obj->other_multi($opts),'foo','other tagged'); + + cmp_deeply( + [$obj->meta->get_attribute('stuff')->all_tags($obj)], + bag(undef,'one'), + 'stuff all_tags'); + cmp_deeply( + [$obj->meta->get_attribute('other')->all_tags($obj)], + bag('one'), + 'other all_tags'); + + my @tags = $obj->meta->get_attribute('stuff')->all_tags($obj); + my $pred=$obj->meta->get_attribute('stuff')->multi_predicate; + for my $tag (@tags) { + ok($obj->$pred({tag=>$tag}),"stuff has tag @{[ $tag || 'undef' ]}"); + } + }; done_testing(); |