From 0ca397ab7065dede71a90f3a6eed14d4ffe3e259 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 16 May 2016 13:08:20 +0100 Subject: [PATCH] Kana: Updating tests for text template --- t/Kana.t | 169 +++++++++++-------------------------------------------- 1 file changed, 32 insertions(+), 137 deletions(-) diff --git a/t/Kana.t b/t/Kana.t index 91e76311c..f75262095 100755 --- a/t/Kana.t +++ b/t/Kana.t @@ -9,162 +9,57 @@ use utf8; zci answer_type => 'kana'; zci is_cached => 1; +sub build_test +{ + my ($text, $title, $script, $subtitle) = @_; + return test_zci($text, structured_answer => { + data => { + title => $title, + subtitle => "Convert to $script: $subtitle", + }, + templates => { + group => 'text' + } + }); +} + + ddg_goodie_test( ['DDG::Goodie::Kana'], # romaji -> hiragana - 'ahiru in hiragana' => test_zci( - 'ahiru converted to hiragana is あひる', - structured_answer => { - input => ['ahiru'], - operation => 'Convert to Hiragana', - result => 'あひる' - } - ), - 'nihon no daigaku! to hiragana' => test_zci( - 'nihon no daigaku! converted to hiragana is にほん の だいがく!', - structured_answer => { - input => ['nihon no daigaku!'], - operation => 'Convert to Hiragana', - result => 'にほん の だいがく!' - } - ), - + 'ahiru in hiragana' => build_test('ahiru converted to hiragana is あひる','あひる', "Hiragana", 'ahiru'), + 'nihon no daigaku! to hiragana' => build_test('nihon no daigaku! converted to hiragana is にほん の だいがく!', 'にほん の だいがく!', 'Hiragana', 'nihon no daigaku!'), # romaji -> katakana - 'ahiru in katakana' => test_zci( - 'ahiru converted to katakana is アヒル', - structured_answer => { - input => ['ahiru'], - operation => 'Convert to Katakana', - result => 'アヒル' - } - ), - 'kirin, banana to katakana' => test_zci( - 'kirin, banana converted to katakana is キリン、 バナナ', - structured_answer => { - input => ['kirin, banana'], - operation => 'Convert to Katakana', - result => 'キリン、 バナナ' - } - ), + 'ahiru in katakana' => build_test('ahiru converted to katakana is アヒル', 'アヒル', "Katakana", "ahiru",), + 'kirin, banana to katakana' => build_test('kirin, banana converted to katakana is キリン、 バナナ','キリン、 バナナ', "Katakana", 'kirin, banana'), # katakana -> romaji - 'アヒル to romaji' => test_zci( - 'アヒル converted to romaji is ahiru', - structured_answer => { - input => ['アヒル'], - operation => 'Convert to Romaji', - result => 'ahiru' - } - ), - 'キリン、 バナナ in romaji' => test_zci( - 'キリン、 バナナ converted to romaji is kirin, banana', - structured_answer => { - input => ['キリン、 バナナ'], - operation => 'Convert to Romaji', - result => 'kirin, banana' - } - ), + 'アヒル to romaji' => build_test('アヒル converted to romaji is ahiru', 'ahiru', 'Romaji', 'アヒル'), + 'キリン、 バナナ in romaji' => build_test('キリン、 バナナ converted to romaji is kirin, banana', 'kirin, banana', "Romaji", 'キリン、 バナナ'), # hiragana -> romaji - 'あひる in romaji' => test_zci( - 'あひる converted to romaji is ahiru', - structured_answer => { - input => ['あひる'], - operation => 'Convert to Romaji', - result => 'ahiru' - } - ), - 'すみません、 いま なんじ ですか。 to romaji' => test_zci( - 'すみません、 いま なんじ ですか。 converted to romaji is sumimasen, ima nanji desuka.', - structured_answer => { - input => ['すみません、 いま なんじ ですか。'], - operation => 'Convert to Romaji', - result => 'sumimasen, ima nanji desuka.' - } - ), + 'あひる in romaji' => build_test('あひる converted to romaji is ahiru', "ahiru", "Romaji", 'あひる'), + 'すみません、 いま なんじ ですか。 to romaji' => build_test('すみません、 いま なんじ ですか。 converted to romaji is sumimasen, ima nanji desuka.', 'sumimasen, ima nanji desuka.', "Romaji", 'すみません、 いま なんじ ですか。'), # hiragana -> katakana - 'はつしぐれさるもこみのをほしげなり to katakana' => test_zci( - 'はつしぐれさるもこみのをほしげなり converted to katakana is ハツシグレサルモコミノヲホシゲナリ', - structured_answer => { - input => ['はつしぐれさるもこみのをほしげなり'], - operation => 'Convert to Katakana', - result => 'ハツシグレサルモコミノヲホシゲナリ' - } - ), + 'はつしぐれさるもこみのをほしげなり to katakana' => build_test('はつしぐれさるもこみのをほしげなり converted to katakana is ハツシグレサルモコミノヲホシゲナリ', 'ハツシグレサルモコミノヲホシゲナリ', "Katakana", 'はつしぐれさるもこみのをほしげなり'), # katakana -> hirgana - 'ハツシグレサルモコミノヲホシゲナリ to hiragana' => test_zci( - 'ハツシグレサルモコミノヲホシゲナリ converted to hiragana is はつしぐれさるもこみのをほしげなり', - structured_answer => { - input => ['ハツシグレサルモコミノヲホシゲナリ'], - operation => 'Convert to Hiragana', - result => 'はつしぐれさるもこみのをほしげなり' - } - ), + 'ハツシグレサルモコミノヲホシゲナリ to hiragana' => build_test('ハツシグレサルモコミノヲホシゲナリ converted to hiragana is はつしぐれさるもこみのをほしげなり', 'はつしぐれさるもこみのをほしげなり', "Hiragana", 'ハツシグレサルモコミノヲホシゲナリ'), # kana -> romaji - 'ハンバーガーはたべものです。 to romaji' => test_zci( - 'ハンバーガーはたべものです。 converted to romaji is hambāgāhatabemonodesu.', - structured_answer => { - input => ['ハンバーガーはたべものです。'], - operation => 'Convert to Romaji', - result => 'hambāgāhatabemonodesu.' - } - ), + 'ハンバーガーはたべものです。 to romaji' => build_test('ハンバーガーはたべものです。 converted to romaji is hambāgāhatabemonodesu.', 'hambāgāhatabemonodesu.', 'Romaji', 'ハンバーガーはたべものです。'), # japanese puncuation -> romaji - '{[(?!。、『』あ「」,:)]} to romaji' => test_zci( - '{[(?!。、『』あ「」,:)]} converted to romaji is {[(?!.,""a\'\',:)]}', - structured_answer => { - input => ['{[(?!。、『』あ「」,:)]}'], - operation => 'Convert to Romaji', - result => '{[(?!.,""a\'\',:)]}' - } - ), - 'ええ! in romaji' => test_zci( - 'ええ! converted to romaji is ē!', - structured_answer => { - input => ['ええ!'], - operation => 'Convert to Romaji', - result => 'ē!' - } - ), + '{[(?!。、『』あ「」,:)]} to romaji' => build_test('{[(?!。、『』あ「」,:)]} converted to romaji is {[(?!.,""a\'\',:)]}', '{[(?!.,""a\'\',:)]}', 'Romaji', '{[(?!。、『』あ「」,:)]}'), + 'ええ! in romaji' => build_test('ええ! converted to romaji is ē!', 'ē!', 'Romaji', 'ええ!'), # Hiragana goodie tests - 'a hiragana' => test_zci( - 'a converted to hiragana is あ', - structured_answer => { - input => ['a'], - operation => 'Convert to Hiragana', - result => 'あ' - } - ), - 'konnichiwa hiragana' => test_zci( - 'konnichiwa converted to hiragana is こんにちわ', - structured_answer => { - input => ['konnichiwa'], - operation => 'Convert to Hiragana', - result => 'こんにちわ' - } - ), - 'nihon hiragana' => test_zci( - 'nihon converted to hiragana is にほん', - structured_answer => { - input => ['nihon'], - operation => 'Convert to Hiragana', - result => 'にほん' - } - ), - 'tsukue no ue hiragana' => test_zci( - 'tsukue no ue converted to hiragana is つくえ の うえ', - structured_answer => { - input => ['tsukue no ue'], - operation => 'Convert to Hiragana', - result => 'つくえ の うえ' - } - ), + 'a hiragana' => build_test('a converted to hiragana is あ', 'あ', 'Hiragana', 'a'), + 'konnichiwa hiragana' => build_test('konnichiwa converted to hiragana is こんにちわ', 'こんにちわ', 'Hiragana', 'konnichiwa'), + 'nihon hiragana' => build_test('nihon converted to hiragana is にほん', 'にほん', 'Hiragana', 'nihon'), + 'tsukue no ue hiragana' => build_test('tsukue no ue converted to hiragana is つくえ の うえ', 'つくえ の うえ', 'Hiragana', 'tsukue no ue'), # Invalid inputs 'romaji' => undef,