AI-MicroStructure
view release on metacpan or search on metacpan
use Test::More;
use strict;
use AI::MicroStructure;
END {
my %tests = (
':all' => [
qw( grinder lacravate echo book jq dm stomakc maddingue
arhuman davorg clkao dha)
],
'fr' => [
qw( grinder lacravate echo book jq dm stomakc maddingue arhuman )
],
'fr/paris' => [qw( grinder lacravate echo book )],
'fr/lyon' => [qw( book jq dm stomakc )],
'fr/lyon/perrache' => [qw( book )],
'fr/lyon/ailleurs' => [qw( jq dm stomakc )],
'fr/marseille' => [qw( maddingue arhuman )],
'uk' => [qw( davorg clkao )],
'uk/london' => [qw( davorg clkao )],
'us' => ['dha'],
'us/new-york' => ['dha'],
'mars' => [],
);
plan tests => ( 2 + keys %tests ) * 4 + 8;
my @categories = AI::MicroStructure::mongers->categories();
is_deeply(
[ sort @categories ],
[ grep { $_ ne ':all' } sort keys %tests ],
"All categories (class)"
);
@categories = AI::MicroStructure::mongers->new()->categories();
is_deeply(
[ sort @categories ],
[ grep { $_ ne ':all' } sort keys %tests ],
"All categories (instances)"
);
for my $args ( [], map { [ category => $_ ] } @categories, ':all', 'zz' ) {
my $meta = AI::MicroStructure::mongers->new(@$args);
my $category = $args->[1] || 'fr/lyon';
$category = 'fr/lyon'
if $category eq 'zz'; # check fallback to default
my ( $one, $four ) = ( 1, 4 );
( $one, $four ) = ( 0, 0 ) if $category eq 'mars'; # empty list
my @mongers = $meta->name();
is( $meta->category(), $category, "category() is $category" );
is( @mongers, $one, "Single item ($one $category)" );
@mongers = $meta->name(4);
is( @mongers, $four, "Four items ($four $category)" );
@mongers = sort $meta->name(0);
is_deeply(
\@mongers,
[ sort @{ $tests{$category} } ],
"All items ($category)"
);
( run in 0.804 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )