1use strict; 2use warnings; 3 4use Test::More; 5 6{ 7 package Some::Identifiable; 8 use Moose; 9 10 with(qw( 11 Role::Identifiable::HasTags 12 Role::Identifiable::HasIdent 13 )); 14 15 sub x_tags { qw(whatever) } 16} 17 18{ 19 my $thing = Some::Identifiable->new({ 20 ident => 'pants too small', 21 tags => [ qw(foo-bar zug) ], 22 }); 23 24 isa_ok($thing, 'Some::Identifiable', 'the identifiable object'); 25 26 is($thing->ident, 'pants too small', '...has the right ident'); 27 28 ok( 29 $thing->has_tag('foo-bar') && $thing->has_tag('whatever') && ! $thing->has_tag('xyz'), 30 "...and its tags seem correct via ->has_tag", 31 ); 32} 33 34{ 35 for my $test ( 36 [ defined => undef ], 37 [ nonempty => '' ], 38 [ 'non-left padded' => ' ident' ], 39 [ 'non-right padded' => 'ident ' ], 40 [ 'non-floating' => ' floating ' ], 41 ) { 42 ok( 43 ! eval { Some::Identifiable->new({ ident => $test->[1] }); 1 }, 44 "ident must be $test->[0]", 45 ); 46 } 47} 48 49done_testing; 50