2016-07-04 10:57:54 -07:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
|
|
|
use Test::Deep;
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
2016-07-04 11:28:09 -07:00
|
|
|
zci answer_type => "rgb_color";
|
2016-07-05 01:29:42 -07:00
|
|
|
zci is_cached => 0;
|
2016-07-04 10:57:54 -07:00
|
|
|
|
|
|
|
sub build_structured_answer {
|
|
|
|
my @test_params = @_;
|
|
|
|
|
2016-07-05 01:29:42 -07:00
|
|
|
my %answer = build_answer_random();
|
|
|
|
|
|
|
|
return $answer{text_answer},
|
2016-07-04 10:57:54 -07:00
|
|
|
structured_answer => {
|
|
|
|
|
2016-07-05 01:29:42 -07:00
|
|
|
data => $answer{data},
|
2016-07-04 10:57:54 -07:00
|
|
|
|
|
|
|
templates => {
|
|
|
|
group => "text",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-07-05 01:29:42 -07:00
|
|
|
my $color_re = qr/\p{XDigit}{6}/i;
|
|
|
|
|
|
|
|
sub build_answer_random {
|
|
|
|
return (
|
|
|
|
text_answer => re($color_re),
|
|
|
|
data => {
|
|
|
|
title => re($color_re),
|
|
|
|
subtitle => 'Random color',
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-07-04 10:57:54 -07:00
|
|
|
sub build_test { test_zci(build_structured_answer(@_)) }
|
|
|
|
|
|
|
|
ddg_goodie_test(
|
2016-07-05 00:52:33 -07:00
|
|
|
[qw( DDG::Goodie::RgbColor )],
|
2016-07-05 01:29:42 -07:00
|
|
|
# Random colors
|
|
|
|
'random color' => build_test(),
|
2016-07-05 01:38:04 -07:00
|
|
|
# Using 'colour'
|
|
|
|
'random colour' => build_test(),
|
2016-07-04 10:57:54 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
done_testing;
|