FlipText: use structured answer.

master
Matt Miller 2014-10-07 13:13:19 +02:00
parent d8f710d4e8
commit 37c69da9c7
2 changed files with 50 additions and 14 deletions

View File

@ -7,8 +7,8 @@ use Text::UpsideDown;
triggers startend => "flip text", "mirror text", "spin text", "rotate text";
zci is_cached => 1;
zci answer_type => "flip_text";
zci is_cached => 1;
primary_example_queries 'flip text sentence';
secondary_example_queries 'mirror text hello';
@ -17,13 +17,23 @@ name 'FlipText';
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/FlipText.pm';
category 'transformations';
topics 'words_and_games';
attribution web => [ 'robert.io', 'Robert Picard' ],
github => [ 'http://github.com/rpicard', 'rpicard'],
twitter => ['http://twitter.com/__rlp', '__rlp'];
attribution web => ['robert.io', 'Robert Picard'],
github => ['http://github.com/rpicard', 'rpicard'],
twitter => ['http://twitter.com/__rlp', '__rlp'];
handle remainder => sub {
return unless $_;
return upside_down( $_ );
my $input = $_;
return unless $input;
my $result = upside_down($input);
return $result,
structured_answer => {
input => [html_enc($input)],
operation => 'flip text',
result => html_enc($result),
};
};
1;

View File

@ -7,16 +7,42 @@ use Test::More;
use DDG::Test::Goodie;
zci answer_type => 'flip_text';
zci is_cached => 1;
zci is_cached => 1;
ddg_goodie_test(
[qw(
DDG::Goodie::FlipText
)],
'flip text test' => test_zci("\x{0287}\x{0073}\x{01DD}\x{0287}"),
'mirror text test' => test_zci("\x{0287}\x{0073}\x{01DD}\x{0287}"),
'flip text my sentence' => test_zci('ǝɔuǝʇuǝs ʎɯ'),
'mirror text text' => test_zci('ʇxǝʇ'),
[qw( DDG::Goodie::FlipText)],
'flip text test' => test_zci(
"\x{0287}\x{0073}\x{01DD}\x{0287}",
structured_answer => {
input => ['test'],
operation => 'flip text',
result => 'ʇsǝʇ'
}
),
'mirror text test' => test_zci(
"\x{0287}\x{0073}\x{01DD}\x{0287}",
structured_answer => {
input => ['test'],
operation => 'flip text',
result => 'ʇsǝʇ'
}
),
'flip text my sentence' => test_zci(
'ǝɔuǝʇuǝs ʎɯ',
structured_answer => {
input => ['my sentence'],
operation => 'flip text',
result => 'ǝɔuǝʇuǝs ʎɯ'
}
),
'mirror text text' => test_zci(
'ʇxǝʇ',
structured_answer => {
input => ['text'],
operation => 'flip text',
result => 'ʇxǝʇ'
}
),
);
done_testing;