From 703829760536f68311dc5510e9c441419371e34e Mon Sep 17 00:00:00 2001 From: kbramhe Date: Sun, 31 Jan 2016 07:24:52 +0000 Subject: [PATCH 01/91] added cheat sheet for evil-mode for emacs --- .../cheat_sheets/json/emacs-evil-mode.json | 195 ++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 share/goodie/cheat_sheets/json/emacs-evil-mode.json diff --git a/share/goodie/cheat_sheets/json/emacs-evil-mode.json b/share/goodie/cheat_sheets/json/emacs-evil-mode.json new file mode 100644 index 000000000..856e3b49a --- /dev/null +++ b/share/goodie/cheat_sheets/json/emacs-evil-mode.json @@ -0,0 +1,195 @@ +{ + "id": "emacs_evil_mode_cheat_sheet", + "name": "Evil-Mode for Emacs", + "description": "Shortcuts for the Evil-mode of the Emacs editor", + "metadata": { + "sourceName": "GiHub", + "sourceUrl": "https://github.com/amirrajan/devbox/wiki/EMACS-Evil-Cheat-Sheet" + }, + "template_type": "keyboard", + "aliases": [ + "evil emacs", + "emacs evil-mode", + "emacs evil mode", + "evil-mode emacs", + "evil mode emacs", + "evil-mode for emacs", + "evil mode for emacs", + "evil emacs mode" + ], + "section_order": [ + "Editing Text", + "Window Navigation", + "Discovery" + + ], + "sections": { + "Editing Text": [ + { + "key": "ESC", + "val": "Command Mode" + }, + { + "key": ":w", + "val": "save" + }, + { + "key": ":q", + "val": "quit" + }, + { + "key": ":wq", + "val": "save and quit" + }, + { + "key": ":wqa", + "val": "save quit all" + }, + { + "key": "hjkl", + "val": "to navigate" + }, + { + "key": "w", + "val": "to move forward by one word" + }, + { + "key": "b", + "val": "to move back by one word" + }, + { + "key": "shift+[", + "val": "move up by new lines" + }, + { + "key": "shift+]", + "val": "to move down by new lines" + }, + { + "key": "yy", + "val": "copy line" + }, + { + "key": "dd", + "val": "delete line" + }, + { + "key": "cc", + "val": "change line" + }, + { + "key": "Y", + "val": "copy till the end of line" + }, + { + "key": "D", + "val": "delete till the end of line" + }, + { + "key": "C", + "val": "change till the end of line" + }, + { + "key": "yw", + "val": "yank word" + }, + { + "key": "dw", + "val": "delete word" + }, + { + "key": "cw", + "val": "change word" + }, + { + "key": "gg", + "val": "go to top of file" + }, + { + "key": "G", + "val": "goto bottom of file" + } + + ], + "Window Navigation": [ + { + "key": ",g", + "val": "go to file" + }, + { + "key": ",b", + "val": "view recently visited files" + }, + { + "key": ",m", + "val": "new vertical split" + }, + { + "key": ":split", + "val": "new horizontal split" + }, + { + "key": ",.", + "val": "open current directory" + }, + { + "key": "C-h , C-j ,C-k ,C-l", + "val": "navigate between windows" + }, + { + "key": ",)", + "val": "previous buffer" + }, + { + "key": ",(", + "val": "next buffer" + }, + { + "key": ":ack ENT", + "val": "search across files" + }, + { + "key": ",f", + "val": "next search result" + }, + { + "key": ",d", + "val": "previous search result" + }, + { + "key": "CTRL+v", + "val": "visula block mode" + }, + { + "key": "While in visual Block Mode shift + i", + "val": "Insert Mode to append text to selection from Visual Block Mode " + } + ], + "Discovery": [ + { + "key": ":describe-char", + "val": "describes the char underneath the cursor, allows you to change color theme from there" + }, + { + "key": ":customize-face", + "val": "editor for changing all color themes use tab and shift+tab to navigate" + }, + { + "key": "F1 k KEYSTROKE", + "val": " press F1 followed by k, then enter a key stroke. You'll get information about what editor method was invoked" + }, + { + "key": "F1 f METHODNAME", + "val": "gives information about an editor method" + }, + { + "key": "F1 a SEARCH", + "val": "search for an editor method containing the search term" + }, + { + "key": ":METHODNAME", + "val": "invoke editor method" + } + ] + } +} From 753b2574961447be3f6ff061fb51e6d105dd8f18 Mon Sep 17 00:00:00 2001 From: ehuang Date: Tue, 29 Mar 2016 05:45:48 +0000 Subject: [PATCH 02/91] Fix for Braille: bad triggers #2771 IA: https://duck.co/ia/view/braille --- lib/DDG/Goodie/Braille.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/DDG/Goodie/Braille.pm b/lib/DDG/Goodie/Braille.pm index 158f91aad..49eaec444 100644 --- a/lib/DDG/Goodie/Braille.pm +++ b/lib/DDG/Goodie/Braille.pm @@ -7,7 +7,7 @@ use DDG::Goodie; use Convert::Braille; use utf8; -triggers query_raw => qr/\p{Braille}|braille/i; +triggers query_raw => qr/\p{Braille}|( in|to){1} braille$|^braille:/i; zci is_cached => 1; @@ -16,20 +16,24 @@ my $braille_space = '⠀'; # the braille unicode space (U+2800) handle query_raw => sub { my $query = $_; - $query =~ s/translate to braille |( in)? braille$|^braille //; + $query =~ s/( in|to){1} braille$|^braille: //; return unless $query; my $result; + my $type; if ($query =~ /\p{Braille}/) { $result = join(" ", map { lc(brailleDotsToAscii($_)) } split(/$braille_space/, $query)); + $type = "Ascii/Unicode"; } else { $result = join($braille_space, map { brailleAsciiToUnicode(uc $_) } split(/\s/, $query)); + $type = "Braille"; } - return $result . ' (Braille)', + return answer => $result, + answer_type => $type, structured_answer => { - input => [html_enc($query)], + input => [$query], operation => 'Braille translation', result => html_enc($result), }; From 0ad0890f8463ffa7eebe709bd397d730d443e066 Mon Sep 17 00:00:00 2001 From: ehuang Date: Wed, 30 Mar 2016 03:55:05 +0000 Subject: [PATCH 03/91] Structured Answer to Full Templates. Update test as well. --- lib/DDG/Goodie/Braille.pm | 23 ++++++----- t/Braille.t | 83 ++++++++++++++------------------------- 2 files changed, 42 insertions(+), 64 deletions(-) diff --git a/lib/DDG/Goodie/Braille.pm b/lib/DDG/Goodie/Braille.pm index 49eaec444..2a4ce6cbe 100644 --- a/lib/DDG/Goodie/Braille.pm +++ b/lib/DDG/Goodie/Braille.pm @@ -7,7 +7,7 @@ use DDG::Goodie; use Convert::Braille; use utf8; -triggers query_raw => qr/\p{Braille}|( in|to){1} braille$|^braille:/i; +triggers query_raw => qr/\p{Braille}|( in| to){1} braille$|^braille:/i; zci is_cached => 1; @@ -16,26 +16,29 @@ my $braille_space = '⠀'; # the braille unicode space (U+2800) handle query_raw => sub { my $query = $_; - $query =~ s/( in|to){1} braille$|^braille: //; + $query =~ s/( in| to){1} braille$|^braille:\s?//; return unless $query; - my $result; + my $response; my $type; if ($query =~ /\p{Braille}/) { - $result = join(" ", map { lc(brailleDotsToAscii($_)) } split(/$braille_space/, $query)); + $response = join(" ", map { lc(brailleDotsToAscii($_)) } split(/$braille_space/, $query)); $type = "Ascii/Unicode"; } else { - $result = join($braille_space, map { brailleAsciiToUnicode(uc $_) } split(/\s/, $query)); + $response = join($braille_space, map { brailleAsciiToUnicode(uc $_) } split(/\s/, $query)); $type = "Braille"; } - return answer => $result, - answer_type => $type, + return $response, structured_answer => { - input => [$query], - operation => 'Braille translation', - result => html_enc($result), + data => { + title => $response, + subtitle => 'Translate "' . $query . '" to ' . $type, + }, + templates => { + group => 'text', + }, }; }; diff --git a/t/Braille.t b/t/Braille.t index 1cf9054dc..2efbe72f4 100644 --- a/t/Braille.t +++ b/t/Braille.t @@ -10,62 +10,37 @@ use utf8; zci answer_type => 'braille'; zci is_cached => 1; +sub build_structured_answer { + my ($query, $response, $type) = @_; + return $response, + structured_answer => { + data => { + title => $response, + subtitle => 'Translate "' . $query . '" to ' . $type, + }, + templates => { + group => 'text', + } + }, +} + +sub build_test { test_zci(build_structured_answer(@_)) } + ddg_goodie_test( [qw( DDG::Goodie::Braille)], - 'hello in braille' => test_zci( - "⠓⠑⠇⠇⠕ (Braille)", - structured_answer => { - input => ['hello'], - operation => 'Braille translation', - result => '⠓⠑⠇⠇⠕' - } - ), - '⠓⠑⠇⠇⠕' => test_zci( - "hello (Braille)", - structured_answer => { - input => ['⠓⠑⠇⠇⠕'], - operation => 'Braille translation', - result => 'hello' - } - ), - 'translate to braille translate to braille' => test_zci( - "⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑ (Braille)", - structured_answer => { - input => ['translate to braille'], - operation => 'Braille translation', - result => - '⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑' - } - ), - '⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑' => test_zci( - "translate to braille (Braille)", - structured_answer => { - input => [ - '⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑' - ], - operation => 'Braille translation', - result => 'translate to braille' - } - - ), - 'braille asdf k' => test_zci( - "⠁⠎⠙⠋⠀⠅ (Braille)", - structured_answer => { - input => ['asdf k'], - operation => 'Braille translation', - result => '⠁⠎⠙⠋⠀⠅' - } - - ), - '⠁⠎⠙⠋⠀⠅' => test_zci( - "asdf k (Braille)", - structured_answer => { - input => ['⠁⠎⠙⠋⠀⠅'], - operation => 'Braille translation', - result => 'asdf k' - } - - ), + # Ascii/Unicode -> Braille + 'hello in braille' => build_test('hello', '⠓⠑⠇⠇⠕', 'Braille'), + 'hello to braille' => build_test('hello', '⠓⠑⠇⠇⠕', 'Braille'), + 'translate to braille to braille' => build_test('translate to braille', '⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑', 'Braille'), + 'braille: asdf k' => build_test('asdf k', '⠁⠎⠙⠋⠀⠅', 'Braille'), + # Braille -> Ascii/Unicode + '⠓⠑⠀⠇⠇⠕' => build_test('⠓⠑⠀⠇⠇⠕', 'he llo', 'Ascii/Unicode'), + '⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑' => build_test('⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑', 'translate to braille', 'Ascii/Unicode'), + '⠁⠎⠙⠋⠀⠅' => build_test('⠁⠎⠙⠋⠀⠅', 'asdf k', 'Ascii/Unicode'), + # Invalid Queries + 'braille asdf k' => undef, + 'how long to learn braille' => undef, + 'braille to braille is good' => undef, ); done_testing; From 59de6b6b1b40a3eeb070ff0a4dabe4ac1287418a Mon Sep 17 00:00:00 2001 From: ehuang Date: Wed, 6 Apr 2016 06:35:47 +0000 Subject: [PATCH 04/91] Update subtitle string and add html_enc for input. --- lib/DDG/Goodie/Braille.pm | 2 +- t/Braille.t | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/DDG/Goodie/Braille.pm b/lib/DDG/Goodie/Braille.pm index 2a4ce6cbe..3930dd16a 100644 --- a/lib/DDG/Goodie/Braille.pm +++ b/lib/DDG/Goodie/Braille.pm @@ -34,7 +34,7 @@ handle query_raw => sub { structured_answer => { data => { title => $response, - subtitle => 'Translate "' . $query . '" to ' . $type, + subtitle => 'Braille translation: ' . html_enc($query), }, templates => { group => 'text', diff --git a/t/Braille.t b/t/Braille.t index 2efbe72f4..d853f6d05 100644 --- a/t/Braille.t +++ b/t/Braille.t @@ -11,12 +11,12 @@ zci answer_type => 'braille'; zci is_cached => 1; sub build_structured_answer { - my ($query, $response, $type) = @_; + my ($query, $response) = @_; return $response, structured_answer => { data => { title => $response, - subtitle => 'Translate "' . $query . '" to ' . $type, + subtitle => 'Braille translation: ' . $query, }, templates => { group => 'text', @@ -29,14 +29,14 @@ sub build_test { test_zci(build_structured_answer(@_)) } ddg_goodie_test( [qw( DDG::Goodie::Braille)], # Ascii/Unicode -> Braille - 'hello in braille' => build_test('hello', '⠓⠑⠇⠇⠕', 'Braille'), - 'hello to braille' => build_test('hello', '⠓⠑⠇⠇⠕', 'Braille'), - 'translate to braille to braille' => build_test('translate to braille', '⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑', 'Braille'), - 'braille: asdf k' => build_test('asdf k', '⠁⠎⠙⠋⠀⠅', 'Braille'), + 'hello in braille' => build_test('hello', '⠓⠑⠇⠇⠕'), + 'hello to braille' => build_test('hello', '⠓⠑⠇⠇⠕'), + 'translate to braille to braille' => build_test('translate to braille', '⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑'), + 'braille: asdf k' => build_test('asdf k', '⠁⠎⠙⠋⠀⠅'), # Braille -> Ascii/Unicode - '⠓⠑⠀⠇⠇⠕' => build_test('⠓⠑⠀⠇⠇⠕', 'he llo', 'Ascii/Unicode'), - '⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑' => build_test('⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑', 'translate to braille', 'Ascii/Unicode'), - '⠁⠎⠙⠋⠀⠅' => build_test('⠁⠎⠙⠋⠀⠅', 'asdf k', 'Ascii/Unicode'), + '⠓⠑⠀⠇⠇⠕' => build_test('⠓⠑⠀⠇⠇⠕', 'he llo'), + '⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑' => build_test('⠞⠗⠁⠝⠎⠇⠁⠞⠑⠀⠞⠕⠀⠃⠗⠁⠊⠇⠇⠑', 'translate to braille'), + '⠁⠎⠙⠋⠀⠅' => build_test('⠁⠎⠙⠋⠀⠅', 'asdf k'), # Invalid Queries 'braille asdf k' => undef, 'how long to learn braille' => undef, From 214286be14c435639fd337f185600e9d77fa4f26 Mon Sep 17 00:00:00 2001 From: kbramhe Date: Mon, 18 Apr 2016 21:34:25 +0000 Subject: [PATCH 05/91] correction of indentation and spelling mistakes --- share/goodie/cheat_sheets/json/emacs-evil-mode.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/share/goodie/cheat_sheets/json/emacs-evil-mode.json b/share/goodie/cheat_sheets/json/emacs-evil-mode.json index 856e3b49a..b9c7275b6 100644 --- a/share/goodie/cheat_sheets/json/emacs-evil-mode.json +++ b/share/goodie/cheat_sheets/json/emacs-evil-mode.json @@ -3,7 +3,7 @@ "name": "Evil-Mode for Emacs", "description": "Shortcuts for the Evil-mode of the Emacs editor", "metadata": { - "sourceName": "GiHub", + "sourceName": "GitHub", "sourceUrl": "https://github.com/amirrajan/devbox/wiki/EMACS-Evil-Cheat-Sheet" }, "template_type": "keyboard", @@ -21,7 +21,6 @@ "Editing Text", "Window Navigation", "Discovery" - ], "sections": { "Editing Text": [ @@ -162,7 +161,7 @@ }, { "key": "While in visual Block Mode shift + i", - "val": "Insert Mode to append text to selection from Visual Block Mode " + "val": "Insert Mode to append text to selection from Visual Block Mode" } ], "Discovery": [ @@ -174,9 +173,9 @@ "key": ":customize-face", "val": "editor for changing all color themes use tab and shift+tab to navigate" }, - { + { "key": "F1 k KEYSTROKE", - "val": " press F1 followed by k, then enter a key stroke. You'll get information about what editor method was invoked" + "val": "press F1 followed by k, then enter a key stroke to find information about what editor method was invoked" }, { "key": "F1 f METHODNAME", From c08a3f663fa489180b277fc019c2075ac3be57e6 Mon Sep 17 00:00:00 2001 From: tagawa Date: Thu, 21 Apr 2016 13:45:32 +0000 Subject: [PATCH 06/91] Logarithms cheatsheet: Fixed description --- share/goodie/cheat_sheets/json/logarithms.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/goodie/cheat_sheets/json/logarithms.json b/share/goodie/cheat_sheets/json/logarithms.json index 78df4ec6a..bcac98f1e 100644 --- a/share/goodie/cheat_sheets/json/logarithms.json +++ b/share/goodie/cheat_sheets/json/logarithms.json @@ -1,7 +1,7 @@ { "id": "logarithms_cheat_sheet", "name": "Logarithms", - "description": "displayed as subtitle of the AnswerBar; optional", + "description": "List of logarithmic rules and formulae.", "metadata": { "sourceName": "SCRIBD", @@ -9,7 +9,7 @@ }, "aliases": [ - "logarithmic identities", "logarithms rules" + "logarithmic identities", "logarithms rules", "logarithm rules", "logarithm" ], "template_type": "reference", From f5523c71279d8a05154ebfcd60468c226b6b029f Mon Sep 17 00:00:00 2001 From: tagawa Date: Fri, 22 Apr 2016 06:17:24 +0000 Subject: [PATCH 07/91] Added more aliases --- share/goodie/cheat_sheets/json/logarithms.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/goodie/cheat_sheets/json/logarithms.json b/share/goodie/cheat_sheets/json/logarithms.json index bcac98f1e..04f5010ea 100644 --- a/share/goodie/cheat_sheets/json/logarithms.json +++ b/share/goodie/cheat_sheets/json/logarithms.json @@ -9,7 +9,10 @@ }, "aliases": [ - "logarithmic identities", "logarithms rules", "logarithm rules", "logarithm" + "logarithmic identities", "logarithms rules", + "logarithm identities", "logarithm rules", + "log identities", "log rules", + "logarithm" ], "template_type": "reference", From 99424df280ed811dacb2a1336b5b448449e672bf Mon Sep 17 00:00:00 2001 From: kbramhe Date: Fri, 22 Apr 2016 12:41:04 +0000 Subject: [PATCH 08/91] removed the error causing alias --- share/goodie/cheat_sheets/json/emacs-evil-mode.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/goodie/cheat_sheets/json/emacs-evil-mode.json b/share/goodie/cheat_sheets/json/emacs-evil-mode.json index b9c7275b6..9eb7b0941 100644 --- a/share/goodie/cheat_sheets/json/emacs-evil-mode.json +++ b/share/goodie/cheat_sheets/json/emacs-evil-mode.json @@ -10,9 +10,7 @@ "aliases": [ "evil emacs", "emacs evil-mode", - "emacs evil mode", "evil-mode emacs", - "evil mode emacs", "evil-mode for emacs", "evil mode for emacs", "evil emacs mode" From b684159303efe3e5550cd352abcfb9a5f4739111 Mon Sep 17 00:00:00 2001 From: Sebastian Nemak Date: Thu, 28 Apr 2016 21:38:21 +0200 Subject: [PATCH 09/91] Create cheat sheet for ZFS --- share/goodie/cheat_sheets/json/zfs.json | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 share/goodie/cheat_sheets/json/zfs.json diff --git a/share/goodie/cheat_sheets/json/zfs.json b/share/goodie/cheat_sheets/json/zfs.json new file mode 100644 index 000000000..2905c0967 --- /dev/null +++ b/share/goodie/cheat_sheets/json/zfs.json @@ -0,0 +1,44 @@ +{ + "id": "zfs_cheat_sheet", + "name": "ZFS", + "description": "The combined file system and logical volume manager", + "metadata": { + "sourceName": "ZFS", + "sourceUrl": "https://www.freebsd.org/doc/handbook/zfs.html" + }, + "aliases": [ + "zfs", + "zpool" + ], + "template_type": "terminal", + "section_order": [ + "zPools", + "zDatasets" + ], + "sections": { + "zPools": [ + { + "key": "zpool list", + "val": "List pools." + }, + { + "key": "zpool status", + "val": "Check disk status." + } + ], + "zDatasets": [ + { + "key": "zfs list", + "val": "List datasets and pools." + }, + { + "key": "zfs snaphot -r $POOL/$DATASET@$SNAPSHOTNAME", + "val": "Takes a recursiv snaphot of dataset." + }, + { + "key": "zfs list -t snapshot /", + "val": "Display a list of snapshots." + } + ] + } +} From 77a5c13e915ca91aca0f21de2a84b5224871038a Mon Sep 17 00:00:00 2001 From: Sebastian Nemak Date: Fri, 29 Apr 2016 11:42:02 +0200 Subject: [PATCH 10/91] fix testing failure; update sourceName $ duckpan test CheatSheets Display 1 testing FAILURE: aliases contain the cheat sheet name (zfs) --- share/goodie/cheat_sheets/json/zfs.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/goodie/cheat_sheets/json/zfs.json b/share/goodie/cheat_sheets/json/zfs.json index 2905c0967..0058eda38 100644 --- a/share/goodie/cheat_sheets/json/zfs.json +++ b/share/goodie/cheat_sheets/json/zfs.json @@ -3,11 +3,11 @@ "name": "ZFS", "description": "The combined file system and logical volume manager", "metadata": { - "sourceName": "ZFS", + "sourceName": "FreeBSD handbook - The Z File System (ZFS)", "sourceUrl": "https://www.freebsd.org/doc/handbook/zfs.html" }, "aliases": [ - "zfs", + "z file system", "zpool" ], "template_type": "terminal", From d32294e4a1498829d6e1443e3fb192b8326c8995 Mon Sep 17 00:00:00 2001 From: Jett Jackson Date: Sun, 1 May 2016 00:12:28 +1000 Subject: [PATCH 11/91] Move exit commands to top issue [FIXED] #2885 Mistake in previous commit. --- share/goodie/cheat_sheets/json/vim.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/goodie/cheat_sheets/json/vim.json b/share/goodie/cheat_sheets/json/vim.json index b144df7d4..b5c52ec5a 100644 --- a/share/goodie/cheat_sheets/json/vim.json +++ b/share/goodie/cheat_sheets/json/vim.json @@ -8,13 +8,13 @@ }, "template_type": "keyboard", "section_order": [ + "Exiting", "Cursor movement", "Insert mode - inserting/appending text", "Editing", "Marking text (visual mode)", "Visual commands", "Cut and paste", - "Exiting", "Search and replace", "Working with multiple files", "Tabs", From 8dac85c25df14532aeb92d58fe0d485e7b530481 Mon Sep 17 00:00:00 2001 From: hchienjo Date: Sat, 30 Apr 2016 14:38:02 +0000 Subject: [PATCH 12/91] remove improper use of shift when unpacking from @ARGV --- share/goodie/cheat_sheets/json/perl.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/goodie/cheat_sheets/json/perl.json b/share/goodie/cheat_sheets/json/perl.json index ecde6e453..d2820848e 100644 --- a/share/goodie/cheat_sheets/json/perl.json +++ b/share/goodie/cheat_sheets/json/perl.json @@ -132,7 +132,7 @@ }], "Basic Syntax": [{ "val": "Read command line params", - "key": "($a, $b) = shift(@ARGV);" + "key": "($a, $b) = (@ARGV);" }, { "val": "Define subroutine", "key": "sub p\\{my $var = shift; ...\\}" From 674368b2b40009cf6f950af4021842de9895bd1c Mon Sep 17 00:00:00 2001 From: rkokkelkoren Date: Sat, 30 Apr 2016 20:23:56 +0000 Subject: [PATCH 13/91] Expanded trigger words --- lib/DDG/Goodie/UnixTime.pm | 2 +- t/UnixTime.t | 45 +++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/DDG/Goodie/UnixTime.pm b/lib/DDG/Goodie/UnixTime.pm index f129d8f3f..985bfa756 100644 --- a/lib/DDG/Goodie/UnixTime.pm +++ b/lib/DDG/Goodie/UnixTime.pm @@ -8,7 +8,7 @@ use DateTime; use List::MoreUtils qw( uniq ); use Try::Tiny; -my @trigger_words = ("unixtime", "datetime", "unix timestamp", "unix time stamp", "unix epoch", "epoch", "timestamp", "unix time", "utc time", "utc now", "current utc", "time since epoch"); +my @trigger_words = ("unixtime", "datetime", "unix timestamp", "unix time stamp", "unix epoch", "epoch", "timestamp", "unix time", "utc time", "utc now", "current utc", "time since epoch", "epoch converter", "epoch time converter"); triggers startend => @trigger_words; zci answer_type => "time_conversion"; diff --git a/t/UnixTime.t b/t/UnixTime.t index 832b5886d..dfe24379a 100644 --- a/t/UnixTime.t +++ b/t/UnixTime.t @@ -83,28 +83,29 @@ ddg_goodie_test([qw( DDG::Goodie::UnixTime ) ], - 'unix time 0000000000000' => test_zci(@zero), - 'epoch 0' => test_zci(@zeroi), - 'utc time 0' => test_zci(@zeroi), - 'epoch 2147483647' => test_zci(@later), - '2147483647 epoch' => test_zci(@later), - 'timestamp 2147483647' => test_zci(@later), - 'utc time 2147483647' => test_zci(@later), - 'datetime' => test_zci(@now), - 'unix time' => test_zci(@now), - 'unix epoch' => test_zci(@now), - 'utc time' => test_zci(@now), - 'utc now' => test_zci(@now), - 'current utc' => test_zci(@now), - 'time since epoch' => test_zci(@now), - 'epoch -1234567890' => test_zci(@then), - '-1234567890 epoch' => test_zci(@then), - 'timestamp -1234567890' => test_zci(@then), - 'utc time -1234567890' => test_zci(@then), - 'timestamp' => undef, - 'time' => undef, - 'epoch' => undef, - 'unix time info' => undef, + 'unix time 0000000000000' => test_zci(@zero), + 'epoch 0' => test_zci(@zeroi), + 'utc time 0' => test_zci(@zeroi), + 'epoch 2147483647' => test_zci(@later), + '2147483647 epoch' => test_zci(@later), + 'timestamp 2147483647' => test_zci(@later), + 'utc time 2147483647' => test_zci(@later), + 'epoch converter 2147483647' => test_zci(@later), + 'datetime' => test_zci(@now), + 'unix time' => test_zci(@now), + 'unix epoch' => test_zci(@now), + 'utc time' => test_zci(@now), + 'utc now' => test_zci(@now), + 'current utc' => test_zci(@now), + 'time since epoch' => test_zci(@now), + 'epoch -1234567890' => test_zci(@then), + '-1234567890 epoch' => test_zci(@then), + 'timestamp -1234567890' => test_zci(@then), + 'utc time -1234567890' => test_zci(@then), + 'timestamp' => undef, + 'time' => undef, + 'epoch' => undef, + 'unix time info' => undef, ); done_testing; From f142424123c844379208fe74780147604d809ce1 Mon Sep 17 00:00:00 2001 From: harisphnx Date: Thu, 5 May 2016 05:44:54 +0000 Subject: [PATCH 14/91] Re-arranged operators according to precedence --- share/goodie/cheat_sheets/json/c.json | 86 +++++++++++++-------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/share/goodie/cheat_sheets/json/c.json b/share/goodie/cheat_sheets/json/c.json index 235d1dd4a..e4fb4ee54 100644 --- a/share/goodie/cheat_sheets/json/c.json +++ b/share/goodie/cheat_sheets/json/c.json @@ -23,18 +23,6 @@ ], "sections": { "Arithmetic Operators": [ - { - "val": "Basic assignment", - "key": "a = b" - }, - { - "val": "Addition", - "key": "a + b" - }, - { - "val": "Subtraction", - "key": "a - b" - }, { "val": "Unary plus (integer promotion)", "key": "+a" @@ -43,18 +31,6 @@ "val": "Unary minus (additive inverse)", "key": "-a" }, - { - "val": "Multiplication", - "key": "a * b" - }, - { - "val": "Division", - "key": "a / b" - }, - { - "val": "Modulo (integer remainder)", - "key": "a % b" - }, { "val": "Increment Prefix", "key": "++a" @@ -70,6 +46,30 @@ { "val": "Decrement Postfix", "key": "a--" + }, + { + "val": "Multiplication", + "key": "a * b" + }, + { + "val": "Division", + "key": "a / b" + }, + { + "val": "Modulo (integer remainder)", + "key": "a % b" + }, + { + "val": "Addition", + "key": "a + b" + }, + { + "val": "Subtraction", + "key": "a - b" + }, + { + "val": "Basic assignment", + "key": "a = b" } ], "Comparison Operators": [ @@ -78,21 +78,21 @@ "key": "a < b" }, { - "val": "a equal to b", - "key": "a == b" + "val": "a less than equal to b", + "key": "a <= b" }, { "val": "a greater than b", "key": "a > b" }, - { - "val": "a less than equal to b", - "key": "a <= b" - }, { "val": "a greater than equal to b", "key": "a >= b" }, + { + "val": "a equal to b", + "key": "a == b" + }, { "val": "a not equal to b", "key": "a != b" @@ -117,18 +117,6 @@ "val": "Bitwise NOT / One's Complement", "key": "~a" }, - { - "val": "Bitwise AND", - "key": "a & b" - }, - { - "val": "Bitwise OR", - "key": "a | b" - }, - { - "val": "Bitwise XOR", - "key": "a ^ b" - }, { "val": "Bitwise left shift", "key": "a << b" @@ -136,6 +124,18 @@ { "val": "Bitwise right shift", "key": "a >> b" + }, + { + "val": "Bitwise AND", + "key": "a & b" + }, + { + "val": "Bitwise XOR", + "key": "a ^ b" + }, + { + "val": "Bitwise OR", + "key": "a | b" } ], "Other Operators": [ @@ -275,4 +275,4 @@ } ] } -} +} \ No newline at end of file From 99d89ba89136e27f1c0114e2a937521bf955a094 Mon Sep 17 00:00:00 2001 From: Zacqary Date: Sat, 7 May 2016 19:05:41 +0000 Subject: [PATCH 15/91] Conversions: Added tablespoons and teaspoons --- share/goodie/conversions/ratios.yml | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/share/goodie/conversions/ratios.yml b/share/goodie/conversions/ratios.yml index ed12cadca..54363fa8a 100755 --- a/share/goodie/conversions/ratios.yml +++ b/share/goodie/conversions/ratios.yml @@ -572,6 +572,46 @@ factor: 4.2267528 type: volume unit: us cup --- +aliases: + - us teaspoons + - us tsp + - us tsp. + - teaspoons + - teaspoon + - tsp + - tsp. +factor: 202.88413621 +type: volume +unit: us teaspoon +--- +aliases: + - metric teaspoons + - metric tsp + - metric tsp. +factor: 200 +type: volume +unit: metric teaspoon +--- +aliases: + - us tablespoons + - us tbsp + - us tbsp. + - tablespoons + - tablespoon + - tbsp + - tbsp. +factor: 67.6280454 +type: volume +unit: us tablespoon +--- +aliases: + - metric tablespoons + - metric tbsp + - metric tbsp. +factor: 66.6666666 +type: volume +unit: metric tablespoon +--- aliases: - days - dy From 2540ff11b10c4745315eed978fb5c234739ef1a0 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 8 May 2016 11:25:12 +0100 Subject: [PATCH 16/91] Mintsoft/conversions/squarefeet (#3006) * Conversions: The plural of square foot is square feet NOT square foots * Conversions: Fixing test for #3004 --- lib/DDG/Goodie/Conversions.pm | 3 ++- t/Conversions.t | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index dd130ebac..8ed191751 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -57,7 +57,8 @@ my %plural_exceptions = ( 'millennium' => 'millennia', 'mmHg' => 'mmHg', 'torr' => 'torr', - 'cubic inch' => 'cubic inches' + 'cubic inch' => 'cubic inches', + 'square foot' => 'square feet' ); my %singular_exceptions = reverse %plural_exceptions; diff --git a/t/Conversions.t b/t/Conversions.t index 7411f0b92..7fbbe3a15 100755 --- a/t/Conversions.t +++ b/t/Conversions.t @@ -2755,7 +2755,18 @@ ddg_goodie_test( physical_quantity => 'speed' }) ), - + 'acre square feet' => test_zci( + '1 acre = 43,560.173 square feet', + structured_answer => make_answer({ + markup_input => '1', + raw_input => '1', + from_unit => 'acre', + styled_output => '43,560.173', + raw_answer => '43560.173', + to_unit => 'square feet', + physical_quantity => 'area' + }) + ), # Intentionally untriggered From 6f3319919ba20f8f4ec02d6bea8d754b77e11453 Mon Sep 17 00:00:00 2001 From: hchienjo Date: Sun, 8 May 2016 11:34:01 +0000 Subject: [PATCH 17/91] remove unnecessary brackets. --- share/goodie/cheat_sheets/json/perl.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/goodie/cheat_sheets/json/perl.json b/share/goodie/cheat_sheets/json/perl.json index d2820848e..986969a44 100644 --- a/share/goodie/cheat_sheets/json/perl.json +++ b/share/goodie/cheat_sheets/json/perl.json @@ -132,7 +132,7 @@ }], "Basic Syntax": [{ "val": "Read command line params", - "key": "($a, $b) = (@ARGV);" + "key": "($a, $b) = @ARGV;" }, { "val": "Define subroutine", "key": "sub p\\{my $var = shift; ...\\}" From e25e37997ae68b0808e7cb8a710b2972832b2f31 Mon Sep 17 00:00:00 2001 From: Zacqary Adam Xeper Date: Sun, 8 May 2016 12:04:57 -0400 Subject: [PATCH 18/91] Conversions: Added metric dessert spoons --- share/goodie/conversions/ratios.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/share/goodie/conversions/ratios.yml b/share/goodie/conversions/ratios.yml index 54363fa8a..8674d0b05 100755 --- a/share/goodie/conversions/ratios.yml +++ b/share/goodie/conversions/ratios.yml @@ -612,6 +612,16 @@ factor: 66.6666666 type: volume unit: metric tablespoon --- +aliases: + - metric dessert spoons + - dessert spoons + - dessert spoon + - dsrspn + - dsrspn. +factor: 100 +type: volume +unit: metric dessert spoon +--- aliases: - days - dy From 2828b9e67b551344f9ba7d5fd45a9ae191381370 Mon Sep 17 00:00:00 2001 From: Zacqary Adam Xeper Date: Sun, 8 May 2016 13:47:07 -0400 Subject: [PATCH 19/91] Conversions: Fixed dessert spoons abbreviation --- share/goodie/conversions/ratios.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/goodie/conversions/ratios.yml b/share/goodie/conversions/ratios.yml index 8674d0b05..dbaed2ec0 100755 --- a/share/goodie/conversions/ratios.yml +++ b/share/goodie/conversions/ratios.yml @@ -616,8 +616,8 @@ aliases: - metric dessert spoons - dessert spoons - dessert spoon - - dsrspn - - dsrspn. + - dstspn + - dstspn. factor: 100 type: volume unit: metric dessert spoon From 35fb7cbf96290cc0357d675710c79a76410a1eed Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 8 May 2016 21:27:07 +0100 Subject: [PATCH 20/91] Constants: The Boltzmann and Stefan-Boltzman constants were confused (#2963) --- share/goodie/constants/constants.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/share/goodie/constants/constants.yml b/share/goodie/constants/constants.yml index 9ac93c59a..57aa6b647 100644 --- a/share/goodie/constants/constants.yml +++ b/share/goodie/constants/constants.yml @@ -80,16 +80,26 @@ bohr magneton: html: '9.27400968 × 10−24 J T−1' boltzmann constant: - name: The Stefan Boltzmann Constant + name: The Boltzmann Constant aliases: - - stefan boltzmann constant - - the stefan boltzmann constant - symbol: + - the boltzmann constant + symbol: k wiki: value: plain: '1.3806503 × 10^-23 m^2 kg s^-2 K^-1' html: '1.3806503 × 10-23 m2 kg s-2 K-1' +stefan-boltzmann constant: + name: The Stefan-Boltzmann Constant + aliases: + - the stefan boltzmann constant + - stefan boltzmann constant + symbol: σ + wiki: + value: + plain: '5.670367 × 10^−8 W m^−2 K^−4' + html: '5.670367 × 10−8 W m−2 K−4' + elementary electric charge: name: Elementary Electric Charge aliases: From 5f9ec79b194665b8a8a514373d30aee8d588ba76 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Fri, 6 May 2016 21:30:45 +0100 Subject: [PATCH 21/91] Conversions: Adding definition for plural against each unit --- share/goodie/conversions/ratios.yml | 185 ++++++++++++++++++++++++++-- 1 file changed, 176 insertions(+), 9 deletions(-) diff --git a/share/goodie/conversions/ratios.yml b/share/goodie/conversions/ratios.yml index dbaed2ec0..40fd01889 100755 --- a/share/goodie/conversions/ratios.yml +++ b/share/goodie/conversions/ratios.yml @@ -12,6 +12,7 @@ aliases: factor: 1 type: mass unit: metric ton +plural: metric tonnes --- aliases: - oz @@ -20,6 +21,7 @@ aliases: factor: 35274 type: mass unit: ounce +plural: ounces --- aliases: - lb @@ -32,6 +34,7 @@ aliases: factor: 2204.62 type: mass unit: pound +plural: pounds --- aliases: - st @@ -40,6 +43,7 @@ aliases: factor: 157.473 type: mass unit: stone +plural: stones --- aliases: - weight ton @@ -50,6 +54,7 @@ aliases: factor: 0.984207 type: mass unit: long ton +plural: long tons --- aliases: - mcg @@ -59,6 +64,7 @@ aliases: factor: 1000000000000 type: mass unit: microgram +plural: micrograms --- aliases: - kg @@ -71,6 +77,7 @@ aliases: factor: 1000 type: mass unit: kilogram +plural: kilograms --- aliases: - g @@ -83,6 +90,7 @@ aliases: factor: 1000000 type: mass unit: gram +plural: grams --- aliases: - mg @@ -91,6 +99,7 @@ aliases: factor: 1000000000 type: mass unit: milligram +plural: milligrams --- aliases: - short ton @@ -99,6 +108,7 @@ aliases: factor: 1.10231 type: mass unit: ton +plural: tons --- aliases: - grain @@ -109,6 +119,7 @@ aliases: factor: 15432358.3529414 type: mass unit: grain +plural: grains --- aliases: - carat @@ -116,6 +127,7 @@ aliases: factor: 5000000 type: mass unit: carat +plural: carats --- aliases: - dram @@ -125,7 +137,8 @@ aliases: - avoirdupois dram factor: 564383.3912 type: mass -unit: drams avoirdupois +unit: avoirdupois dram +plural: avoirdupois drams --- aliases: - meters @@ -135,6 +148,7 @@ aliases: factor: 1 type: length unit: meter +plural: meters --- aliases: - kilometers @@ -147,6 +161,7 @@ aliases: factor: 0.001 type: length unit: kilometer +plural: kilometers --- aliases: - centimeters @@ -157,6 +172,7 @@ aliases: factor: 100 type: length unit: centimeter +plural: centimeters --- aliases: - millimeters @@ -167,6 +183,7 @@ aliases: factor: 1000 type: length unit: millimeter +plural: millimeters --- aliases: - thou @@ -178,6 +195,7 @@ aliases: factor: 39370.1 type: length unit: thousandth of an inch +plural: thousandths of an inch --- aliases: - miles @@ -189,6 +207,7 @@ aliases: factor: 0.000621371192237334 type: length unit: mile +plural: miles --- aliases: - yards @@ -198,6 +217,7 @@ aliases: factor: 1.0936132983377077865266841644794 type: length unit: yard +plural: yards --- aliases: - feet @@ -209,6 +229,7 @@ aliases: factor: 3.2808398950131233595800524934383 type: length unit: foot +plural: feet --- aliases: - inches @@ -217,6 +238,7 @@ aliases: factor: 39.37007874015748031496062992126 type: length unit: inch +plural: inches --- aliases: - nautical miles @@ -229,12 +251,14 @@ aliases: factor: 0.000539957 type: length unit: nautical mile +plural: nautical miles --- aliases: - furlongs factor: 0.00497096953789867 type: length unit: furlong +plural: furlongs --- aliases: - gunter's chains @@ -242,6 +266,7 @@ aliases: factor: 0.0497096953789867 type: length unit: chain +plural: chains --- aliases: - gunter's links @@ -249,12 +274,14 @@ aliases: factor: 4.97096953789867 type: length unit: link +plural: links --- aliases: - rods factor: 0.198838781515947 type: length unit: rod +plural: rods --- aliases: - fathoms @@ -263,18 +290,21 @@ aliases: factor: 0.539611824837685 type: length unit: fathom +plural: fathoms --- aliases: - leagues factor: 0.000207123730745778 type: length unit: league +plural: leagues --- aliases: - cables factor: 0.00539611824837685 type: length unit: cable +plural: cables --- aliases: - light years @@ -283,6 +313,7 @@ aliases: factor: 1.05700083402462e-16 type: length unit: light year +plural: light years --- aliases: - parsecs @@ -291,6 +322,7 @@ aliases: factor: 3.24077923047971e-17 type: length unit: parsec +plural: parsecs --- aliases: - astronomical units @@ -299,6 +331,7 @@ aliases: factor: 6.68458712226845e-12 type: length unit: astronomical unit +plural: astronomical units --- aliases: - hectares @@ -306,12 +339,14 @@ aliases: factor: 1 type: area unit: hectare +plural: hectares --- aliases: - acres factor: 2.4710439 type: area unit: acre +plural: acres --- aliases: - square meters @@ -326,6 +361,7 @@ aliases: factor: 10000 type: area unit: square meter +plural: square meters --- aliases: - square kilometers @@ -336,6 +372,7 @@ aliases: factor: 0.01 type: area unit: square kilometer +plural: square kilometers --- aliases: - square centimeters @@ -346,6 +383,7 @@ aliases: factor: 100000000 type: area unit: square centimeter +plural: square centimeters --- aliases: - square millimeters @@ -356,6 +394,7 @@ aliases: factor: 10000000000 type: area unit: square millimeter +plural: square millimeters --- aliases: - square miles @@ -369,6 +408,7 @@ aliases: factor: 0.00386102160083284 type: area unit: square mile +plural: square miles --- aliases: - square yards @@ -383,6 +423,7 @@ aliases: factor: 11959.9 type: area unit: square yard +plural: square yards --- aliases: - square feet @@ -395,6 +436,7 @@ aliases: factor: 107639.1 type: area unit: square foot +plural: square feet --- aliases: - square inches @@ -406,12 +448,14 @@ aliases: factor: 15500031 type: area unit: square inch +plural: square inches --- aliases: - ping factor: 3024.80338778 type: area unit: 坪 +plural: 坪 --- aliases: - liter @@ -423,6 +467,7 @@ aliases: factor: 1 type: volume unit: litre +plural: litres --- aliases: - milliliter @@ -432,6 +477,7 @@ aliases: factor: 1000 type: volume unit: millilitre +plural:millilitres --- aliases: - cubic inch @@ -445,6 +491,7 @@ aliases: factor: 61.024 type: volume unit: cubic inch +plural: cubic inches --- aliases: - metre^3 @@ -456,6 +503,7 @@ aliases: factor: 0.001 type: volume unit: cubic metre +plural: cubic metres --- aliases: - centimetre^3 @@ -468,9 +516,12 @@ aliases: - ccm factor: 1000 type: volume -unit: cubic centimetre +unit: cubic centimeter +plural: cubic centimeters --- aliases: + - cubic millimetre + - cubic millimetres - millimetre^3 - millimeter^3 - millimetres^3 @@ -479,7 +530,8 @@ aliases: - mm³ factor: 1000000 type: volume -unit: cubic millimetre +unit: cubic millimeter +plural: cubic millimeters --- aliases: - liquid pints @@ -489,12 +541,14 @@ aliases: factor: 2.11337641886519 type: volume unit: liquid pint +plural: liquid pints --- aliases: - dry pints factor: 1.81616596853771 type: volume unit: dry pint +plural: dry pints --- aliases: - pints @@ -506,6 +560,7 @@ aliases: factor: 1.7597539863927 type: volume unit: imperial pint +plural: imperial pints --- aliases: - imperial gallon @@ -516,6 +571,7 @@ aliases: factor: 0.219969248299088 type: volume unit: imperial gallon +plural: imperial gallons --- aliases: - fluid gallon @@ -527,6 +583,7 @@ aliases: factor: 0.264172052358148 type: volume unit: us gallon +pluralunit: us gallons --- aliases: - liquid quart @@ -537,6 +594,7 @@ aliases: factor: 1.05668820943259 type: volume unit: quart +plural: quarts --- aliases: - imperial quarts @@ -545,6 +603,7 @@ aliases: factor: 7.03901594557081 type: volume unit: imperial quart +plural: imperial quarts --- aliases: - imperial fluid ounces @@ -553,6 +612,7 @@ aliases: factor: 28.1560637822832 type: volume unit: imperial fluid ounce +plural: imperial fluid ounches --- aliases: - us fluid ounces @@ -563,6 +623,7 @@ aliases: factor: 33.814022701843 type: volume unit: us fluid ounce +plural: us fluid ounces --- aliases: - us cups @@ -571,6 +632,7 @@ aliases: factor: 4.2267528 type: volume unit: us cup +plural: us cups --- aliases: - us teaspoons @@ -630,6 +692,7 @@ aliases: factor: 1 type: duration unit: day +plural: days --- aliases: - seconds @@ -638,6 +701,7 @@ aliases: factor: 86400 type: duration unit: second +plural: seconds --- aliases: - milliseconds @@ -647,6 +711,7 @@ aliases: factor: 86400000 type: duration unit: millisecond +plural: milliseconds --- aliases: - microseconds @@ -656,6 +721,7 @@ aliases: factor: 86400000000 type: duration unit: microsecond +plural: microseconds --- aliases: - nanoseconds @@ -665,6 +731,7 @@ aliases: factor: 86400000000000 type: duration unit: nanosecond +plural: nanoseconds --- aliases: - minutes @@ -673,6 +740,7 @@ aliases: factor: 1440 type: duration unit: minute +plural: minutes --- aliases: - hours @@ -682,6 +750,7 @@ aliases: factor: 24 type: duration unit: hour +plural: hours --- aliases: - weeks @@ -690,11 +759,13 @@ aliases: factor: 0.142857142857143 type: duration unit: week +plural: weeks --- aliases: [] factor: 0.0714285714285714 type: duration unit: fortnight +plural: fortnights --- aliases: - months @@ -704,6 +775,7 @@ aliases: factor: 0.0328767123287671 type: duration unit: month +plural: months --- aliases: - years @@ -712,6 +784,7 @@ aliases: factor: 0.00273972602739726 type: duration unit: year +plural: years --- aliases: - decade @@ -719,6 +792,7 @@ aliases: factor: 0.000273972602739726 type: duration unit: decade +plural: decades --- aliases: - century @@ -726,6 +800,7 @@ aliases: factor: 0.0000273972602739726 type: duration unit: century +plural: centuries --- aliases: - millennium @@ -733,6 +808,7 @@ aliases: factor: 0.00000273972602739726 type: duration unit: millennium +plural: millennia --- aliases: - leap years @@ -742,6 +818,7 @@ aliases: factor: 0.00273224043715847 type: duration unit: leap year +plural: leap years --- aliases: - pascals @@ -750,6 +827,7 @@ aliases: factor: 1 type: pressure unit: pascal +plural: pascals --- aliases: - kilopascals @@ -758,6 +836,7 @@ aliases: factor: 0.001 type: pressure unit: kilopascal +plural: kilopascals --- aliases: - megapascals @@ -766,6 +845,7 @@ aliases: factor: 1e-06 type: pressure unit: megapascal +plural: megapascals --- aliases: - gigapascals @@ -774,6 +854,7 @@ aliases: factor: 1e-09 type: pressure unit: gigapascal +plural: gigapascals --- aliases: - bars @@ -782,6 +863,7 @@ aliases: factor: 1e-05 type: pressure unit: bar +plural: bars --- aliases: - atmospheres @@ -790,6 +872,7 @@ aliases: factor: 9.86923266716013e-06 type: pressure unit: atmosphere +plural: atmospheres --- aliases: - psis @@ -799,13 +882,15 @@ aliases: - p.s.i factor: 0.000145036839357197 type: pressure -unit: pounds per square inch +unit: pound per square inch +plural: pounds per square inch --- aliases: - mmhg factor: 0.00750061683 type: pressure unit: mmHg +plural: mmHg --- aliases: - torr @@ -813,6 +898,7 @@ aliases: factor: 0.00750062 type: pressure unit: torr +plural: torrs --- aliases: - joules @@ -821,6 +907,7 @@ aliases: factor: 1 type: energy unit: joule +plural: joules --- aliases: - watt second @@ -829,6 +916,7 @@ aliases: factor: 1 type: energy unit: watt-second +plural: watt-seconds --- aliases: - watt hour @@ -837,6 +925,7 @@ aliases: factor: 0.000277777777777778 type: energy unit: watt-hour +plural: watt-hours --- aliases: - kilowatt hour @@ -845,6 +934,7 @@ aliases: factor: 2.77777777777778e-07 type: energy unit: kilowatt-hour +plural: kilowatt-hours --- aliases: - ergon @@ -853,6 +943,7 @@ aliases: factor: 1e-07 type: energy unit: erg +plural: ergs --- aliases: - electronvolt @@ -862,6 +953,7 @@ aliases: factor: 6.2415096e+18 type: energy unit: electron volt +plural: electron volts --- aliases: - small calories @@ -871,6 +963,7 @@ aliases: factor: 0.239005736137667 type: energy unit: thermochemical gram calorie +plural: thermochemical gran calories --- aliases: - large calories @@ -881,6 +974,7 @@ aliases: factor: 0.000239005736137667 type: energy unit: large calorie +plural: large calories --- aliases: - british thermal units @@ -889,6 +983,7 @@ aliases: factor: 0.000948316737790422 type: energy unit: british thermal unit +plural: british thermal units --- aliases: - tnt equivilent @@ -898,6 +993,7 @@ aliases: factor: 2.39005736137667e-10 type: energy unit: ton of TNT +plural: tons of TNT --- aliases: - watts @@ -905,6 +1001,7 @@ aliases: factor: 1 type: power unit: watt +plural: watts --- aliases: - kilowatts @@ -912,6 +1009,7 @@ aliases: factor: 0.001 type: power unit: kilowatt +plural: kilowatts --- aliases: - megawatts @@ -919,6 +1017,7 @@ aliases: factor: 1e-06 type: power unit: megawatt +plural: megawatts --- aliases: - gigawatts @@ -927,6 +1026,7 @@ aliases: factor: 1e-09 type: power unit: gigawatt +plural: gigawatts --- aliases: - terawatts @@ -934,6 +1034,7 @@ aliases: factor: 1e-12 type: power unit: terawatt +plural: terawatts --- aliases: - petawatts @@ -941,18 +1042,21 @@ aliases: factor: 1e-15 type: power unit: petawatt +plural: petawatts --- aliases: - milliwatts factor: 1000 type: power unit: milliwatt +plural: milliwatts --- aliases: - microwatts factor: 1000000 type: power unit: microwatt +plural: microwatts --- aliases: - nanowatts @@ -960,6 +1064,7 @@ aliases: factor: 1000000000 type: power unit: nanowatt +plural: nanowatts --- aliases: - picowatts @@ -967,6 +1072,7 @@ aliases: factor: 1000000000000 type: power unit: picowatt +plural: picowatts --- aliases: - metric horsepowers @@ -980,9 +1086,10 @@ aliases: factor: 0.0013596216173039 type: power unit: metric horsepower +plural: metric horsepower --- aliases: - - mechnical horsepower + - mechanical horsepower - horsepower - hp - hp @@ -990,14 +1097,16 @@ aliases: factor: 0.00134102208959503 type: power unit: horsepower +plural: horsepower --- aliases: - - electical horsepowers + - electrical horsepowers - hp - hp factor: 0.00134048257372654 type: power -unit: electical horsepower +unit: electrical horsepower +plural: electrical horsepower --- aliases: - degrees @@ -1006,6 +1115,7 @@ aliases: factor: 1 type: angle unit: degree +plural: degrees --- aliases: - radians @@ -1014,6 +1124,7 @@ aliases: factor: 0.0174532925199433 type: angle unit: radian +plural: radians --- aliases: - gradians @@ -1026,6 +1137,7 @@ aliases: factor: 1.11111111111111 type: angle unit: gradian +plural: gradians --- aliases: - quadrants @@ -1034,6 +1146,7 @@ aliases: factor: 0.0111111111111111 type: angle unit: quadrant +plural: quadrants --- aliases: - semi circle @@ -1044,6 +1157,7 @@ aliases: factor: 0.00555555555555556 type: angle unit: semi-circle +plural: semi-circles --- aliases: - revolutions @@ -1053,6 +1167,7 @@ aliases: factor: 0.00277777777777778 type: angle unit: revolution +plural: revolutions --- aliases: - newtons @@ -1060,13 +1175,15 @@ aliases: factor: 1 type: force unit: newton +plural: newtons --- aliases: - kilonewtons - kn factor: 0.001 type: force -unit: kilonewton +unit: kilonewtons +plural: kilonewtons --- aliases: - meganewtons @@ -1074,6 +1191,7 @@ aliases: factor: 1e-06 type: force unit: meganewton +plural: meganewtons --- aliases: - giganewtons @@ -1081,31 +1199,36 @@ aliases: factor: 1e-09 type: force unit: giganewton +plural: giganewtons --- aliases: - dynes factor: 1e-05 type: force unit: dyne +plural: dynes --- aliases: - kilodynes factor: 0.01 type: force unit: kilodyne +plural: kildynes --- aliases: - megadynes factor: 10 type: force unit: megadyne +plural: megadynes --- aliases: - lbs force - pounds force factor: 0.224808943099711 type: force -unit: pounds force +unit: pound force +plural: pounds force --- aliases: - poundals @@ -1113,6 +1236,7 @@ aliases: factor: 7.23301385120989 type: force unit: poundal +plural: poundals --- aliases: - f @@ -1121,6 +1245,7 @@ can_be_negative: 1 factor: 1 type: temperature unit: fahrenheit +plural: fahrenheit --- aliases: - c @@ -1129,18 +1254,21 @@ can_be_negative: 1 factor: 1 type: temperature unit: celsius +plural: celsius --- aliases: - k factor: 1 type: temperature unit: kelvin +plural: kelvin --- aliases: - r factor: 1 type: temperature unit: rankine +plural: rankine --- aliases: - re @@ -1148,6 +1276,7 @@ can_be_negative: 1 factor: 1 type: temperature unit: reaumur +plural: reamur --- aliases: - bits @@ -1162,6 +1291,7 @@ aliases: factor: 0.001 type: digital unit: kilobit +plural: kilobits --- aliases: - mbit @@ -1170,6 +1300,7 @@ aliases: factor: 1e-06 type: digital unit: megabit +plural: megabits --- aliases: - gbit @@ -1178,6 +1309,7 @@ aliases: factor: 1e-09 type: digital unit: gigabit +plural: gigabits --- aliases: - tbit @@ -1186,6 +1318,7 @@ aliases: factor: 1e-12 type: digital unit: terabit +plural: terabits --- aliases: - pbit @@ -1194,6 +1327,7 @@ aliases: factor: 1e-15 type: digital unit: petabit +plural: petabits --- aliases: - ebit @@ -1202,6 +1336,7 @@ aliases: factor: 1e-18 type: digital unit: exabit +plural: exabits --- aliases: - zbit @@ -1210,6 +1345,7 @@ aliases: factor: 1e-21 type: digital unit: zettabit +plural: zettabits --- aliases: - ybit @@ -1218,6 +1354,7 @@ aliases: factor: 1e-24 type: digital unit: yottabit +plural: yottabits --- aliases: - kibit @@ -1226,6 +1363,7 @@ aliases: factor: 0.0009765625 type: digital unit: kibibit +plural: kibibits --- aliases: - mibit @@ -1234,6 +1372,7 @@ aliases: factor: 9.5367431640625e-07 type: digital unit: mebibit +plural: mebibits --- aliases: - gibit @@ -1242,6 +1381,7 @@ aliases: factor: 9.31322574615479e-10 type: digital unit: gibibit +plural: gibibits --- aliases: - tibit @@ -1250,6 +1390,7 @@ aliases: factor: 9.09494701772928e-13 type: digital unit: tebibit +plural: tebibits --- aliases: - pibit @@ -1258,6 +1399,7 @@ aliases: factor: 8.88178419700125e-16 type: digital unit: pebibit +plural: pebibits --- aliases: - eibit @@ -1266,6 +1408,7 @@ aliases: factor: 8.67361737988404e-19 type: digital unit: exbibit +plural: exbibits --- aliases: - zibit @@ -1274,6 +1417,7 @@ aliases: factor: 8.470329472543e-22 type: digital unit: zebibit +plural: zebibits --- aliases: - yibit @@ -1282,12 +1426,14 @@ aliases: factor: 8.27180612553028e-25 type: digital unit: yobibit +plural: yobibits --- aliases: - bytes factor: 0.125 type: digital unit: byte +plural: bytes --- aliases: - kb @@ -1296,6 +1442,7 @@ aliases: factor: 0.000125 type: digital unit: kilobyte +plural: kilobytes --- aliases: - mb @@ -1304,6 +1451,7 @@ aliases: factor: 1.25e-07 type: digital unit: megabyte +plural: megabytes --- aliases: - gb @@ -1312,6 +1460,7 @@ aliases: factor: 1.25e-10 type: digital unit: gigabyte +plural: gigabytes --- aliases: - tb @@ -1320,6 +1469,7 @@ aliases: factor: 1.25e-13 type: digital unit: terabyte +plural: terabytes --- aliases: - pb @@ -1328,6 +1478,7 @@ aliases: factor: 1.25e-16 type: digital unit: petabyte +plural: petabytes --- aliases: - eb @@ -1336,6 +1487,7 @@ aliases: factor: 1.25e-19 type: digital unit: exabyte +plural: exabytes --- aliases: - zb @@ -1344,6 +1496,7 @@ aliases: factor: 1.25e-22 type: digital unit: zettabyte +plural: zettabytes --- aliases: - yb @@ -1352,6 +1505,7 @@ aliases: factor: 1.25e-25 type: digital unit: yottabyte +plural: yottabytes --- aliases: - kib @@ -1360,6 +1514,7 @@ aliases: factor: 0.0001220703125 type: digital unit: kibibyte +plural: kibibytes --- aliases: - mib @@ -1368,6 +1523,7 @@ aliases: factor: 1.19209289550781e-07 type: digital unit: mebibyte +plural: mebibytes --- aliases: - gib @@ -1376,6 +1532,7 @@ aliases: factor: 1.16415321826935e-10 type: digital unit: gibibyte +plural: gibibytes --- aliases: - tib @@ -1384,6 +1541,7 @@ aliases: factor: 1.13686837721616e-13 type: digital unit: tebibyte +plural: tebibytes --- aliases: - pib @@ -1392,6 +1550,7 @@ aliases: factor: 1.11022302462516e-16 type: digital unit: pebibyte +plural: pebibytes --- aliases: - eib @@ -1400,6 +1559,7 @@ aliases: factor: 1.0842021724855e-19 type: digital unit: exbibyte +plural: exbibytes --- aliases: - zib @@ -1408,6 +1568,7 @@ aliases: factor: 1.05879118406788e-22 type: digital unit: zebibyte +plural: zebibytes --- aliases: - yib @@ -1416,6 +1577,7 @@ aliases: factor: 1.03397576569129e-25 type: digital unit: yobibyte +plural: yobibytes --- aliases: - mi/h @@ -1425,6 +1587,7 @@ aliases: factor: 2.236941851939304 type: speed unit: mph +plural: mph --- aliases: - meters per second @@ -1439,6 +1602,7 @@ aliases: factor: 1 type: speed unit: m/s +plural: m/s --- aliases: - feet per second @@ -1453,6 +1617,7 @@ aliases: factor: 3.280839895013123 type: speed unit: ft/s +plural: ft/s --- aliases: - kilometer per hour @@ -1464,6 +1629,7 @@ aliases: factor: 3.6 type: speed unit: km/h +plural: km/h --- aliases: - knots @@ -1472,3 +1638,4 @@ aliases: factor: 1.943844492440605 type: speed unit: knot +plural: knots From ccc0ad7d4656b777ce047884f44aa9a0f1761628 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Fri, 6 May 2016 22:02:04 +0100 Subject: [PATCH 22/91] Conversions: Removing the plurals from aliases as they'll get merged in the IA --- share/goodie/conversions/ratios.yml | 196 +++++----------------------- 1 file changed, 31 insertions(+), 165 deletions(-) diff --git a/share/goodie/conversions/ratios.yml b/share/goodie/conversions/ratios.yml index 40fd01889..b5678cd15 100755 --- a/share/goodie/conversions/ratios.yml +++ b/share/goodie/conversions/ratios.yml @@ -16,7 +16,6 @@ plural: metric tonnes --- aliases: - oz - - ounces - ozs factor: 35274 type: mass @@ -27,7 +26,6 @@ aliases: - lb - lbm - pound mass - - pounds - lbs - lbms - pounds mass @@ -43,7 +41,7 @@ aliases: factor: 157.473 type: mass unit: stone -plural: stones +plural: stone --- aliases: - weight ton @@ -58,7 +56,6 @@ plural: long tons --- aliases: - mcg - - micrograms - mcgs - µg factor: 1000000000000 @@ -70,7 +67,6 @@ aliases: - kg - kilo - kilogramme - - kilograms - kgs - kilos - kilogrammes @@ -83,7 +79,6 @@ aliases: - g - gm - gramme - - grams - gs - gms - grammes @@ -94,7 +89,6 @@ plural: grams --- aliases: - mg - - milligrams - mgs factor: 1000000000 type: mass @@ -104,7 +98,6 @@ plural: milligrams aliases: - short ton - short tons - - tons factor: 1.10231 type: mass unit: ton @@ -112,7 +105,6 @@ plural: tons --- aliases: - grain - - grains - gr - troy grain - troy grains @@ -123,7 +115,6 @@ plural: grains --- aliases: - carat - - carats factor: 5000000 type: mass unit: carat @@ -141,7 +132,6 @@ unit: avoirdupois dram plural: avoirdupois drams --- aliases: - - meters - metre - metres - m @@ -151,7 +141,6 @@ unit: meter plural: meters --- aliases: - - kilometers - kilometre - kilometres - km @@ -164,7 +153,6 @@ unit: kilometer plural: kilometers --- aliases: - - centimeters - centimetre - centimetres - cm @@ -175,7 +163,6 @@ unit: centimeter plural: centimeters --- aliases: - - millimeters - millimetre - millimetres - mm @@ -191,14 +178,12 @@ aliases: - mil - mils - thousandth of an inch - - thousandths of an inch factor: 39370.1 type: length unit: thousandth of an inch plural: thousandths of an inch --- aliases: - - miles - mi - statute mile - statute miles @@ -210,7 +195,6 @@ unit: mile plural: miles --- aliases: - - yards - yd - yds - yrds @@ -220,7 +204,6 @@ unit: yard plural: yards --- aliases: - - feet - ft - international foot - international feet @@ -232,7 +215,6 @@ unit: foot plural: feet --- aliases: - - inches - in - ins factor: 39.37007874015748031496062992126 @@ -241,7 +223,6 @@ unit: inch plural: inches --- aliases: - - nautical miles - n - ns - nm @@ -254,7 +235,7 @@ unit: nautical mile plural: nautical miles --- aliases: - - furlongs + - furlng factor: 0.00497096953789867 type: length unit: furlong @@ -262,7 +243,6 @@ plural: furlongs --- aliases: - gunter's chains - - chains factor: 0.0497096953789867 type: length unit: chain @@ -270,21 +250,19 @@ plural: chains --- aliases: - gunter's links - - links factor: 4.97096953789867 type: length unit: link plural: links --- aliases: - - rods + - rd factor: 0.198838781515947 type: length unit: rod plural: rods --- aliases: - - fathoms - ftm - ftms factor: 0.539611824837685 @@ -292,22 +270,19 @@ type: length unit: fathom plural: fathoms --- -aliases: - - leagues +aliases: [] factor: 0.000207123730745778 type: length unit: league plural: leagues --- -aliases: - - cables +aliases: [] factor: 0.00539611824837685 type: length unit: cable plural: cables --- aliases: - - light years - ly - lys factor: 1.05700083402462e-16 @@ -316,7 +291,6 @@ unit: light year plural: light years --- aliases: - - parsecs - pc - pcs factor: 3.24077923047971e-17 @@ -325,7 +299,6 @@ unit: parsec plural: parsecs --- aliases: - - astronomical units - au - aus factor: 6.68458712226845e-12 @@ -334,22 +307,19 @@ unit: astronomical unit plural: astronomical units --- aliases: - - hectares - ha factor: 1 type: area unit: hectare plural: hectares --- -aliases: - - acres +aliases: [] factor: 2.4710439 type: area unit: acre plural: acres --- aliases: - - square meters - metre^2 - meter^2 - metres^2 @@ -364,7 +334,6 @@ unit: square meter plural: square meters --- aliases: - - square kilometers - square kilometre - square kilometres - km^2 @@ -375,7 +344,6 @@ unit: square kilometer plural: square kilometers --- aliases: - - square centimeters - square centimetre - square centimetres - cm^2 @@ -386,7 +354,6 @@ unit: square centimeter plural: square centimeters --- aliases: - - square millimeters - square millimetre - square millimetres - mm^2 @@ -397,7 +364,6 @@ unit: square millimeter plural: square millimeters --- aliases: - - square miles - sq mi - square statute mile - square statute miles @@ -411,7 +377,6 @@ unit: square mile plural: square miles --- aliases: - - square yards - yard^2 - yard² - yards² @@ -426,7 +391,6 @@ unit: square yard plural: square yards --- aliases: - - square feet - feet^2 - feet² - foot^2 @@ -439,7 +403,6 @@ unit: square foot plural: square feet --- aliases: - - square inches - inch^2 - inches^2 - squinch @@ -459,7 +422,6 @@ plural: 坪 --- aliases: - liter - - litres - liters - l - litter @@ -471,17 +433,15 @@ plural: litres --- aliases: - milliliter - - millilitres - milliliters - ml factor: 1000 type: volume unit: millilitre -plural:millilitres +plural: millilitres --- aliases: - cubic inch - - cubic inches - cubic in - cu inch - cu in @@ -534,7 +494,6 @@ unit: cubic millimeter plural: cubic millimeters --- aliases: - - liquid pints - us pints - us liquid pint - us liquid pints @@ -544,7 +503,7 @@ unit: liquid pint plural: liquid pints --- aliases: - - dry pints + - pints dry factor: 1.81616596853771 type: volume unit: dry pint @@ -553,7 +512,6 @@ plural: dry pints aliases: - pints - pint - - imperial pints - uk pint - british pint - pts @@ -563,11 +521,12 @@ unit: imperial pint plural: imperial pints --- aliases: - - imperial gallon - uk gallon - british gallon - british gallons - uk gallons + - gb gallons + - gb gallon factor: 0.219969248299088 type: volume unit: imperial gallon @@ -577,19 +536,17 @@ aliases: - fluid gallon - us fluid gallon - fluid gallons - - us gallons - gallon - gallons factor: 0.264172052358148 type: volume unit: us gallon -pluralunit: us gallons +plural: us gallons --- aliases: - liquid quart - us quart - us quarts - - quarts - liquid quarts factor: 1.05668820943259 type: volume @@ -597,7 +554,6 @@ unit: quart plural: quarts --- aliases: - - imperial quarts - british quarts - british quart factor: 7.03901594557081 @@ -606,16 +562,14 @@ unit: imperial quart plural: imperial quarts --- aliases: - - imperial fluid ounces - imperial fl oz - imperial fluid oz factor: 28.1560637822832 type: volume unit: imperial fluid ounce -plural: imperial fluid ounches +plural: imperial fluid ounces --- aliases: - - us fluid ounces - us fl oz - fl oz - fl. oz @@ -626,7 +580,6 @@ unit: us fluid ounce plural: us fluid ounces --- aliases: - - us cups - cups - cup factor: 4.2267528 @@ -635,7 +588,6 @@ unit: us cup plural: us cups --- aliases: - - us teaspoons - us tsp - us tsp. - teaspoons @@ -645,17 +597,17 @@ aliases: factor: 202.88413621 type: volume unit: us teaspoon +plural: us teaspoons --- aliases: - - metric teaspoons - metric tsp - metric tsp. factor: 200 type: volume unit: metric teaspoon +plural: metric teaspoons --- aliases: - - us tablespoons - us tbsp - us tbsp. - tablespoons @@ -665,17 +617,17 @@ aliases: factor: 67.6280454 type: volume unit: us tablespoon +plural: us tablespoons --- aliases: - - metric tablespoons - metric tbsp - metric tbsp. factor: 66.6666666 type: volume unit: metric tablespoon +plural: metric tablespoons --- aliases: - - metric dessert spoons - dessert spoons - dessert spoon - dstspn @@ -683,6 +635,7 @@ aliases: factor: 100 type: volume unit: metric dessert spoon +plural: metric dessert spoons --- aliases: - days @@ -695,7 +648,6 @@ unit: day plural: days --- aliases: - - seconds - sec - s factor: 86400 @@ -704,7 +656,6 @@ unit: second plural: seconds --- aliases: - - milliseconds - millisec - millisecs - ms @@ -714,7 +665,6 @@ unit: millisecond plural: milliseconds --- aliases: - - microseconds - microsec - microsecs - µs @@ -724,7 +674,6 @@ unit: microsecond plural: microseconds --- aliases: - - nanoseconds - nanosec - nanosecs - ns @@ -734,7 +683,6 @@ unit: nanosecond plural: nanoseconds --- aliases: - - minutes - min - mins factor: 1440 @@ -743,7 +691,6 @@ unit: minute plural: minutes --- aliases: - - hours - hr - hrs - h @@ -753,7 +700,6 @@ unit: hour plural: hours --- aliases: - - weeks - wks - wk factor: 0.142857142857143 @@ -768,7 +714,6 @@ unit: fortnight plural: fortnights --- aliases: - - months - mons - mns - mn @@ -778,7 +723,6 @@ unit: month plural: months --- aliases: - - years - yr - yrs factor: 0.00273972602739726 @@ -786,32 +730,25 @@ type: duration unit: year plural: years --- -aliases: - - decade - - decades +aliases: [] factor: 0.000273972602739726 type: duration unit: decade plural: decades --- -aliases: - - century - - centuries +aliases: [] factor: 0.0000273972602739726 type: duration unit: century plural: centuries --- -aliases: - - millennium - - millennia +aliases: [] factor: 0.00000273972602739726 type: duration unit: millennium plural: millennia --- aliases: - - leap years - leapyear - leapyr - leapyrs @@ -821,7 +758,6 @@ unit: leap year plural: leap years --- aliases: - - pascals - pa - pas factor: 1 @@ -830,7 +766,6 @@ unit: pascal plural: pascals --- aliases: - - kilopascals - kpa - kpas factor: 0.001 @@ -839,7 +774,6 @@ unit: kilopascal plural: kilopascals --- aliases: - - megapascals - megapa - megapas factor: 1e-06 @@ -848,7 +782,6 @@ unit: megapascal plural: megapascals --- aliases: - - gigapascals - gpa - gpas factor: 1e-09 @@ -857,7 +790,6 @@ unit: gigapascal plural: gigapascals --- aliases: - - bars - pa - pas factor: 1e-05 @@ -866,7 +798,6 @@ unit: bar plural: bars --- aliases: - - atmospheres - atm - atms factor: 9.86923266716013e-06 @@ -892,16 +823,13 @@ type: pressure unit: mmHg plural: mmHg --- -aliases: - - torr - - torrs +aliases: [] factor: 0.00750062 type: pressure unit: torr plural: torrs --- aliases: - - joules - j - js factor: 1 @@ -938,7 +866,6 @@ plural: kilowatt-hours --- aliases: - ergon - - ergs - ergons factor: 1e-07 type: energy @@ -947,7 +874,7 @@ plural: ergs --- aliases: - electronvolt - - electron volts + - electronvolts - ev - evs factor: 6.2415096e+18 @@ -957,7 +884,6 @@ plural: electron volts --- aliases: - small calories - - thermochemical gram calories - chemical calorie - chemical calories factor: 0.239005736137667 @@ -966,7 +892,6 @@ unit: thermochemical gram calorie plural: thermochemical gran calories --- aliases: - - large calories - food calorie - food calories - kcals @@ -977,7 +902,6 @@ unit: large calorie plural: large calories --- aliases: - - british thermal units - btu - btus factor: 0.000948316737790422 @@ -989,14 +913,12 @@ aliases: - tnt equivilent - tonnes of tnt - tnt - - tons of tnt factor: 2.39005736137667e-10 type: energy unit: ton of TNT plural: tons of TNT --- aliases: - - watts - w factor: 1 type: power @@ -1004,7 +926,6 @@ unit: watt plural: watts --- aliases: - - kilowatts - kw factor: 0.001 type: power @@ -1012,7 +933,6 @@ unit: kilowatt plural: kilowatts --- aliases: - - megawatts - mw factor: 1e-06 type: power @@ -1020,7 +940,6 @@ unit: megawatt plural: megawatts --- aliases: - - gigawatts - jiggawatts - gw factor: 1e-09 @@ -1029,7 +948,6 @@ unit: gigawatt plural: gigawatts --- aliases: - - terawatts - tw factor: 1e-12 type: power @@ -1037,29 +955,26 @@ unit: terawatt plural: terawatts --- aliases: - - petawatts - pw factor: 1e-15 type: power unit: petawatt plural: petawatts --- -aliases: - - milliwatts +aliases: [] factor: 1000 type: power unit: milliwatt plural: milliwatts --- aliases: - - microwatts + - μwatts factor: 1000000 type: power unit: microwatt plural: microwatts --- aliases: - - nanowatts - nw factor: 1000000000 type: power @@ -1067,7 +982,6 @@ unit: nanowatt plural: nanowatts --- aliases: - - picowatts - pw factor: 1000000000000 type: power @@ -1109,7 +1023,6 @@ unit: electrical horsepower plural: electrical horsepower --- aliases: - - degrees - deg - degs factor: 1 @@ -1118,7 +1031,6 @@ unit: degree plural: degrees --- aliases: - - radians - rad - rads factor: 0.0174532925199433 @@ -1127,7 +1039,6 @@ unit: radian plural: radians --- aliases: - - gradians - grad - grads - gon @@ -1140,7 +1051,6 @@ unit: gradian plural: gradians --- aliases: - - quadrants - quads - quad factor: 0.0111111111111111 @@ -1153,14 +1063,12 @@ aliases: - semicircle - semi circles - semicircles - - semi-circles factor: 0.00555555555555556 type: angle unit: semi-circle plural: semi-circles --- aliases: - - revolutions - circle - circles - revs @@ -1170,7 +1078,6 @@ unit: revolution plural: revolutions --- aliases: - - newtons - n factor: 1 type: force @@ -1178,7 +1085,6 @@ unit: newton plural: newtons --- aliases: - - kilonewtons - kn factor: 0.001 type: force @@ -1186,7 +1092,6 @@ unit: kilonewtons plural: kilonewtons --- aliases: - - meganewtons - mn factor: 1e-06 type: force @@ -1194,29 +1099,25 @@ unit: meganewton plural: meganewtons --- aliases: - - giganewtons - gn factor: 1e-09 type: force unit: giganewton plural: giganewtons --- -aliases: - - dynes +aliases: [] factor: 1e-05 type: force unit: dyne plural: dynes --- -aliases: - - kilodynes +aliases: [] factor: 0.01 type: force unit: kilodyne plural: kildynes --- -aliases: - - megadynes +aliases: [] factor: 10 type: force unit: megadyne @@ -1224,14 +1125,13 @@ plural: megadynes --- aliases: - lbs force - - pounds force + - lb force factor: 0.224808943099711 type: force unit: pound force plural: pounds force --- aliases: - - poundals - pdl factor: 7.23301385120989 type: force @@ -1278,16 +1178,15 @@ type: temperature unit: reaumur plural: reamur --- -aliases: - - bits +aliases: [] factor: 1 type: digital unit: bit +plural: bits --- aliases: - kbit - kbits - - kilobits factor: 0.001 type: digital unit: kilobit @@ -1296,7 +1195,6 @@ plural: kilobits aliases: - mbit - mbits - - megabits factor: 1e-06 type: digital unit: megabit @@ -1304,7 +1202,6 @@ plural: megabits --- aliases: - gbit - - gigabits - gbits factor: 1e-09 type: digital @@ -1314,7 +1211,6 @@ plural: gigabits aliases: - tbit - tbits - - terabits factor: 1e-12 type: digital unit: terabit @@ -1323,7 +1219,6 @@ plural: terabits aliases: - pbit - pbits - - petabits factor: 1e-15 type: digital unit: petabit @@ -1332,7 +1227,6 @@ plural: petabits aliases: - ebit - ebits - - exabits factor: 1e-18 type: digital unit: exabit @@ -1341,7 +1235,6 @@ plural: exabits aliases: - zbit - zbits - - zettabits factor: 1e-21 type: digital unit: zettabit @@ -1350,7 +1243,6 @@ plural: zettabits aliases: - ybit - ybits - - yottabits factor: 1e-24 type: digital unit: yottabit @@ -1359,7 +1251,6 @@ plural: yottabits aliases: - kibit - kibits - - kibibits factor: 0.0009765625 type: digital unit: kibibit @@ -1368,7 +1259,6 @@ plural: kibibits aliases: - mibit - mibits - - mebibits factor: 9.5367431640625e-07 type: digital unit: mebibit @@ -1377,7 +1267,6 @@ plural: mebibits aliases: - gibit - gibits - - gibibits factor: 9.31322574615479e-10 type: digital unit: gibibit @@ -1386,7 +1275,6 @@ plural: gibibits aliases: - tibit - tibits - - tebibits factor: 9.09494701772928e-13 type: digital unit: tebibit @@ -1395,7 +1283,6 @@ plural: tebibits aliases: - pibit - pibits - - pebibits factor: 8.88178419700125e-16 type: digital unit: pebibit @@ -1404,7 +1291,6 @@ plural: pebibits aliases: - eibit - eibits - - exbibits factor: 8.67361737988404e-19 type: digital unit: exbibit @@ -1413,7 +1299,6 @@ plural: exbibits aliases: - zibit - zibits - - zebibits factor: 8.470329472543e-22 type: digital unit: zebibit @@ -1422,14 +1307,12 @@ plural: zebibits aliases: - yibit - yibits - - yobibits factor: 8.27180612553028e-25 type: digital unit: yobibit plural: yobibits --- -aliases: - - bytes +aliases: [] factor: 0.125 type: digital unit: byte @@ -1438,7 +1321,6 @@ plural: bytes aliases: - kb - kbs - - kilobytes factor: 0.000125 type: digital unit: kilobyte @@ -1447,7 +1329,6 @@ plural: kilobytes aliases: - mb - mbs - - megabytes factor: 1.25e-07 type: digital unit: megabyte @@ -1456,7 +1337,6 @@ plural: megabytes aliases: - gb - gbs - - gigabytes factor: 1.25e-10 type: digital unit: gigabyte @@ -1465,7 +1345,6 @@ plural: gigabytes aliases: - tb - tbs - - terabytes factor: 1.25e-13 type: digital unit: terabyte @@ -1474,7 +1353,6 @@ plural: terabytes aliases: - pb - pbs - - petabytes factor: 1.25e-16 type: digital unit: petabyte @@ -1483,7 +1361,6 @@ plural: petabytes aliases: - eb - ebs - - exabytes factor: 1.25e-19 type: digital unit: exabyte @@ -1492,7 +1369,6 @@ plural: exabytes aliases: - zb - zbs - - zettabytes factor: 1.25e-22 type: digital unit: zettabyte @@ -1501,7 +1377,6 @@ plural: zettabytes aliases: - yb - ybs - - yottabytes factor: 1.25e-25 type: digital unit: yottabyte @@ -1510,7 +1385,6 @@ plural: yottabytes aliases: - kib - kibs - - kibibytes factor: 0.0001220703125 type: digital unit: kibibyte @@ -1519,7 +1393,6 @@ plural: kibibytes aliases: - mib - mibs - - mebibytes factor: 1.19209289550781e-07 type: digital unit: mebibyte @@ -1528,7 +1401,6 @@ plural: mebibytes aliases: - gib - gibs - - gibibytes factor: 1.16415321826935e-10 type: digital unit: gibibyte @@ -1537,7 +1409,6 @@ plural: gibibytes aliases: - tib - tibs - - tebibytes factor: 1.13686837721616e-13 type: digital unit: tebibyte @@ -1546,7 +1417,6 @@ plural: tebibytes aliases: - pib - pibs - - pebibytes factor: 1.11022302462516e-16 type: digital unit: pebibyte @@ -1555,7 +1425,6 @@ plural: pebibytes aliases: - eib - eibs - - exbibytes factor: 1.0842021724855e-19 type: digital unit: exbibyte @@ -1564,7 +1433,6 @@ plural: exbibytes aliases: - zib - zibs - - zebibytes factor: 1.05879118406788e-22 type: digital unit: zebibyte @@ -1573,7 +1441,6 @@ plural: zebibytes aliases: - yib - yibs - - yobibytes factor: 1.03397576569129e-25 type: digital unit: yobibyte @@ -1632,7 +1499,6 @@ unit: km/h plural: km/h --- aliases: - - knots - kt - nmi/h factor: 1.943844492440605 From 65ad6fce17ce4490364aabefbb9c5148cdafdb32 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 8 May 2016 22:14:56 +0100 Subject: [PATCH 23/91] Conversions: non-working version using the plural from the YAML --- lib/DDG/Goodie/Conversions.pm | 97 +++++++++++++---------------------- 1 file changed, 35 insertions(+), 62 deletions(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index 8ed191751..4005b207b 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -8,6 +8,7 @@ with 'DDG::GoodieRole::NumberStyler'; use Math::Round qw/nearest/; use utf8; use YAML::XS 'LoadFile'; +use List::Util qw(any); zci answer_type => 'conversions'; zci is_cached => 1; @@ -17,8 +18,9 @@ use bignum; my @types = LoadFile(share('ratios.yml')); my @units = (); -foreach my $type (@types) { +foreach my $type (@types) { push(@units, $type->{'unit'}); + push(@units, $type->{'plural'}) unless $type->{'unit'} eq $type->{'plural'}; push(@units, @{$type->{'aliases'}}); } @@ -35,33 +37,6 @@ my $question_prefix = qr/(?convert|what (?:is|are|does)|how (?:much|many my $factor_re = join('|', ('a', 'an', number_style_regex())); my $guard = qr/^(?$question_prefix)\s?(?$factor_re*)\s?(?$keys)\s(?in|to|into|(?:in to)|from)?\s?(?$factor_re*)\s?(?:of\s)?(?$keys)[\?]?$/i; -# exceptions for pluralized forms: -my %plural_exceptions = ( - 'stone' => 'stone', - 'foot' => 'feet', - 'inch' => 'inches', - 'pounds per square inch' => 'pounds per square inch', - 'ton of TNT' => 'tons of TNT', - 'metric horsepower' => 'metric horsepower', - 'horsepower' => 'horsepower', - 'electrical horsepower' => 'electrical horsepower', - 'pounds force' => 'pounds force', - '坪' => '坪', - 'km/h' => 'km/h', - 'mph' => 'mph', - 'm/s' => 'm/s', - 'ft/s' => 'ft/s', - 'dram avoirdupois' => 'drams avoirdupois', - 'thousandth of an inch' => 'thousandths of an inch', - 'century' => 'centuries', - 'millennium' => 'millennia', - 'mmHg' => 'mmHg', - 'torr' => 'torr', - 'cubic inch' => 'cubic inches', - 'square foot' => 'square feet' -); -my %singular_exceptions = reverse %plural_exceptions; - # fix precision and rounding: my $precision = 3; my $nearest = '.' . ('0' x ($precision-1)) . '1'; @@ -180,10 +155,12 @@ handle query_lc => sub { $result->{'from_unit'} = ($factor == 1 ? "degree" : "degrees") . " $result->{'from_unit'}" if ($result->{'from_unit'} ne "kelvin"); $result->{'to_unit'} = ($result->{'result'} == 1 ? "degree" : "degrees") . " $result->{'to_unit'}" if ($result->{'to_unit'} ne "kelvin"); } else { - $result->{'from_unit'} = set_unit_pluralisation($result->{'from_unit'}, $factor); - $result->{'to_unit'} = set_unit_pluralisation($result->{'to_unit'}, $result->{'result'}); + $result->{'from_unit'} = set_unit_pluralisation($result, $factor); + $result->{'to_unit'} = set_unit_pluralisation($result, $result->{'result'}); } + #warn($result->{'from_unit'}. " | ". $result->{'to_unit'}); + $result->{'result'} = $formatted_result; $result->{'result'} =~ s/\.0{$precision}$//; $result->{'result'} = $styler->for_display($result->{'result'}); @@ -194,31 +171,33 @@ handle query_lc => sub { }; $factor = $styler->for_display($factor); - return $factor . " $result->{'from_unit'} = $result->{'result'} $result->{'to_unit'}", - structured_answer => { - data => { - raw_input => $styler->for_computation($factor), - raw_answer => $styler->for_computation($result->{'result'}), - left_unit => $result->{'from_unit'}, - right_unit => $result->{'to_unit'}, - markup_input => $styler->with_html($factor), - styled_output => $styler->with_html($result->{'result'}), - physical_quantity => $result->{'type'} - }, - templates => { - group => 'text', - options => { - content => 'DDH.conversions.content' - } - } + return "$factor $result->{'from_unit'} = $result->{'result'} $result->{'to_unit'}", + structured_answer => { + data => { + raw_input => $styler->for_computation($factor), + raw_answer => $styler->for_computation($result->{'result'}), + left_unit => $result->{'from_unit'}, + right_unit => $result->{'to_unit'}, + markup_input => $styler->with_html($factor), + styled_output => $styler->with_html($result->{'result'}), + physical_quantity => $result->{'type'} + }, + templates => { + group => 'text', + options => { + content => 'DDH.conversions.content' + } + } }; }; sub looks_plural { my ($unit) = @_; - my @unit_letters = split //, $unit; - return exists $singular_exceptions{$unit} || $unit_letters[-1] eq 's'; +# my @unit_letters = split //, $unit; +# return exists $singular_exceptions{$unit} || $unit_letters[-1] eq 's'; + return any {$_ eq $unit} @units; } + sub convert_temperatures { my ($from, $to, $in_temperature) = @_; @@ -248,11 +227,12 @@ sub get_matches { my @output_matches = (); foreach my $match (@input_matches) { foreach my $type (@types) { - if (lc $match eq $type->{'unit'} || grep { $_ eq lc $match } @{$type->{'aliases'}}) { + if (lc $match eq $type->{'unit'} || lc $match eq $type->{'plural'} || grep { $_ eq lc $match } @{$type->{'aliases'}}) { push(@output_matches,{ type => $type->{'type'}, factor => $type->{'factor'}, unit => $type->{'unit'}, + plural => $type->{'plural'}, can_be_negative => $type->{'can_be_negative'} || '0' }); } @@ -263,10 +243,10 @@ sub get_matches { } sub convert { my ($conversion) = @_; - my @matches = get_matches($conversion->{'from_unit'}, $conversion->{'to_unit'}); return if $conversion->{'factor'} < 0 && !($matches[0]->{'can_be_negative'}); + # matches must be of the same type (e.g., can't convert mass to length): return if ($matches[0]->{'type'} ne $matches[1]->{'type'}); @@ -288,17 +268,10 @@ sub convert { } sub set_unit_pluralisation { my ($unit, $count) = @_; - my $proper_unit = $unit; - - my $already_plural = looks_plural($unit); - - if ($already_plural && $count == 1) { - $proper_unit = $singular_exceptions{$unit} || substr($unit, 0, -1); - } elsif (!$already_plural && $count != 1) { - $proper_unit = $plural_exceptions{$unit} || $unit . 's'; - } - - return $proper_unit; + use Data::Dump qw(dump); + warn ($count, dump($unit)); + return $unit->{'unit'} unless($count == 1); + return $unit->{'plural'}; } 1; From 02b39325add0cc8c1197b9409edc692720ad0190 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 01:15:05 +0100 Subject: [PATCH 24/91] Conversions: Adding JSON representation which works far better than YAML --- share/goodie/conversions/ratios.json | 1202 ++++++++++++++++++++++++++ 1 file changed, 1202 insertions(+) create mode 100755 share/goodie/conversions/ratios.json diff --git a/share/goodie/conversions/ratios.json b/share/goodie/conversions/ratios.json new file mode 100755 index 000000000..7a470c6bb --- /dev/null +++ b/share/goodie/conversions/ratios.json @@ -0,0 +1,1202 @@ +{ + "thousandth of an inch" : { + "factor" : "39370.1", + "unit" : "thousandth of an inch", + "type" : "length", + "aliases" : ["thou", "thous", "mil", "mils", "thousandth of an inch"], + "plural" : "thousandths of an inch" + }, + "terabit" : { + "factor" : "1e-12", + "unit" : "terabit", + "type" : "digital", + "plural" : "terabits", + "aliases" : ["tbit", "tbits"] + }, + "pebibit" : { + "factor" : "8.88178419700125e-16", + "unit" : "pebibit", + "type" : "digital", + "plural" : "pebibits", + "aliases" : ["pibit", "pibits"] + }, + "exbibyte" : { + "plural" : "exbibytes", + "aliases" : ["eib", "eibs"], + "type" : "digital", + "unit" : "exbibyte", + "factor" : "1.0842021724855e-19" + }, + "us teaspoon" : { + "factor" : "202.88413621", + "unit" : "us teaspoon", + "type" : "volume", + "aliases" : ["us tsp", "us tsp.", "teaspoons", "teaspoon", "tsp", "tsp."], + "plural" : "us teaspoons" + }, + "astronomical unit" : { + "factor" : "6.68458712226845e-12", + "unit" : "astronomical unit", + "type" : "length", + "plural" : "astronomical units", + "aliases" : ["au", "aus"] + }, + "bar" : { + "unit" : "bar", + "factor" : "1e-05", + "plural" : "bars", + "aliases" : ["pa", "pas"], + "type" : "pressure" + }, + "pound force" : { + "factor" : "0.224808943099711", + "unit" : "pound force", + "type" : "force", + "plural" : "pounds force", + "aliases" : ["lbs force", "lb force"] + }, + "gigabit" : { + "type" : "digital", + "aliases" : ["gbit", "gbits"], + "plural" : "gigabits", + "factor" : "1e-09", + "unit" : "gigabit" + }, + "imperial gallon" : { + "type" : "volume", + "aliases" : ["uk gallon", "british gallon", "british gallons", "uk gallons", "gb gallons", "gb gallon"], + "plural" : "imperial gallons", + "factor" : "0.219969248299088", + "unit" : "imperial gallon" + }, + "centimeter" : { + "aliases" : ["centimetre", "centimetres", "cm", "cms"], + "plural" : "centimeters", + "type" : "length", + "unit" : "centimeter", + "factor" : "100" + }, + "ton of TNT" : { + "aliases" : ["tnt equivilent", "tonnes of tnt", "tnt"], + "plural" : "tons of TNT", + "type" : "energy", + "unit" : "ton of TNT", + "factor" : "2.39005736137667e-10" + }, + "us tablespoon" : { + "aliases" : ["us tbsp", "us tbsp.", "tablespoons", "tablespoon", "tbsp", "tbsp."], + "plural" : "us tablespoons", + "type" : "volume", + "unit" : "us tablespoon", + "factor" : "67.6280454" + }, + "exabit" : { + "type" : "digital", + "aliases" : ["ebit", "ebits"], + "plural" : "exabits", + "factor" : "1e-18", + "unit" : "exabit" + }, + "atmosphere" : { + "type" : "pressure", + "plural" : "atmospheres", + "aliases" : ["atm", "atms"], + "factor" : "9.86923266716013e-06", + "unit" : "atmosphere" + }, + "zebibyte" : { + "plural" : "zebibytes", + "aliases" : ["zib", "zibs"], + "type" : "digital", + "unit" : "zebibyte", + "factor" : "1.05879118406788e-22" + }, + "tebibyte" : { + "unit" : "tebibyte", + "factor" : "1.13686837721616e-13", + "aliases" : ["tib", "tibs"], + "plural" : "tebibytes", + "type" : "digital" + }, + "link" : { + "factor" : "4.97096953789867", + "unit" : "link", + "type" : "length", + "plural" : "links", + "aliases" : ["gunter's links"] + }, + "carat" : { + "unit" : "carat", + "factor" : "5000000", + "aliases" : ["carat"], + "plural" : "carats", + "type" : "mass" + }, + "watt-second" : { + "factor" : "1", + "unit" : "watt-second", + "type" : "energy", + "aliases" : ["watt second", "watt seconds", "ws"], + "plural" : "watt-seconds" + }, + "millisecond" : { + "plural" : "milliseconds", + "aliases" : ["millisec", "millisecs", "ms"], + "type" : "duration", + "unit" : "millisecond", + "factor" : "86400000" + }, + "exabyte" : { + "factor" : "1.25e-19", + "unit" : "exabyte", + "type" : "digital", + "aliases" : ["eb", "ebs"], + "plural" : "exabytes" + }, + "kilopascal" : { + "unit" : "kilopascal", + "factor" : "0.001", + "aliases" : ["kpa", "kpas"], + "plural" : "kilopascals", + "type" : "pressure" + }, + "metric horsepower" : { + "factor" : "0.0013596216173039", + "unit" : "metric horsepower", + "type" : "power", + "plural" : "metric horsepower", + "aliases" : ["metric horsepowers", "mhp", "hp", "ps", "cv", "hk", "ks", "ch"] + }, + "cubic metre" : { + "plural" : "cubic metres", + "aliases" : ["metre^3", "meter^3", "metres^3", "meters^3", "m^3", "m³"], + "type" : "volume", + "unit" : "cubic metre", + "factor" : "0.001" + }, + "gibibyte" : { + "factor" : "1.16415321826935e-10", + "unit" : "gibibyte", + "type" : "digital", + "aliases" : ["gib", "gibs"], + "plural" : "gibibytes" + }, + "radian" : { + "type" : "angle", + "aliases" : ["rad", "rads"], + "plural" : "radians", + "factor" : "0.0174532925199433", + "unit" : "radian" + }, + "torr" : { + "unit" : "torr", + "factor" : "0.00750062", + "plural" : "torrs", + "aliases" : [], + "type" : "pressure" + }, + "gigapascal" : { + "factor" : "1e-09", + "unit" : "gigapascal", + "type" : "pressure", + "aliases" : ["gpa", "gpas"], + "plural" : "gigapascals" + }, + "imperial fluid ounce" : { + "aliases" : ["imperial fl oz", "imperial fluid oz"], + "plural" : "imperial fluid ounces", + "type" : "volume", + "unit" : "imperial fluid ounce", + "factor" : "28.1560637822832" + }, + "metric ton" : { + "factor" : "1", + "unit" : "metric ton", + "type" : "mass", + "aliases" : ["tonne", "t", "mt", "te", "metric tons", "tonnes", "ts", "mts", "tes"], + "plural" : "metric tonnes" + }, + "cable" : { + "aliases" : [], + "plural" : "cables", + "type" : "length", + "unit" : "cable", + "factor" : "0.00539611824837685" + }, + "petabit" : { + "unit" : "petabit", + "factor" : "1e-15", + "aliases" : ["pbit", "pbits"], + "plural" : "petabits", + "type" : "digital" + }, + "leap year" : { + "type" : "duration", + "plural" : "leap years", + "aliases" : ["leapyear", "leapyr", "leapyrs"], + "factor" : "0.00273224043715847", + "unit" : "leap year" + }, + "tebibit" : { + "plural" : "tebibits", + "aliases" : ["tibit", "tibits"], + "type" : "digital", + "unit" : "tebibit", + "factor" : "9.09494701772928e-13" + }, + "metric tablespoon" : { + "factor" : "66.6666666", + "unit" : "metric tablespoon", + "type" : "volume", + "aliases" : ["metric tbsp", "metric tbsp."], + "plural" : "metric tablespoons" + }, + "horsepower" : { + "type" : "power", + "plural" : "horsepower", + "aliases" : ["mechanical horsepower", "horsepower", "hp", "hp", "bhp"], + "factor" : "0.00134102208959503", + "unit" : "horsepower" + }, + "dry pint" : { + "factor" : "1.81616596853771", + "unit" : "dry pint", + "type" : "volume", + "aliases" : ["pints dry"], + "plural" : "dry pints" + }, + "pebibyte" : { + "plural" : "pebibytes", + "aliases" : ["pib", "pibs"], + "type" : "digital", + "unit" : "pebibyte", + "factor" : "1.11022302462516e-16" + }, + "liquid pint" : { + "plural" : "liquid pints", + "aliases" : ["us pints", "us liquid pint", "us liquid pints"], + "type" : "volume", + "unit" : "liquid pint", + "factor" : "2.11337641886519" + }, + "revolution" : { + "unit" : "revolution", + "factor" : "0.00277777777777778", + "aliases" : ["circle", "circles", "revs"], + "plural" : "revolutions", + "type" : "angle" + }, + "kilogram" : { + "unit" : "kilogram", + "factor" : "1000", + "plural" : "kilograms", + "aliases" : ["kg", "kilo", "kilogramme", "kgs", "kilos", "kilogrammes"], + "type" : "mass" + }, + "kilowatt" : { + "factor" : "0.001", + "unit" : "kilowatt", + "type" : "power", + "plural" : "kilowatts", + "aliases" : ["kw"] + }, + "megabyte" : { + "plural" : "megabytes", + "aliases" : ["mb", "mbs"], + "type" : "digital", + "unit" : "megabyte", + "factor" : "1.25e-07" + }, + "us cup" : { + "factor" : "4.2267528", + "unit" : "us cup", + "type" : "volume", + "aliases" : ["cups", "cup"], + "plural" : "us cups" + }, + "nanowatt" : { + "unit" : "nanowatt", + "factor" : "1000000000", + "aliases" : ["nw"], + "plural" : "nanowatts", + "type" : "power" + }, + "ft/s" : { + "unit" : "ft/s", + "factor" : "3.280839895013123", + "aliases" : ["feet per second", "foot per second", "feet/sec", "feet/second", "foot/sec", "foot/second", "fps", "ft/sec", "ft/second"], + "plural" : "ft/s", + "type" : "speed" + }, + "ounce" : { + "unit" : "ounce", + "factor" : "35274", + "plural" : "ounces", + "aliases" : ["oz", "ozs"], + "type" : "mass" + }, + "cubic millimeter" : { + "unit" : "cubic millimeter", + "factor" : "1000000", + "aliases" : ["cubic millimetre", "cubic millimetres", "millimetre^3", "millimeter^3", "millimetres^3", "millimeters^3", "mm^3", "mm³"], + "plural" : "cubic millimeters", + "type" : "volume" + }, + "day" : { + "aliases" : ["days", "dy", "dys", "d"], + "plural" : "days", + "type" : "duration", + "unit" : "day", + "factor" : "1" + }, + "gigawatt" : { + "unit" : "gigawatt", + "factor" : "1e-09", + "aliases" : ["jiggawatts", "gw"], + "plural" : "gigawatts", + "type" : "power" + }, + "minute" : { + "plural" : "minutes", + "aliases" : ["min", "mins"], + "type" : "duration", + "unit" : "minute", + "factor" : "1440" + }, + "dyne" : { + "factor" : "1e-05", + "unit" : "dyne", + "type" : "force", + "aliases" : [], + "plural" : "dynes" + }, + "yobibit" : { + "plural" : "yobibits", + "aliases" : ["yibit", "yibits"], + "type" : "digital", + "unit" : "yobibit", + "factor" : "8.27180612553028e-25" + }, + "light year" : { + "factor" : "1.05700083402462e-16", + "unit" : "light year", + "type" : "length", + "plural" : "light years", + "aliases" : ["ly", "lys"] + }, + "microwatt" : { + "plural" : "microwatts", + "aliases" : ["μwatts"], + "type" : "power", + "unit" : "microwatt", + "factor" : "1000000" + }, + "square yard" : { + "type" : "area", + "plural" : "square yards", + "aliases" : ["yard^2", "yard²", "yards²", "yards^2", "yd^2", "yd²", "yrd^2", "yrd²"], + "factor" : "11959.9", + "unit" : "square yard" + }, + "rod" : { + "plural" : "rods", + "aliases" : ["rd"], + "type" : "length", + "unit" : "rod", + "factor" : "0.198838781515947" + }, + "square kilometer" : { + "aliases" : ["square kilometre", "square kilometres", "km^2", "km²"], + "plural" : "square kilometers", + "type" : "area", + "unit" : "square kilometer", + "factor" : "0.01" + }, + "semi-circle" : { + "plural" : "semi-circles", + "aliases" : ["semi circle", "semicircle", "semi circles", "semicircles"], + "type" : "angle", + "unit" : "semi-circle", + "factor" : "0.00555555555555556" + }, + "megapascal" : { + "plural" : "megapascals", + "aliases" : ["megapa", "megapas"], + "type" : "pressure", + "unit" : "megapascal", + "factor" : "1e-06" + }, + "mebibit" : { + "unit" : "mebibit", + "factor" : "9.5367431640625e-07", + "plural" : "mebibits", + "aliases" : ["mibit", "mibits"], + "type" : "digital" + }, + "foot" : { + "type" : "length", + "aliases" : ["ft", "international foot", "international feet", "survey foot", "survey feet"], + "plural" : "feet", + "factor" : "3.2808398950131233595800524934383", + "unit" : "foot" + }, + "zettabyte" : { + "plural" : "zettabytes", + "aliases" : ["zb", "zbs"], + "type" : "digital", + "unit" : "zettabyte", + "factor" : "1.25e-22" + }, + "mmHg" : { + "aliases" : ["mmhg"], + "plural" : "mmHg", + "type" : "pressure", + "unit" : "mmHg", + "factor" : "0.00750061683" + }, + "watt" : { + "aliases" : ["w"], + "plural" : "watts", + "type" : "power", + "unit" : "watt", + "factor" : "1" + }, + "league" : { + "type" : "length", + "plural" : "leagues", + "aliases" : [], + "factor" : "0.000207123730745778", + "unit" : "league" + }, + "fahrenheit" : { + "unit" : "fahrenheit", + "factor" : "1", + "aliases" : ["f", "°f"], + "plural" : "fahrenheit", + "can_be_negative" : "1", + "type" : "temperature" + }, + "exbibit" : { + "factor" : "8.67361737988404e-19", + "unit" : "exbibit", + "type" : "digital", + "aliases" : ["eibit", "eibits"], + "plural" : "exbibits" + }, + "meter" : { + "factor" : "1", + "unit" : "meter", + "type" : "length", + "plural" : "meters", + "aliases" : ["metre", "metres", "m"] + }, + "parsec" : { + "unit" : "parsec", + "factor" : "3.24077923047971e-17", + "aliases" : ["pc", "pcs"], + "plural" : "parsecs", + "type" : "length" + }, + "yobibyte" : { + "factor" : "1.03397576569129e-25", + "unit" : "yobibyte", + "type" : "digital", + "plural" : "yobibytes", + "aliases" : ["yib", "yibs"] + }, + "yottabit" : { + "factor" : "1e-24", + "unit" : "yottabit", + "type" : "digital", + "aliases" : ["ybit", "ybits"], + "plural" : "yottabits" + }, + "pascal" : { + "type" : "pressure", + "aliases" : ["pa", "pas"], + "plural" : "pascals", + "factor" : "1", + "unit" : "pascal" + }, + "kilometer" : { + "plural" : "kilometers", + "aliases" : ["kilometre", "kilometres", "km", "kms", "klick", "klicks"], + "type" : "length", + "unit" : "kilometer", + "factor" : "0.001" + }, + "square meter" : { + "factor" : "10000", + "unit" : "square meter", + "type" : "area", + "aliases" : ["metre^2", "meter^2", "metres^2", "meters^2", "square metre", "square metres", "m^2", "m²"], + "plural" : "square meters" + }, + "picowatt" : { + "type" : "power", + "aliases" : ["pw"], + "plural" : "picowatts", + "factor" : "1000000000000", + "unit" : "picowatt" + }, + "kibibyte" : { + "type" : "digital", + "aliases" : ["kib", "kibs"], + "plural" : "kibibytes", + "factor" : "0.0001220703125", + "unit" : "kibibyte" + }, + "quart" : { + "factor" : "1.05668820943259", + "unit" : "quart", + "type" : "volume", + "aliases" : ["liquid quart", "us quart", "us quarts", "liquid quarts"], + "plural" : "quarts" + }, + "metric dessert spoon" : { + "type" : "volume", + "aliases" : ["dessert spoons", "dessert spoon", "dstspn", "dstspn."], + "plural" : "metric dessert spoons", + "factor" : "100", + "unit" : "metric dessert spoon" + }, + "square foot" : { + "type" : "area", + "aliases" : ["feet^2", "feet²", "foot^2", "foot²", "ft²", "ft^2"], + "plural" : "square feet", + "factor" : "107639.1", + "unit" : "square foot" + }, + "petabyte" : { + "type" : "digital", + "plural" : "petabytes", + "aliases" : ["pb", "pbs"], + "factor" : "1.25e-16", + "unit" : "petabyte" + }, + "nanosecond" : { + "plural" : "nanoseconds", + "aliases" : ["nanosec", "nanosecs", "ns"], + "type" : "duration", + "unit" : "nanosecond", + "factor" : "86400000000000" + }, + "mile" : { + "type" : "length", + "aliases" : ["mi", "statute mile", "statute miles", "land mile", "land miles"], + "plural" : "miles", + "factor" : "0.000621371192237334", + "unit" : "mile" + }, + "hectare" : { + "plural" : "hectares", + "aliases" : ["ha"], + "type" : "area", + "unit" : "hectare", + "factor" : "1" + }, + "yottabyte" : { + "type" : "digital", + "aliases" : ["yb", "ybs"], + "plural" : "yottabytes", + "factor" : "1.25e-25", + "unit" : "yottabyte" + }, + "square centimeter" : { + "type" : "area", + "aliases" : ["square centimetre", "square centimetres", "cm^2", "cm²"], + "plural" : "square centimeters", + "factor" : "100000000", + "unit" : "square centimeter" + }, + "reaumur" : { + "type" : "temperature", + "aliases" : ["re"], + "plural" : "reamur", + "can_be_negative" : "1", + "factor" : "1", + "unit" : "reaumur" + }, + "cubic centimeter" : { + "factor" : "1000", + "unit" : "cubic centimeter", + "type" : "volume", + "plural" : "cubic centimeters", + "aliases" : ["centimetre^3", "centimeter^3", "centimetres^3", "centimeters^3", "cm^3", "cm³", "cc", "ccm"] + }, + "furlong" : { + "unit" : "furlong", + "factor" : "0.00497096953789867", + "plural" : "furlongs", + "aliases" : ["furlng"], + "type" : "length" + }, + "knot" : { + "factor" : "1.943844492440605", + "unit" : "knot", + "type" : "speed", + "aliases" : ["kt", "nmi/h"], + "plural" : "knots" + }, + "british thermal unit" : { + "type" : "energy", + "plural" : "british thermal units", + "aliases" : ["btu", "btus"], + "factor" : "0.000948316737790422", + "unit" : "british thermal unit" + }, + "pound per square inch" : { + "unit" : "pound per square inch", + "factor" : "0.000145036839357197", + "aliases" : ["psis", "psi", "lbs/inch^2", "p.s.i.", "p.s.i"], + "plural" : "pounds per square inch", + "type" : "pressure" + }, + "kilodyne" : { + "unit" : "kilodyne", + "factor" : "0.01", + "aliases" : [], + "plural" : "kildynes", + "type" : "force" + }, + "thermochemical gram calorie" : { + "type" : "energy", + "aliases" : ["small calories", "chemical calorie", "chemical calories"], + "plural" : "thermochemical gran calories", + "factor" : "0.239005736137667", + "unit" : "thermochemical gram calorie" + }, + "bit" : { + "plural" : "bits", + "aliases" : [], + "type" : "digital", + "unit" : "bit", + "factor" : "1" + }, + "millimeter" : { + "unit" : "millimeter", + "factor" : "1000", + "plural" : "millimeters", + "aliases" : ["millimetre", "millimetres", "mm", "mms"], + "type" : "length" + }, + "kelvin" : { + "unit" : "kelvin", + "factor" : "1", + "aliases" : ["k"], + "plural" : "kelvin", + "type" : "temperature" + }, + "month" : { + "factor" : "0.0328767123287671", + "unit" : "month", + "type" : "duration", + "aliases" : ["mons", "mns", "mn"], + "plural" : "months" + }, + "imperial pint" : { + "type" : "volume", + "aliases" : ["pints", "pint", "uk pint", "british pint", "pts"], + "plural" : "imperial pints", + "factor" : "1.7597539863927", + "unit" : "imperial pint" + }, + "millilitre" : { + "aliases" : ["milliliter", "milliliters", "ml"], + "plural" : "millilitres", + "type" : "volume", + "unit" : "millilitre", + "factor" : "1000" + }, + "watt-hour" : { + "plural" : "watt-hours", + "aliases" : ["watt hour", "watt hours", "wh"], + "type" : "energy", + "unit" : "watt-hour", + "factor" : "0.000277777777777778" + }, + "petawatt" : { + "type" : "power", + "plural" : "petawatts", + "aliases" : ["pw"], + "factor" : "1e-15", + "unit" : "petawatt" + }, + "grain" : { + "plural" : "grains", + "aliases" : ["grain", "gr", "troy grain", "troy grains"], + "type" : "mass", + "unit" : "grain", + "factor" : "15432358.3529414" + }, + "square mile" : { + "factor" : "0.00386102160083284", + "unit" : "square mile", + "type" : "area", + "plural" : "square miles", + "aliases" : ["sq mi", "square statute mile", "square statute miles", "square land mile", "square land miles", "miles^2", "miles²"] + }, + "long ton" : { + "type" : "mass", + "aliases" : ["weight ton", "imperial ton", "long tons", "weight tons", "imperial tons"], + "plural" : "long tons", + "factor" : "0.984207", + "unit" : "long ton" + }, + "newton" : { + "factor" : "1", + "unit" : "newton", + "type" : "force", + "plural" : "newtons", + "aliases" : ["n"] + }, + "year" : { + "unit" : "year", + "factor" : "0.00273972602739726", + "aliases" : ["yr", "yrs"], + "plural" : "years", + "type" : "duration" + }, + "litre" : { + "factor" : "1", + "unit" : "litre", + "type" : "volume", + "plural" : "litres", + "aliases" : ["liter", "liters", "l", "litter", "litters"] + }, + "kilobyte" : { + "type" : "digital", + "aliases" : ["kb", "kbs"], + "plural" : "kilobytes", + "factor" : "0.000125", + "unit" : "kilobyte" + }, + "week" : { + "unit" : "week", + "factor" : "0.142857142857143", + "aliases" : ["wks", "wk"], + "plural" : "weeks", + "type" : "duration" + }, + "megadyne" : { + "factor" : "10", + "unit" : "megadyne", + "type" : "force", + "aliases" : [], + "plural" : "megadynes" + }, + "nautical mile" : { + "type" : "length", + "aliases" : ["n", "ns", "nm", "nms", "nmi", "nmis"], + "plural" : "nautical miles", + "factor" : "0.000539957", + "unit" : "nautical mile" + }, + "square inch" : { + "unit" : "square inch", + "factor" : "15500031", + "aliases" : ["inch^2", "inches^2", "squinch", "in^2", "in²"], + "plural" : "square inches", + "type" : "area" + }, + "millennium" : { + "unit" : "millennium", + "factor" : "0.00000273972602739726", + "aliases" : [], + "plural" : "millennia", + "type" : "duration" + }, + "gigabyte" : { + "plural" : "gigabytes", + "aliases" : ["gb", "gbs"], + "type" : "digital", + "unit" : "gigabyte", + "factor" : "1.25e-10" + }, + "microsecond" : { + "plural" : "microseconds", + "aliases" : ["microsec", "microsecs", "µs"], + "type" : "duration", + "unit" : "microsecond", + "factor" : "86400000000" + }, + "celsius" : { + "unit" : "celsius", + "factor" : "1", + "plural" : "celsius", + "can_be_negative" : "1", + "aliases" : ["c", "°c"], + "type" : "temperature" + }, + "kilonewtons" : { + "unit" : "kilonewtons", + "factor" : "0.001", + "aliases" : ["kn"], + "plural" : "kilonewtons", + "type" : "force" + }, + "second" : { + "factor" : "86400", + "unit" : "second", + "type" : "duration", + "plural" : "seconds", + "aliases" : ["sec", "s"] + }, + "electron volt" : { + "factor" : "6.2415096e+18", + "unit" : "electron volt", + "type" : "energy", + "plural" : "electron volts", + "aliases" : ["electronvolt", "electronvolts", "ev", "evs"] + }, + "gradian" : { + "factor" : "1.11111111111111", + "unit" : "gradian", + "type" : "angle", + "plural" : "gradians", + "aliases" : ["grad", "grads", "gon", "gons", "grade", "grades"] + }, + "kilobit" : { + "aliases" : ["kbit", "kbits"], + "plural" : "kilobits", + "type" : "digital", + "unit" : "kilobit", + "factor" : "0.001" + }, + "kilowatt-hour" : { + "factor" : "2.77777777777778e-07", + "unit" : "kilowatt-hour", + "type" : "energy", + "aliases" : ["kilowatt hour", "kilowatt hours", "kwh"], + "plural" : "kilowatt-hours" + }, + "pound" : { + "type" : "mass", + "aliases" : ["lb", "lbm", "pound mass", "lbs", "lbms", "pounds mass"], + "plural" : "pounds", + "factor" : "2204.62", + "unit" : "pound" + }, + "terabyte" : { + "plural" : "terabytes", + "aliases" : ["tb", "tbs"], + "type" : "digital", + "unit" : "terabyte", + "factor" : "1.25e-13" + }, + "avoirdupois dram" : { + "type" : "mass", + "plural" : "avoirdupois drams", + "aliases" : ["dram", "drams", "dram avoirdupois", "drams avoirdupois", "avoirdupois dram"], + "factor" : "564383.3912", + "unit" : "avoirdupois dram" + }, + "gram" : { + "factor" : "1000000", + "unit" : "gram", + "type" : "mass", + "plural" : "grams", + "aliases" : ["g", "gm", "gramme", "gs", "gms", "grammes"] + }, + "inch" : { + "factor" : "39.37007874015748031496062992126", + "unit" : "inch", + "type" : "length", + "aliases" : ["in", "ins"], + "plural" : "inches" + }, + "gibibit" : { + "type" : "digital", + "plural" : "gibibits", + "aliases" : ["gibit", "gibits"], + "factor" : "9.31322574615479e-10", + "unit" : "gibibit" + }, + "century" : { + "plural" : "centuries", + "aliases" : [], + "type" : "duration", + "unit" : "century", + "factor" : "0.0000273972602739726" + }, + "erg" : { + "factor" : "1e-07", + "unit" : "erg", + "type" : "energy", + "aliases" : ["ergon", "ergons"], + "plural" : "ergs" + }, + "terawatt" : { + "type" : "power", + "aliases" : ["tw"], + "plural" : "terawatts", + "factor" : "1e-12", + "unit" : "terawatt" + }, + "joule" : { + "aliases" : ["j", "js"], + "plural" : "joules", + "type" : "energy", + "unit" : "joule", + "factor" : "1" + }, + "milliwatt" : { + "type" : "power", + "plural" : "milliwatts", + "aliases" : [], + "factor" : "1000", + "unit" : "milliwatt" + }, + "chain" : { + "unit" : "chain", + "factor" : "0.0497096953789867", + "plural" : "chains", + "aliases" : ["gunter's chains"], + "type" : "length" + }, + "us gallon" : { + "type" : "volume", + "plural" : "us gallons", + "aliases" : ["fluid gallon", "us fluid gallon", "fluid gallons", "gallon", "gallons"], + "factor" : "0.264172052358148", + "unit" : "us gallon" + }, + "electrical horsepower" : { + "type" : "power", + "plural" : "electrical horsepower", + "aliases" : ["electrical horsepowers", "hp", "hp"], + "factor" : "0.00134048257372654", + "unit" : "electrical horsepower" + }, + "fathom" : { + "type" : "length", + "plural" : "fathoms", + "aliases" : ["ftm", "ftms"], + "factor" : "0.539611824837685", + "unit" : "fathom" + }, + "megabit" : { + "aliases" : ["mbit", "mbits"], + "plural" : "megabits", + "type" : "digital", + "unit" : "megabit", + "factor" : "1e-06" + }, + "metric teaspoon" : { + "unit" : "metric teaspoon", + "factor" : "200", + "plural" : "metric teaspoons", + "aliases" : ["metric tsp", "metric tsp."], + "type" : "volume" + }, + "milligram" : { + "factor" : "1000000000", + "unit" : "milligram", + "type" : "mass", + "plural" : "milligrams", + "aliases" : ["mg", "mgs"] + }, + "microgram" : { + "unit" : "microgram", + "factor" : "1000000000000", + "aliases" : ["mcg", "mcgs", "µg"], + "plural" : "micrograms", + "type" : "mass" + }, + "m/s" : { + "unit" : "m/s", + "factor" : "1", + "plural" : "m/s", + "aliases" : ["meters per second", "metres per second", "meter per second", "metre per second", "meter/second", "metre/second", "meters/second", "metres/second", "mps"], + "type" : "speed" + }, + "meganewton" : { + "factor" : "1e-06", + "unit" : "meganewton", + "type" : "force", + "aliases" : ["mn"], + "plural" : "meganewtons" + }, + "decade" : { + "aliases" : [], + "plural" : "decades", + "type" : "duration", + "unit" : "decade", + "factor" : "0.000273972602739726" + }, + "mebibyte" : { + "type" : "digital", + "aliases" : ["mib", "mibs"], + "plural" : "mebibytes", + "factor" : "1.19209289550781e-07", + "unit" : "mebibyte" + }, + "kibibit" : { + "factor" : "0.0009765625", + "unit" : "kibibit", + "type" : "digital", + "plural" : "kibibits", + "aliases" : ["kibit", "kibits"] + }, + "degree" : { + "factor" : "1", + "unit" : "degree", + "type" : "angle", + "plural" : "degrees", + "aliases" : ["deg", "degs"] + }, + "byte" : { + "factor" : "0.125", + "unit" : "byte", + "type" : "digital", + "plural" : "bytes", + "aliases" : [] + }, + "large calorie" : { + "plural" : "large calories", + "aliases" : ["food calorie", "food calories", "kcals", "kcal"], + "type" : "energy", + "unit" : "large calorie", + "factor" : "0.000239005736137667" + }, + "cubic inch" : { + "plural" : "cubic inches", + "aliases" : ["cubic inch", "cubic in", "cu inch", "cu in", "inch^3", "in^3", "cui"], + "type" : "volume", + "unit" : "cubic inch", + "factor" : "61.024" + }, + "rankine" : { + "unit" : "rankine", + "factor" : "1", + "plural" : "rankine", + "aliases" : ["r"], + "type" : "temperature" + }, + "zettabit" : { + "type" : "digital", + "aliases" : ["zbit", "zbits"], + "plural" : "zettabits", + "factor" : "1e-21", + "unit" : "zettabit" + }, + "hour" : { + "plural" : "hours", + "aliases" : ["hr", "hrs", "h"], + "type" : "duration", + "unit" : "hour", + "factor" : "24" + }, + "acre" : { + "plural" : "acres", + "aliases" : [], + "type" : "area", + "unit" : "acre", + "factor" : "2.4710439" + }, + "yard" : { + "aliases" : ["yd", "yds", "yrds"], + "plural" : "yards", + "type" : "length", + "unit" : "yard", + "factor" : "1.0936132983377077865266841644794" + }, + "ton" : { + "factor" : "1.10231", + "unit" : "ton", + "type" : "mass", + "plural" : "tons", + "aliases" : ["short ton", "short tons"] + }, + "giganewton" : { + "factor" : "1e-09", + "unit" : "giganewton", + "type" : "force", + "aliases" : ["gn"], + "plural" : "giganewtons" + }, + "poundal" : { + "factor" : "7.23301385120989", + "unit" : "poundal", + "type" : "force", + "aliases" : ["pdl"], + "plural" : "poundals" + }, + "stone" : { + "type" : "mass", + "aliases" : ["st", "stones", "sts"], + "plural" : "stone", + "factor" : "157.473", + "unit" : "stone" + }, + "fortnight" : { + "unit" : "fortnight", + "factor" : "0.0714285714285714", + "plural" : "fortnights", + "aliases" : [], + "type" : "duration" + }, + "zebibit" : { + "type" : "digital", + "aliases" : ["zibit", "zibits"], + "plural" : "zebibits", + "factor" : "8.470329472543e-22", + "unit" : "zebibit" + }, + "megawatt" : { + "factor" : "1e-06", + "unit" : "megawatt", + "type" : "power", + "plural" : "megawatts", + "aliases" : ["mw"] + }, + "mph" : { + "plural" : "mph", + "aliases" : ["mi/h", "miles/hour", "miles per hour", "mile per hour"], + "type" : "speed", + "unit" : "mph", + "factor" : "2.236941851939304" + }, + "square millimeter" : { + "unit" : "square millimeter", + "factor" : "10000000000", + "plural" : "square millimeters", + "aliases" : ["square millimetre", "square millimetres", "mm^2", "mm²"], + "type" : "area" + }, + "km/h" : { + "factor" : "3.6", + "unit" : "km/h", + "type" : "speed", + "plural" : "km/h", + "aliases" : ["kilometer per hour", "kilometre per hour", "kph", "kmph", "kilometers per hour", "kilometres per hour"] + }, + "坪" : { + "unit" : "坪", + "factor" : "3024.80338778", + "plural" : "坪", + "aliases" : ["ping"], + "type" : "area" + }, + "imperial quart" : { + "unit" : "imperial quart", + "factor" : "7.03901594557081", + "plural" : "imperial quarts", + "aliases" : ["british quarts", "british quart"], + "type" : "volume" + }, + "quadrant" : { + "plural" : "quadrants", + "aliases" : ["quads", "quad"], + "type" : "angle", + "unit" : "quadrant", + "factor" : "0.0111111111111111" + }, + "us fluid ounce" : { + "type" : "volume", + "plural" : "us fluid ounces", + "aliases" : ["us fl oz", "fl oz", "fl. oz", "fluid oz"], + "factor" : "33.814022701843", + "unit" : "us fluid ounce" + } +} From 0141a0558b2fa58013dc4e2344b6ed402b763ae6 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Mon, 9 May 2016 17:25:48 +0100 Subject: [PATCH 25/91] Rename share/goodie/cheat_sheets/visual-studio.json to share/goodie/cheat_sheets/json/visual-studio.json --- share/goodie/cheat_sheets/{ => json}/visual-studio.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename share/goodie/cheat_sheets/{ => json}/visual-studio.json (100%) diff --git a/share/goodie/cheat_sheets/visual-studio.json b/share/goodie/cheat_sheets/json/visual-studio.json similarity index 100% rename from share/goodie/cheat_sheets/visual-studio.json rename to share/goodie/cheat_sheets/json/visual-studio.json From be39939bf7899ee459c486b89a6321a5c5a41906 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Mon, 9 May 2016 17:41:02 +0100 Subject: [PATCH 26/91] Fix missing template type (#3017) --- share/goodie/cheat_sheets/json/visual-studio.json | 1 + 1 file changed, 1 insertion(+) diff --git a/share/goodie/cheat_sheets/json/visual-studio.json b/share/goodie/cheat_sheets/json/visual-studio.json index c109b4572..aefe038c4 100644 --- a/share/goodie/cheat_sheets/json/visual-studio.json +++ b/share/goodie/cheat_sheets/json/visual-studio.json @@ -5,6 +5,7 @@ "sourceName": "Microsoft", "sourceUrl": "https://msdn.microsoft.com/en-us/library/da5kh0wa.aspx" }, + "template_type": "keyboard", "section_order": ["Edit","Debug","Build","Project"], "sections": { "Edit": [{ From e15deda8cf2e255690ccbf6e4a122db304f7db57 Mon Sep 17 00:00:00 2001 From: Ethan Chiu Date: Mon, 9 May 2016 13:36:31 -0400 Subject: [PATCH 27/91] Telugu Cheat Sheet: Removed "english to telugu" and "basic telugu" aliases (#3003) * Removed "english to telugu" and "basic telugu" https://github.com/duckduckgo/zeroclickinfo-goodies/issue/2967 --- share/goodie/cheat_sheets/json/language/telugu.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/share/goodie/cheat_sheets/json/language/telugu.json b/share/goodie/cheat_sheets/json/language/telugu.json index 310eec17f..2567621f0 100644 --- a/share/goodie/cheat_sheets/json/language/telugu.json +++ b/share/goodie/cheat_sheets/json/language/telugu.json @@ -6,10 +6,6 @@ "sourceName":"Wikitravel", "sourceUrl":"http://wikitravel.org/en/Telugu_phrasebook" }, - "aliases":[ - "english to telugu", - "basic telugu" - ], "template_type":"language", "section_order":[ "Basics", @@ -269,4 +265,4 @@ } ] } -} \ No newline at end of file +} From d1914da1b9803fe626d92bd1f78c9b8513f53191 Mon Sep 17 00:00:00 2001 From: Indranil Dutta Date: Mon, 9 May 2016 23:08:56 +0530 Subject: [PATCH 28/91] Updated aliases as per #2967 (#2996) --- share/goodie/cheat_sheets/json/finnish.json | 1 - share/goodie/cheat_sheets/json/high-valyrian.json | 2 +- share/goodie/cheat_sheets/json/language/kannada.json | 4 ---- share/goodie/cheat_sheets/json/language/spanish.json | 2 +- 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/share/goodie/cheat_sheets/json/finnish.json b/share/goodie/cheat_sheets/json/finnish.json index fcdbcdcad..662d27d94 100644 --- a/share/goodie/cheat_sheets/json/finnish.json +++ b/share/goodie/cheat_sheets/json/finnish.json @@ -2,7 +2,6 @@ "id": "finnish_cheat_sheet", "name": "Finnish Cheat Sheet", "description": "Basic Finnish words and phrases", - "aliases": ["english to finnish", "basic finnish"], "template_type": "language", "section_order": ["Basics", "Getting Help", "Travelling", "Etiquette", "Going out for dinner", "Numbers"], "sections": { diff --git a/share/goodie/cheat_sheets/json/high-valyrian.json b/share/goodie/cheat_sheets/json/high-valyrian.json index 1043cfc77..e325b206d 100644 --- a/share/goodie/cheat_sheets/json/high-valyrian.json +++ b/share/goodie/cheat_sheets/json/high-valyrian.json @@ -9,7 +9,7 @@ }, "aliases": [ - "valyrian", "game of thrones language", "valyrian language" + "valyrian" ], "template_type": "language", diff --git a/share/goodie/cheat_sheets/json/language/kannada.json b/share/goodie/cheat_sheets/json/language/kannada.json index c931821a8..fc041c8db 100644 --- a/share/goodie/cheat_sheets/json/language/kannada.json +++ b/share/goodie/cheat_sheets/json/language/kannada.json @@ -8,10 +8,6 @@ "sourceUrl" : "http://www.omniglot.com/language/phrases/kannada.php" }, - "aliases": [ - "basic kannada" - ], - "template_type": "language", "section_order": [ diff --git a/share/goodie/cheat_sheets/json/language/spanish.json b/share/goodie/cheat_sheets/json/language/spanish.json index 224d5a46f..106a70c75 100644 --- a/share/goodie/cheat_sheets/json/language/spanish.json +++ b/share/goodie/cheat_sheets/json/language/spanish.json @@ -9,7 +9,7 @@ }, "aliases": [ - "spanish words", "spanish to english", "spanish greetings", "basic spanish", "spanish questions" + "spanish words", "spanish to english", "spanish greetings", "spanish questions" ], "template_type": "language", From a873ff422843dce5cea12100ae1d6f6c3d0294e1 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Mon, 9 May 2016 18:39:46 +0100 Subject: [PATCH 29/91] Remove extra alias We missed one! --- share/goodie/cheat_sheets/json/language/spanish.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/goodie/cheat_sheets/json/language/spanish.json b/share/goodie/cheat_sheets/json/language/spanish.json index 106a70c75..1215a60d4 100644 --- a/share/goodie/cheat_sheets/json/language/spanish.json +++ b/share/goodie/cheat_sheets/json/language/spanish.json @@ -9,7 +9,7 @@ }, "aliases": [ - "spanish words", "spanish to english", "spanish greetings", "spanish questions" + "spanish words", "spanish greetings", "spanish questions" ], "template_type": "language", @@ -330,4 +330,4 @@ } ] } -} \ No newline at end of file +} From 06e0c534be2aaf6b6b1e4ba15aae58551f7ea3bb Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Sat, 19 Mar 2016 11:32:08 +0000 Subject: [PATCH 30/91] Add support for 'ignore'd phrases These allow categories (and/or cheat sheets) to specify phrases that should be ignored when triggering. For example, many language cheat sheets use 'english to X' as an alias, but this would be better placed in 'ignore'. This would allow these cheat sheets to trigger on 'english to X cheat sheet', 'english to X phrases', 'X phrases english to' (you decide whether you like that last one ;)) etc... In essence, the 'ignore' attribute defines an array of phrases that should be entirely stripped from the query when that cheat sheet or category triggers. --- lib/DDG/Goodie/CheatSheets.pm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/DDG/Goodie/CheatSheets.pm b/lib/DDG/Goodie/CheatSheets.pm index b23e127e7..66bf5357e 100644 --- a/lib/DDG/Goodie/CheatSheets.pm +++ b/lib/DDG/Goodie/CheatSheets.pm @@ -45,12 +45,23 @@ sub generate_triggers { my %triggers; # This will contain a lookup from triggers to categories and/or files. my %trigger_lookup; + # This will contain all the ignored phrases and their associated categories. + my %ignore_phrases; while (my ($name, $trigger_setsh) = each %spec_triggers) { + my $ignore_phrases = delete $trigger_setsh->{ignore}; while (my ($trigger_type, $triggersh) = each %$trigger_setsh) { foreach my $trigger (@{$triggersh}) { # Add trigger to global triggers. $triggers{$trigger_type}{$trigger} = 1; + # Handle ignored components - these will be stripped + # from query and not be included in final trigger. + if (defined $ignore_phrases) { + my %new_ignore_phrases = map { $_ => 1 } + (keys %{$ignore_phrases{$trigger} || {}}, + @$ignore_phrases); + $ignore_phrases{$trigger} = \%new_ignore_phrases; + } my %new_triggers = map { $_ => 1} (keys %{$trigger_lookup{$trigger}}); if ($name !~ /cheat_sheet$/) { @@ -65,7 +76,7 @@ sub generate_triggers { while (my ($trigger_type, $triggers) = each %triggers) { triggers $trigger_type => (keys %{$triggers}); } - return %trigger_lookup; + return (\%ignore_phrases, %trigger_lookup); } # Initialize aliases. @@ -100,13 +111,19 @@ sub get_aliases { my $aliases = get_aliases(); -my %trigger_lookup = generate_triggers($aliases); +my ($trigger_ignore, %trigger_lookup) = generate_triggers($aliases); handle remainder => sub { my $remainder = shift; my $trigger = join(' ', split /\s+/o, lc($req->matched_trigger)); my $lookup = $trigger_lookup{$trigger}; + if (exists $trigger_ignore->{$trigger}) { + foreach my $ignore (keys %{$trigger_ignore->{$trigger}}) { + $remainder =~ s/\b$ignore\b//; + } + $remainder =~ s/^\s*(.+?)\s*$/$1/; + } my $file = $aliases->{join(' ', split /\s+/o, lc($remainder))} or return; open my $fh, $file or return; From 2e01b87335e159d972e21a7a05487a4cb72b5747 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Sat, 19 Mar 2016 11:34:47 +0000 Subject: [PATCH 31/91] Add 'english to' ignore for language category --- share/goodie/cheat_sheets/triggers.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/goodie/cheat_sheets/triggers.yaml b/share/goodie/cheat_sheets/triggers.yaml index 9e542e790..9b07024c8 100644 --- a/share/goodie/cheat_sheets/triggers.yaml +++ b/share/goodie/cheat_sheets/triggers.yaml @@ -66,6 +66,8 @@ categories: startend: - "phrases" - "translations" + ignore: + - "english to" # Shows links to other sites. links: startend: From 8531c333008029ee6fd6ed1100e6646cbce7c030 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Sat, 26 Mar 2016 13:20:17 +0000 Subject: [PATCH 32/91] Add some default ignores Expands cheat sheet triggering a bit more. --- share/goodie/cheat_sheets/triggers.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/share/goodie/cheat_sheets/triggers.yaml b/share/goodie/cheat_sheets/triggers.yaml index 9b07024c8..00fbc7fdf 100644 --- a/share/goodie/cheat_sheets/triggers.yaml +++ b/share/goodie/cheat_sheets/triggers.yaml @@ -36,6 +36,8 @@ categories: - "cheat codes" - "cheats" - "secrets" + ignore: + - "game" # Describes or introduces syntax of a programming language. code: startend: @@ -46,6 +48,8 @@ categories: startend: - "cheat sheet" - "cheatsheet" + ignore: + - "for" # Provides a step-by-step guide. guide: startend: @@ -61,19 +65,26 @@ categories: - "keyboard shortcuts" - "keys" - "shortcuts" + ignore: + - "default" # Introduces basic translations for a human language. language: startend: - "phrases" - "translations" ignore: + - "basic" - "english to" + - "language" # Shows links to other sites. links: startend: - "links" - "sites" - "websites" + ignore: + - "list" + - "list of" # Shows mathematical equations. math: startend: @@ -84,8 +95,9 @@ categories: reference: startend: - "help" - - "quick reference" - "reference" + ignore: + - "quick" # Describes commands that can be entered at a terminal. terminal: startend: From 010351ab80f13d1b4eab61eb3737d652804bc51b Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Sat, 26 Mar 2016 14:34:37 +0000 Subject: [PATCH 33/91] Remove 'for' ignore Clashing with various cheat sheets - potential to come back to this later. --- share/goodie/cheat_sheets/triggers.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/goodie/cheat_sheets/triggers.yaml b/share/goodie/cheat_sheets/triggers.yaml index 00fbc7fdf..bb7881e29 100644 --- a/share/goodie/cheat_sheets/triggers.yaml +++ b/share/goodie/cheat_sheets/triggers.yaml @@ -48,8 +48,6 @@ categories: startend: - "cheat sheet" - "cheatsheet" - ignore: - - "for" # Provides a step-by-step guide. guide: startend: From d6785cb5abb344a71427adde4a8d4bcbb66b0dc3 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Tue, 26 Apr 2016 16:05:24 +0100 Subject: [PATCH 34/91] Ensure tests are alphabetical Easier to read and locate cheat sheets when tests are alphabetical. --- t/CheatSheets/CheatSheetsJSON.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/CheatSheets/CheatSheetsJSON.t b/t/CheatSheets/CheatSheetsJSON.t index 4b3384b7f..ad2c8b7f5 100755 --- a/t/CheatSheets/CheatSheetsJSON.t +++ b/t/CheatSheets/CheatSheetsJSON.t @@ -63,7 +63,7 @@ my @test_paths = File::Find::Rule->file()->name(@fnames)->in($json_dir); my $max_name_len = max map { $_ =~ /.+\/(.+)\.json$/; length $1 } @test_paths; # Iterate over all Cheat Sheet JSON files... -foreach my $path (@test_paths) { +foreach my $path (sort @test_paths) { my ($file_name) = $path =~ /$json_dir\/(.+)/; my ($name) = $path =~ /.+\/(.+)\.json$/; From 0e1ff0e524db1be144803e94592e87ae7195f7f7 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Fri, 29 Apr 2016 14:55:48 +0100 Subject: [PATCH 35/91] Ensure tests are *fully* alphabetically sorted Issue with language cheat sheets being lexically sorted under 'l', and thus being inserted halfway(ish) through the tests. Feexed. --- t/CheatSheets/CheatSheetsJSON.t | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/t/CheatSheets/CheatSheetsJSON.t b/t/CheatSheets/CheatSheetsJSON.t index ad2c8b7f5..144c30ec9 100755 --- a/t/CheatSheets/CheatSheetsJSON.t +++ b/t/CheatSheets/CheatSheetsJSON.t @@ -62,8 +62,16 @@ my @test_paths = File::Find::Rule->file()->name(@fnames)->in($json_dir); my $max_name_len = max map { $_ =~ /.+\/(.+)\.json$/; length $1 } @test_paths; +sub cmp_base { + $a =~ qr{/([^/]+)$}; + my $base1 = $1; + $b =~ qr{/([^/]+)$}; + my $base2 = $1; + return $base1 cmp $base2; +} + # Iterate over all Cheat Sheet JSON files... -foreach my $path (sort @test_paths) { +foreach my $path (sort { cmp_base } @test_paths) { my ($file_name) = $path =~ /$json_dir\/(.+)/; my ($name) = $path =~ /.+\/(.+)\.json$/; From eefe68af55d9da92c1f84c423ec186acd97d52ff Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Fri, 29 Apr 2016 14:58:59 +0100 Subject: [PATCH 36/91] Add tests for ignored phrases in aliases Emit a warning if the user defines an alias that contains an ignored phrase. --- t/CheatSheets/CheatSheetsJSON.t | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/t/CheatSheets/CheatSheetsJSON.t b/t/CheatSheets/CheatSheetsJSON.t index 144c30ec9..50c450976 100755 --- a/t/CheatSheets/CheatSheetsJSON.t +++ b/t/CheatSheets/CheatSheetsJSON.t @@ -57,6 +57,17 @@ sub check_aliases_for_triggers { return; } +sub check_aliases_for_ignore { + my ($aliases, $ignore) = @_; + my @ignore = @$ignore; + foreach my $alias (@$aliases) { + if (my $contained_ignore = first { $alias =~ $_ } @ignore) { + return ($alias, $contained_ignore); + } + } + return; +} + my @fnames = @ARGV ? map { "$_.json" } @ARGV : ("*.json"); my @test_paths = File::Find::Rule->file()->name(@fnames)->in($json_dir); @@ -147,6 +158,12 @@ foreach my $path (sort { cmp_base } @test_paths) { if (my ($alias, $trigger) = check_aliases_for_triggers(\@aliases, $trigger_types)) { push(@tests, {msg => "Alias ($alias) contains a trigger ($trigger) defined in the '$category' category", critical => $critical}); } + # Warn if they have aliases that contain ignored phrases. + if ($critical and my $ignored = $trigger_types->{ignore}) { + if (my ($alias, $ignore) = check_aliases_for_ignore(\@aliases, $ignored)) { + push (@tests, {msg => "Alias ($alias) contains a phrase ($ignore) that is ignored and may be omitted", critical => 0}); + } + } } # Make sure aliases don't contain any custom triggers for the cheat sheet. if (my $custom = $triggers_yaml->{custom_triggers}{$cheat_id}) { From a85b5352a61bd4b68e32961339ee70e41e2d5b7e Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Sat, 30 Apr 2016 11:28:46 +0100 Subject: [PATCH 37/91] Make ignore test critical --- t/CheatSheets/CheatSheetsJSON.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/CheatSheets/CheatSheetsJSON.t b/t/CheatSheets/CheatSheetsJSON.t index 50c450976..ff485327d 100755 --- a/t/CheatSheets/CheatSheetsJSON.t +++ b/t/CheatSheets/CheatSheetsJSON.t @@ -158,10 +158,10 @@ foreach my $path (sort { cmp_base } @test_paths) { if (my ($alias, $trigger) = check_aliases_for_triggers(\@aliases, $trigger_types)) { push(@tests, {msg => "Alias ($alias) contains a trigger ($trigger) defined in the '$category' category", critical => $critical}); } - # Warn if they have aliases that contain ignored phrases. + # Critical if they have aliases that contain ignored phrases. if ($critical and my $ignored = $trigger_types->{ignore}) { if (my ($alias, $ignore) = check_aliases_for_ignore(\@aliases, $ignored)) { - push (@tests, {msg => "Alias ($alias) contains a phrase ($ignore) that is ignored and may be omitted", critical => 0}); + push (@tests, {msg => "Alias ($alias) contains a phrase ($ignore) that is ignored and may be omitted", critical => 1}); } } } From dc299832d7995bea3cce3a7162265c94306e051b Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Sat, 30 Apr 2016 12:02:06 +0100 Subject: [PATCH 38/91] Ensure all invalid aliases are in test results Only the first alias was showing, we ensure that *all* aliases that fail the tests are shown. --- t/CheatSheets/CheatSheetsJSON.t | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/t/CheatSheets/CheatSheetsJSON.t b/t/CheatSheets/CheatSheetsJSON.t index ff485327d..ecb3e3b44 100755 --- a/t/CheatSheets/CheatSheetsJSON.t +++ b/t/CheatSheets/CheatSheetsJSON.t @@ -40,6 +40,7 @@ sub id_to_file_name { sub check_aliases_for_triggers { my ($aliases, $trigger_types) = @_; my @aliases = @$aliases; + my %bad_aliases; while (my ($trigger_type, $triggers) = each %{$trigger_types}) { my @triggers = @$triggers; foreach my $alias (@aliases) { @@ -50,22 +51,23 @@ sub check_aliases_for_triggers { || ($trigger_type =~ /end$/ && ($trigger = first { $alias =~ /$_$/ } @triggers)) ) { - return ($alias, $trigger); + $bad_aliases{$alias} = $trigger; } } } - return; + return %bad_aliases; } sub check_aliases_for_ignore { my ($aliases, $ignore) = @_; my @ignore = @$ignore; + my %bad_aliases; foreach my $alias (@$aliases) { if (my $contained_ignore = first { $alias =~ $_ } @ignore) { - return ($alias, $contained_ignore); + $bad_aliases{$alias} = $ignore; } } - return; + return %bad_aliases; } my @fnames = @ARGV ? map { "$_.json" } @ARGV : ("*.json"); @@ -155,19 +157,22 @@ foreach my $path (sort { cmp_base } @test_paths) { # Make sure aliases don't contain any category triggers. while (my ($category, $trigger_types) = each %{$triggers_yaml->{categories}}) { my $critical = $categories{$category}; - if (my ($alias, $trigger) = check_aliases_for_triggers(\@aliases, $trigger_types)) { + my %bad_aliases = check_aliases_for_triggers(\@aliases, $trigger_types); + while (my ($alias, $trigger) = each %bad_aliases) { push(@tests, {msg => "Alias ($alias) contains a trigger ($trigger) defined in the '$category' category", critical => $critical}); } # Critical if they have aliases that contain ignored phrases. if ($critical and my $ignored = $trigger_types->{ignore}) { - if (my ($alias, $ignore) = check_aliases_for_ignore(\@aliases, $ignored)) { + my %bad_aliases = check_aliases_for_ignore(\@aliases, $ignored); + while (my ($alias, $ignore) = each %bad_aliases) { push (@tests, {msg => "Alias ($alias) contains a phrase ($ignore) that is ignored and may be omitted", critical => 1}); } } } # Make sure aliases don't contain any custom triggers for the cheat sheet. if (my $custom = $triggers_yaml->{custom_triggers}{$cheat_id}) { - if (my ($alias, $trigger) = check_aliases_for_triggers(\@aliases, $custom)) { + my %bad_aliases = check_aliases_for_triggers(\@aliases, $custom); + while (my ($alias, $trigger) = each %bad_aliases) { push(@tests, {msg => "Alias ($alias) contains a custom trigger ($trigger)", critical => 1}); } } From 31d94115cb113569ebc188b65448b3d8173bf2f6 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 19:41:23 +0100 Subject: [PATCH 39/91] Conversions: Fixing some unit mistakes --- share/goodie/conversions/ratios.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/share/goodie/conversions/ratios.yml b/share/goodie/conversions/ratios.yml index b5678cd15..ab389584f 100755 --- a/share/goodie/conversions/ratios.yml +++ b/share/goodie/conversions/ratios.yml @@ -4,7 +4,7 @@ aliases: - t - mt - te - - metric tons + - metric tonnes - tonnes - ts - mts @@ -12,7 +12,7 @@ aliases: factor: 1 type: mass unit: metric ton -plural: metric tonnes +plural: metric tons --- aliases: - oz @@ -128,8 +128,8 @@ aliases: - avoirdupois dram factor: 564383.3912 type: mass -unit: avoirdupois dram -plural: avoirdupois drams +unit: dram avoirdupois +plural: drams avoirdupois --- aliases: - metre @@ -827,7 +827,7 @@ aliases: [] factor: 0.00750062 type: pressure unit: torr -plural: torrs +plural: torr --- aliases: - j From abad3d0d1fad062f8848ec29be3e237f9c2c814a Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 19:55:59 +0100 Subject: [PATCH 40/91] Conversions: The previous code assumed that everything was lowercase; I've injected lc all over the place to make the tests pass --- lib/DDG/Goodie/Conversions.pm | 39 ++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index 4005b207b..c5d460c28 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -9,6 +9,7 @@ use Math::Round qw/nearest/; use utf8; use YAML::XS 'LoadFile'; use List::Util qw(any); +use Data::Dump qw(dump); zci answer_type => 'conversions'; zci is_cached => 1; @@ -17,11 +18,14 @@ use bignum; my @types = LoadFile(share('ratios.yml')); +my %plurals = (); + my @units = (); foreach my $type (@types) { push(@units, $type->{'unit'}); push(@units, $type->{'plural'}) unless $type->{'unit'} eq $type->{'plural'}; push(@units, @{$type->{'aliases'}}); + $plurals{lc $type->{'unit'}} = lc $type->{'plural'}; } # build triggers based on available conversion units: @@ -155,8 +159,8 @@ handle query_lc => sub { $result->{'from_unit'} = ($factor == 1 ? "degree" : "degrees") . " $result->{'from_unit'}" if ($result->{'from_unit'} ne "kelvin"); $result->{'to_unit'} = ($result->{'result'} == 1 ? "degree" : "degrees") . " $result->{'to_unit'}" if ($result->{'to_unit'} ne "kelvin"); } else { - $result->{'from_unit'} = set_unit_pluralisation($result, $factor); - $result->{'to_unit'} = set_unit_pluralisation($result, $result->{'result'}); + $result->{'from_unit'} = set_unit_pluralisation($result->{'from_unit'}, $factor); + $result->{'to_unit'} = set_unit_pluralisation($result->{'to_unit'}, $result->{'result'}); } #warn($result->{'from_unit'}. " | ". $result->{'to_unit'}); @@ -193,9 +197,12 @@ handle query_lc => sub { sub looks_plural { my ($unit) = @_; -# my @unit_letters = split //, $unit; -# return exists $singular_exceptions{$unit} || $unit_letters[-1] eq 's'; - return any {$_ eq $unit} @units; + + my $is_plural = 0; + foreach my $x (keys(%plurals)) { + $is_plural = 1 if lc $plurals{$x} eq lc $unit; + } + return $is_plural; } sub convert_temperatures { @@ -223,11 +230,10 @@ sub convert_temperatures { } sub get_matches { my @input_matches = @_; - my @output_matches = (); foreach my $match (@input_matches) { foreach my $type (@types) { - if (lc $match eq $type->{'unit'} || lc $match eq $type->{'plural'} || grep { $_ eq lc $match } @{$type->{'aliases'}}) { + if (lc $match eq $type->{'unit'} || lc $match eq lc $type->{'plural'} || grep { $_ eq lc $match } @{$type->{'aliases'}}) { push(@output_matches,{ type => $type->{'type'}, factor => $type->{'factor'}, @@ -243,8 +249,9 @@ sub get_matches { } sub convert { my ($conversion) = @_; - my @matches = get_matches($conversion->{'from_unit'}, $conversion->{'to_unit'}); + my @matches = get_matches($conversion->{'from_unit'}, $conversion->{'to_unit'}); + return if $conversion->{'factor'} < 0 && !($matches[0]->{'can_be_negative'}); # matches must be of the same type (e.g., can't convert mass to length): @@ -266,12 +273,20 @@ sub convert { "type" => $matches[0]->{'type'} }; } + sub set_unit_pluralisation { my ($unit, $count) = @_; - use Data::Dump qw(dump); - warn ($count, dump($unit)); - return $unit->{'unit'} unless($count == 1); - return $unit->{'plural'}; + my $proper_unit = $unit; + + my $already_plural = looks_plural($unit); + + if ($already_plural && $count == 1) { + $proper_unit = $unit; + } elsif (!$already_plural && $count != 1) { + $proper_unit = $plurals{lc $unit}; + } + + return $proper_unit; } 1; From e684a14a5f1912e9518bb91a120d5d71eae2dd42 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:03:19 +0100 Subject: [PATCH 41/91] Conversions: TNT will always be returned as tnt now --- t/Conversions.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/Conversions.t b/t/Conversions.t index 7fbbe3a15..89054f3b8 100755 --- a/t/Conversions.t +++ b/t/Conversions.t @@ -588,14 +588,14 @@ ddg_goodie_test( }) ), '2500kcal in tons of tnt' => test_zci( - '2,500 large calories = 0.003 tons of TNT', + '2,500 large calories = 0.003 tons of tnt', structured_answer => make_answer({ markup_input => '2,500', raw_input => '2500', from_unit => 'large calories', styled_output => '0.003', raw_answer => '0.003', - to_unit => 'tons of TNT', + to_unit => 'tons of tnt', physical_quantity => 'energy' }) ), From a76e193f8d6b6108effc1536bd5baa8128fdc76e Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:09:58 +0100 Subject: [PATCH 42/91] Conversions: I think the query how many cm in metres should return the answer "1 meter = 100cm" --- t/Conversions.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/Conversions.t b/t/Conversions.t index 89054f3b8..6176074de 100755 --- a/t/Conversions.t +++ b/t/Conversions.t @@ -1431,14 +1431,14 @@ ddg_goodie_test( }) ), 'how many cm in metres?' => test_zci( - '1 centimeter = 0.010 meters', + '1 meter = 100 centimeters', structured_answer => make_answer({ markup_input => '1', raw_input => '1', - from_unit => 'centimeter', - styled_output => '0.010', - raw_answer => '0.010', - to_unit => 'meters', + from_unit => 'meter', + styled_output => '100', + raw_answer => '100', + to_unit => 'centimeters', physical_quantity => 'length' }) ), From 3085cef17ab5b5dbbd62b470d85d5833b4f10624 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:11:38 +0100 Subject: [PATCH 43/91] Conversions: Again I think the intent behind the query `ml in gallons` is "how many ml are there in a gallon?" --- t/Conversions.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/Conversions.t b/t/Conversions.t index 6176074de..1bee674b4 100755 --- a/t/Conversions.t +++ b/t/Conversions.t @@ -984,14 +984,14 @@ ddg_goodie_test( }) ), 'ml in gallons' => test_zci( - '1 millilitre = 0.000264 us gallons', + '1 us gallon = 3,785.412 millilitres',, structured_answer => make_answer({ markup_input => '1', raw_input => '1', - from_unit => 'millilitre', - styled_output => '0.000264', - raw_answer => '0.000264', - to_unit => 'us gallons', + from_unit => 'us gallon', + styled_output => '3,785.412', + raw_answer => '3785.412', + to_unit => 'millilitres', physical_quantity => 'volume' }) ), From ac079dcae0576608911871a17368480f24ba775b Mon Sep 17 00:00:00 2001 From: Sebastian Nemak Date: Mon, 9 May 2016 21:16:09 +0200 Subject: [PATCH 44/91] Update section pools and datasets --- share/goodie/cheat_sheets/json/zfs.json | 94 +++++++++++++++++++++---- 1 file changed, 81 insertions(+), 13 deletions(-) diff --git a/share/goodie/cheat_sheets/json/zfs.json b/share/goodie/cheat_sheets/json/zfs.json index 0058eda38..22758e12f 100644 --- a/share/goodie/cheat_sheets/json/zfs.json +++ b/share/goodie/cheat_sheets/json/zfs.json @@ -1,7 +1,7 @@ { "id": "zfs_cheat_sheet", "name": "ZFS", - "description": "The combined file system and logical volume manager", + "description": "The combined file system and logical volume manager.", "metadata": { "sourceName": "FreeBSD handbook - The Z File System (ZFS)", "sourceUrl": "https://www.freebsd.org/doc/handbook/zfs.html" @@ -12,32 +12,100 @@ ], "template_type": "terminal", "section_order": [ - "zPools", - "zDatasets" + "Pools", + "Datasets" ], "sections": { - "zPools": [ + "Pools": [ { "key": "zpool list", - "val": "List pools." + "val": "Lists the given pools." }, { - "key": "zpool status", - "val": "Check disk status." + "key": "zpool status \\[$POOLNAME\\]", + "val": "Displays the detailed health status." + }, + { + "key": "zpool get all $POOLNAME", + "val": "Retrieves the all properties for the pool." + }, + { + "key": "zpool set $PROPERTY=$VALUE $POOLNAME", + "val": "Sets the given property on the pool." + }, + { + "key": "zpool create \\[$POOLTYPE\\] $POOLNAME $DEVICE1", + "val": "Create a pool (Pool types: _ | spare | mirror | raidz)." + }, + { + "key": "zpool replace $POOLNAME $DEV_OLD \\[$DEV_NEW\\]", + "val": "Replaces the old device with new one." + }, + { + "key": "zpool destroy $POOLNAME", + "val": "Destroys the given pool." + }, + { + "key": "zpool remove $POOLNAME $DEVICE", + "val": "Remove a physical device from the pool." + }, + { + "key": "zpool online $POOLNAME $DEVICE", + "val": "Device is online and functioning." + }, + { + "key": "zpool offline $POOLNAME $DEVICE", + "val": "Take device explicitly offline." + }, + { + "key": "zpool scrub $POOLNAME", + "val": "Begin to examines all data in the pool to verify that checksums are correctly." + }, + { + "key": "zpool \\[attach|detach\\] $POOLNAME $DEVICE", + "val": "Attach or Detaches device from a pool." + }, + { + "key": "zpool iostat \\[$POOLNAME\\]", + "val": "Displays I/O statistics for the given pool." } ], - "zDatasets": [ + "Datasets": [ { "key": "zfs list", - "val": "List datasets and pools." + "val": "Lists the properties for the given datasets." }, { - "key": "zfs snaphot -r $POOL/$DATASET@$SNAPSHOTNAME", - "val": "Takes a recursiv snaphot of dataset." + "key": "zfs list -t snapshot /\\[$DATASET\\]", + "val": "Display a list of snapshots from /[] directory." }, { - "key": "zfs list -t snapshot /", - "val": "Display a list of snapshots." + "key": "zfs snaphot \\[-r\\] $POOLNAME/$DATASET@$SNAPSHOTNAME", + "val": "Takes a [recursiv] snaphot of dataset." + }, + { + "key": "zfs set $OPTION=$VALUE $POOLNAME/$DATASET", + "val": "Set the property to the given value for a dataset." + }, + { + "key": "zfs clone $POOLNAME/$DATASET@$SNAPSHOTNAME $POOLNAME/$CLONE", + "val": "Creates a clone of the given snapshot." + }, + { + "key": "zfs rollback \\[-rR\\] $POOLNAME/$DATASET@$SNAPSHOTNAME", + "val": "Roll back the given dataset to a previous snapshot." + }, + { + "key": "zfs destroy $POOLNAME/$DATASET@$SNAPSHOTNAME", + "val": "Destroys the given dataset." + }, + { + "key": "zfs mount $POOLNAME", + "val": "Mounts of the ZFS file systems." + }, + { + "key": "zfs umount $POOLNAME\\[/$MOUNTPOINT\\]", + "val": "Unmounts currently mounted ZFS file systems." } ] } From ed3c5560b3b76e4d0f3af2348ee56f1e3b4877c6 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:17:32 +0100 Subject: [PATCH 45/91] Conversions: All tests now passing --- lib/DDG/Goodie/Conversions.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index c5d460c28..2bd25b733 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -112,8 +112,7 @@ handle query_lc => sub { && "" eq $+{'right_num'} && $+{'question'} !~ qr/convert/i && !looks_plural($+{'right_unit'}) - && $+{'connecting_word'} !~ qr/to/i - && $factor1[0] > $factor2[0])) + && $+{'connecting_word'} !~ qr/to/i )) { $factor = $+{'right_num'}; @matches = ($matches[1], $matches[0]); @@ -202,6 +201,7 @@ sub looks_plural { foreach my $x (keys(%plurals)) { $is_plural = 1 if lc $plurals{$x} eq lc $unit; } + return $is_plural; } From aedcc1d5603dbcf8f761ea714891a3f54fa62637 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:18:21 +0100 Subject: [PATCH 46/91] Conversions: Better off without the JSON formatted version for now --- share/goodie/conversions/ratios.json | 1202 -------------------------- 1 file changed, 1202 deletions(-) delete mode 100755 share/goodie/conversions/ratios.json diff --git a/share/goodie/conversions/ratios.json b/share/goodie/conversions/ratios.json deleted file mode 100755 index 7a470c6bb..000000000 --- a/share/goodie/conversions/ratios.json +++ /dev/null @@ -1,1202 +0,0 @@ -{ - "thousandth of an inch" : { - "factor" : "39370.1", - "unit" : "thousandth of an inch", - "type" : "length", - "aliases" : ["thou", "thous", "mil", "mils", "thousandth of an inch"], - "plural" : "thousandths of an inch" - }, - "terabit" : { - "factor" : "1e-12", - "unit" : "terabit", - "type" : "digital", - "plural" : "terabits", - "aliases" : ["tbit", "tbits"] - }, - "pebibit" : { - "factor" : "8.88178419700125e-16", - "unit" : "pebibit", - "type" : "digital", - "plural" : "pebibits", - "aliases" : ["pibit", "pibits"] - }, - "exbibyte" : { - "plural" : "exbibytes", - "aliases" : ["eib", "eibs"], - "type" : "digital", - "unit" : "exbibyte", - "factor" : "1.0842021724855e-19" - }, - "us teaspoon" : { - "factor" : "202.88413621", - "unit" : "us teaspoon", - "type" : "volume", - "aliases" : ["us tsp", "us tsp.", "teaspoons", "teaspoon", "tsp", "tsp."], - "plural" : "us teaspoons" - }, - "astronomical unit" : { - "factor" : "6.68458712226845e-12", - "unit" : "astronomical unit", - "type" : "length", - "plural" : "astronomical units", - "aliases" : ["au", "aus"] - }, - "bar" : { - "unit" : "bar", - "factor" : "1e-05", - "plural" : "bars", - "aliases" : ["pa", "pas"], - "type" : "pressure" - }, - "pound force" : { - "factor" : "0.224808943099711", - "unit" : "pound force", - "type" : "force", - "plural" : "pounds force", - "aliases" : ["lbs force", "lb force"] - }, - "gigabit" : { - "type" : "digital", - "aliases" : ["gbit", "gbits"], - "plural" : "gigabits", - "factor" : "1e-09", - "unit" : "gigabit" - }, - "imperial gallon" : { - "type" : "volume", - "aliases" : ["uk gallon", "british gallon", "british gallons", "uk gallons", "gb gallons", "gb gallon"], - "plural" : "imperial gallons", - "factor" : "0.219969248299088", - "unit" : "imperial gallon" - }, - "centimeter" : { - "aliases" : ["centimetre", "centimetres", "cm", "cms"], - "plural" : "centimeters", - "type" : "length", - "unit" : "centimeter", - "factor" : "100" - }, - "ton of TNT" : { - "aliases" : ["tnt equivilent", "tonnes of tnt", "tnt"], - "plural" : "tons of TNT", - "type" : "energy", - "unit" : "ton of TNT", - "factor" : "2.39005736137667e-10" - }, - "us tablespoon" : { - "aliases" : ["us tbsp", "us tbsp.", "tablespoons", "tablespoon", "tbsp", "tbsp."], - "plural" : "us tablespoons", - "type" : "volume", - "unit" : "us tablespoon", - "factor" : "67.6280454" - }, - "exabit" : { - "type" : "digital", - "aliases" : ["ebit", "ebits"], - "plural" : "exabits", - "factor" : "1e-18", - "unit" : "exabit" - }, - "atmosphere" : { - "type" : "pressure", - "plural" : "atmospheres", - "aliases" : ["atm", "atms"], - "factor" : "9.86923266716013e-06", - "unit" : "atmosphere" - }, - "zebibyte" : { - "plural" : "zebibytes", - "aliases" : ["zib", "zibs"], - "type" : "digital", - "unit" : "zebibyte", - "factor" : "1.05879118406788e-22" - }, - "tebibyte" : { - "unit" : "tebibyte", - "factor" : "1.13686837721616e-13", - "aliases" : ["tib", "tibs"], - "plural" : "tebibytes", - "type" : "digital" - }, - "link" : { - "factor" : "4.97096953789867", - "unit" : "link", - "type" : "length", - "plural" : "links", - "aliases" : ["gunter's links"] - }, - "carat" : { - "unit" : "carat", - "factor" : "5000000", - "aliases" : ["carat"], - "plural" : "carats", - "type" : "mass" - }, - "watt-second" : { - "factor" : "1", - "unit" : "watt-second", - "type" : "energy", - "aliases" : ["watt second", "watt seconds", "ws"], - "plural" : "watt-seconds" - }, - "millisecond" : { - "plural" : "milliseconds", - "aliases" : ["millisec", "millisecs", "ms"], - "type" : "duration", - "unit" : "millisecond", - "factor" : "86400000" - }, - "exabyte" : { - "factor" : "1.25e-19", - "unit" : "exabyte", - "type" : "digital", - "aliases" : ["eb", "ebs"], - "plural" : "exabytes" - }, - "kilopascal" : { - "unit" : "kilopascal", - "factor" : "0.001", - "aliases" : ["kpa", "kpas"], - "plural" : "kilopascals", - "type" : "pressure" - }, - "metric horsepower" : { - "factor" : "0.0013596216173039", - "unit" : "metric horsepower", - "type" : "power", - "plural" : "metric horsepower", - "aliases" : ["metric horsepowers", "mhp", "hp", "ps", "cv", "hk", "ks", "ch"] - }, - "cubic metre" : { - "plural" : "cubic metres", - "aliases" : ["metre^3", "meter^3", "metres^3", "meters^3", "m^3", "m³"], - "type" : "volume", - "unit" : "cubic metre", - "factor" : "0.001" - }, - "gibibyte" : { - "factor" : "1.16415321826935e-10", - "unit" : "gibibyte", - "type" : "digital", - "aliases" : ["gib", "gibs"], - "plural" : "gibibytes" - }, - "radian" : { - "type" : "angle", - "aliases" : ["rad", "rads"], - "plural" : "radians", - "factor" : "0.0174532925199433", - "unit" : "radian" - }, - "torr" : { - "unit" : "torr", - "factor" : "0.00750062", - "plural" : "torrs", - "aliases" : [], - "type" : "pressure" - }, - "gigapascal" : { - "factor" : "1e-09", - "unit" : "gigapascal", - "type" : "pressure", - "aliases" : ["gpa", "gpas"], - "plural" : "gigapascals" - }, - "imperial fluid ounce" : { - "aliases" : ["imperial fl oz", "imperial fluid oz"], - "plural" : "imperial fluid ounces", - "type" : "volume", - "unit" : "imperial fluid ounce", - "factor" : "28.1560637822832" - }, - "metric ton" : { - "factor" : "1", - "unit" : "metric ton", - "type" : "mass", - "aliases" : ["tonne", "t", "mt", "te", "metric tons", "tonnes", "ts", "mts", "tes"], - "plural" : "metric tonnes" - }, - "cable" : { - "aliases" : [], - "plural" : "cables", - "type" : "length", - "unit" : "cable", - "factor" : "0.00539611824837685" - }, - "petabit" : { - "unit" : "petabit", - "factor" : "1e-15", - "aliases" : ["pbit", "pbits"], - "plural" : "petabits", - "type" : "digital" - }, - "leap year" : { - "type" : "duration", - "plural" : "leap years", - "aliases" : ["leapyear", "leapyr", "leapyrs"], - "factor" : "0.00273224043715847", - "unit" : "leap year" - }, - "tebibit" : { - "plural" : "tebibits", - "aliases" : ["tibit", "tibits"], - "type" : "digital", - "unit" : "tebibit", - "factor" : "9.09494701772928e-13" - }, - "metric tablespoon" : { - "factor" : "66.6666666", - "unit" : "metric tablespoon", - "type" : "volume", - "aliases" : ["metric tbsp", "metric tbsp."], - "plural" : "metric tablespoons" - }, - "horsepower" : { - "type" : "power", - "plural" : "horsepower", - "aliases" : ["mechanical horsepower", "horsepower", "hp", "hp", "bhp"], - "factor" : "0.00134102208959503", - "unit" : "horsepower" - }, - "dry pint" : { - "factor" : "1.81616596853771", - "unit" : "dry pint", - "type" : "volume", - "aliases" : ["pints dry"], - "plural" : "dry pints" - }, - "pebibyte" : { - "plural" : "pebibytes", - "aliases" : ["pib", "pibs"], - "type" : "digital", - "unit" : "pebibyte", - "factor" : "1.11022302462516e-16" - }, - "liquid pint" : { - "plural" : "liquid pints", - "aliases" : ["us pints", "us liquid pint", "us liquid pints"], - "type" : "volume", - "unit" : "liquid pint", - "factor" : "2.11337641886519" - }, - "revolution" : { - "unit" : "revolution", - "factor" : "0.00277777777777778", - "aliases" : ["circle", "circles", "revs"], - "plural" : "revolutions", - "type" : "angle" - }, - "kilogram" : { - "unit" : "kilogram", - "factor" : "1000", - "plural" : "kilograms", - "aliases" : ["kg", "kilo", "kilogramme", "kgs", "kilos", "kilogrammes"], - "type" : "mass" - }, - "kilowatt" : { - "factor" : "0.001", - "unit" : "kilowatt", - "type" : "power", - "plural" : "kilowatts", - "aliases" : ["kw"] - }, - "megabyte" : { - "plural" : "megabytes", - "aliases" : ["mb", "mbs"], - "type" : "digital", - "unit" : "megabyte", - "factor" : "1.25e-07" - }, - "us cup" : { - "factor" : "4.2267528", - "unit" : "us cup", - "type" : "volume", - "aliases" : ["cups", "cup"], - "plural" : "us cups" - }, - "nanowatt" : { - "unit" : "nanowatt", - "factor" : "1000000000", - "aliases" : ["nw"], - "plural" : "nanowatts", - "type" : "power" - }, - "ft/s" : { - "unit" : "ft/s", - "factor" : "3.280839895013123", - "aliases" : ["feet per second", "foot per second", "feet/sec", "feet/second", "foot/sec", "foot/second", "fps", "ft/sec", "ft/second"], - "plural" : "ft/s", - "type" : "speed" - }, - "ounce" : { - "unit" : "ounce", - "factor" : "35274", - "plural" : "ounces", - "aliases" : ["oz", "ozs"], - "type" : "mass" - }, - "cubic millimeter" : { - "unit" : "cubic millimeter", - "factor" : "1000000", - "aliases" : ["cubic millimetre", "cubic millimetres", "millimetre^3", "millimeter^3", "millimetres^3", "millimeters^3", "mm^3", "mm³"], - "plural" : "cubic millimeters", - "type" : "volume" - }, - "day" : { - "aliases" : ["days", "dy", "dys", "d"], - "plural" : "days", - "type" : "duration", - "unit" : "day", - "factor" : "1" - }, - "gigawatt" : { - "unit" : "gigawatt", - "factor" : "1e-09", - "aliases" : ["jiggawatts", "gw"], - "plural" : "gigawatts", - "type" : "power" - }, - "minute" : { - "plural" : "minutes", - "aliases" : ["min", "mins"], - "type" : "duration", - "unit" : "minute", - "factor" : "1440" - }, - "dyne" : { - "factor" : "1e-05", - "unit" : "dyne", - "type" : "force", - "aliases" : [], - "plural" : "dynes" - }, - "yobibit" : { - "plural" : "yobibits", - "aliases" : ["yibit", "yibits"], - "type" : "digital", - "unit" : "yobibit", - "factor" : "8.27180612553028e-25" - }, - "light year" : { - "factor" : "1.05700083402462e-16", - "unit" : "light year", - "type" : "length", - "plural" : "light years", - "aliases" : ["ly", "lys"] - }, - "microwatt" : { - "plural" : "microwatts", - "aliases" : ["μwatts"], - "type" : "power", - "unit" : "microwatt", - "factor" : "1000000" - }, - "square yard" : { - "type" : "area", - "plural" : "square yards", - "aliases" : ["yard^2", "yard²", "yards²", "yards^2", "yd^2", "yd²", "yrd^2", "yrd²"], - "factor" : "11959.9", - "unit" : "square yard" - }, - "rod" : { - "plural" : "rods", - "aliases" : ["rd"], - "type" : "length", - "unit" : "rod", - "factor" : "0.198838781515947" - }, - "square kilometer" : { - "aliases" : ["square kilometre", "square kilometres", "km^2", "km²"], - "plural" : "square kilometers", - "type" : "area", - "unit" : "square kilometer", - "factor" : "0.01" - }, - "semi-circle" : { - "plural" : "semi-circles", - "aliases" : ["semi circle", "semicircle", "semi circles", "semicircles"], - "type" : "angle", - "unit" : "semi-circle", - "factor" : "0.00555555555555556" - }, - "megapascal" : { - "plural" : "megapascals", - "aliases" : ["megapa", "megapas"], - "type" : "pressure", - "unit" : "megapascal", - "factor" : "1e-06" - }, - "mebibit" : { - "unit" : "mebibit", - "factor" : "9.5367431640625e-07", - "plural" : "mebibits", - "aliases" : ["mibit", "mibits"], - "type" : "digital" - }, - "foot" : { - "type" : "length", - "aliases" : ["ft", "international foot", "international feet", "survey foot", "survey feet"], - "plural" : "feet", - "factor" : "3.2808398950131233595800524934383", - "unit" : "foot" - }, - "zettabyte" : { - "plural" : "zettabytes", - "aliases" : ["zb", "zbs"], - "type" : "digital", - "unit" : "zettabyte", - "factor" : "1.25e-22" - }, - "mmHg" : { - "aliases" : ["mmhg"], - "plural" : "mmHg", - "type" : "pressure", - "unit" : "mmHg", - "factor" : "0.00750061683" - }, - "watt" : { - "aliases" : ["w"], - "plural" : "watts", - "type" : "power", - "unit" : "watt", - "factor" : "1" - }, - "league" : { - "type" : "length", - "plural" : "leagues", - "aliases" : [], - "factor" : "0.000207123730745778", - "unit" : "league" - }, - "fahrenheit" : { - "unit" : "fahrenheit", - "factor" : "1", - "aliases" : ["f", "°f"], - "plural" : "fahrenheit", - "can_be_negative" : "1", - "type" : "temperature" - }, - "exbibit" : { - "factor" : "8.67361737988404e-19", - "unit" : "exbibit", - "type" : "digital", - "aliases" : ["eibit", "eibits"], - "plural" : "exbibits" - }, - "meter" : { - "factor" : "1", - "unit" : "meter", - "type" : "length", - "plural" : "meters", - "aliases" : ["metre", "metres", "m"] - }, - "parsec" : { - "unit" : "parsec", - "factor" : "3.24077923047971e-17", - "aliases" : ["pc", "pcs"], - "plural" : "parsecs", - "type" : "length" - }, - "yobibyte" : { - "factor" : "1.03397576569129e-25", - "unit" : "yobibyte", - "type" : "digital", - "plural" : "yobibytes", - "aliases" : ["yib", "yibs"] - }, - "yottabit" : { - "factor" : "1e-24", - "unit" : "yottabit", - "type" : "digital", - "aliases" : ["ybit", "ybits"], - "plural" : "yottabits" - }, - "pascal" : { - "type" : "pressure", - "aliases" : ["pa", "pas"], - "plural" : "pascals", - "factor" : "1", - "unit" : "pascal" - }, - "kilometer" : { - "plural" : "kilometers", - "aliases" : ["kilometre", "kilometres", "km", "kms", "klick", "klicks"], - "type" : "length", - "unit" : "kilometer", - "factor" : "0.001" - }, - "square meter" : { - "factor" : "10000", - "unit" : "square meter", - "type" : "area", - "aliases" : ["metre^2", "meter^2", "metres^2", "meters^2", "square metre", "square metres", "m^2", "m²"], - "plural" : "square meters" - }, - "picowatt" : { - "type" : "power", - "aliases" : ["pw"], - "plural" : "picowatts", - "factor" : "1000000000000", - "unit" : "picowatt" - }, - "kibibyte" : { - "type" : "digital", - "aliases" : ["kib", "kibs"], - "plural" : "kibibytes", - "factor" : "0.0001220703125", - "unit" : "kibibyte" - }, - "quart" : { - "factor" : "1.05668820943259", - "unit" : "quart", - "type" : "volume", - "aliases" : ["liquid quart", "us quart", "us quarts", "liquid quarts"], - "plural" : "quarts" - }, - "metric dessert spoon" : { - "type" : "volume", - "aliases" : ["dessert spoons", "dessert spoon", "dstspn", "dstspn."], - "plural" : "metric dessert spoons", - "factor" : "100", - "unit" : "metric dessert spoon" - }, - "square foot" : { - "type" : "area", - "aliases" : ["feet^2", "feet²", "foot^2", "foot²", "ft²", "ft^2"], - "plural" : "square feet", - "factor" : "107639.1", - "unit" : "square foot" - }, - "petabyte" : { - "type" : "digital", - "plural" : "petabytes", - "aliases" : ["pb", "pbs"], - "factor" : "1.25e-16", - "unit" : "petabyte" - }, - "nanosecond" : { - "plural" : "nanoseconds", - "aliases" : ["nanosec", "nanosecs", "ns"], - "type" : "duration", - "unit" : "nanosecond", - "factor" : "86400000000000" - }, - "mile" : { - "type" : "length", - "aliases" : ["mi", "statute mile", "statute miles", "land mile", "land miles"], - "plural" : "miles", - "factor" : "0.000621371192237334", - "unit" : "mile" - }, - "hectare" : { - "plural" : "hectares", - "aliases" : ["ha"], - "type" : "area", - "unit" : "hectare", - "factor" : "1" - }, - "yottabyte" : { - "type" : "digital", - "aliases" : ["yb", "ybs"], - "plural" : "yottabytes", - "factor" : "1.25e-25", - "unit" : "yottabyte" - }, - "square centimeter" : { - "type" : "area", - "aliases" : ["square centimetre", "square centimetres", "cm^2", "cm²"], - "plural" : "square centimeters", - "factor" : "100000000", - "unit" : "square centimeter" - }, - "reaumur" : { - "type" : "temperature", - "aliases" : ["re"], - "plural" : "reamur", - "can_be_negative" : "1", - "factor" : "1", - "unit" : "reaumur" - }, - "cubic centimeter" : { - "factor" : "1000", - "unit" : "cubic centimeter", - "type" : "volume", - "plural" : "cubic centimeters", - "aliases" : ["centimetre^3", "centimeter^3", "centimetres^3", "centimeters^3", "cm^3", "cm³", "cc", "ccm"] - }, - "furlong" : { - "unit" : "furlong", - "factor" : "0.00497096953789867", - "plural" : "furlongs", - "aliases" : ["furlng"], - "type" : "length" - }, - "knot" : { - "factor" : "1.943844492440605", - "unit" : "knot", - "type" : "speed", - "aliases" : ["kt", "nmi/h"], - "plural" : "knots" - }, - "british thermal unit" : { - "type" : "energy", - "plural" : "british thermal units", - "aliases" : ["btu", "btus"], - "factor" : "0.000948316737790422", - "unit" : "british thermal unit" - }, - "pound per square inch" : { - "unit" : "pound per square inch", - "factor" : "0.000145036839357197", - "aliases" : ["psis", "psi", "lbs/inch^2", "p.s.i.", "p.s.i"], - "plural" : "pounds per square inch", - "type" : "pressure" - }, - "kilodyne" : { - "unit" : "kilodyne", - "factor" : "0.01", - "aliases" : [], - "plural" : "kildynes", - "type" : "force" - }, - "thermochemical gram calorie" : { - "type" : "energy", - "aliases" : ["small calories", "chemical calorie", "chemical calories"], - "plural" : "thermochemical gran calories", - "factor" : "0.239005736137667", - "unit" : "thermochemical gram calorie" - }, - "bit" : { - "plural" : "bits", - "aliases" : [], - "type" : "digital", - "unit" : "bit", - "factor" : "1" - }, - "millimeter" : { - "unit" : "millimeter", - "factor" : "1000", - "plural" : "millimeters", - "aliases" : ["millimetre", "millimetres", "mm", "mms"], - "type" : "length" - }, - "kelvin" : { - "unit" : "kelvin", - "factor" : "1", - "aliases" : ["k"], - "plural" : "kelvin", - "type" : "temperature" - }, - "month" : { - "factor" : "0.0328767123287671", - "unit" : "month", - "type" : "duration", - "aliases" : ["mons", "mns", "mn"], - "plural" : "months" - }, - "imperial pint" : { - "type" : "volume", - "aliases" : ["pints", "pint", "uk pint", "british pint", "pts"], - "plural" : "imperial pints", - "factor" : "1.7597539863927", - "unit" : "imperial pint" - }, - "millilitre" : { - "aliases" : ["milliliter", "milliliters", "ml"], - "plural" : "millilitres", - "type" : "volume", - "unit" : "millilitre", - "factor" : "1000" - }, - "watt-hour" : { - "plural" : "watt-hours", - "aliases" : ["watt hour", "watt hours", "wh"], - "type" : "energy", - "unit" : "watt-hour", - "factor" : "0.000277777777777778" - }, - "petawatt" : { - "type" : "power", - "plural" : "petawatts", - "aliases" : ["pw"], - "factor" : "1e-15", - "unit" : "petawatt" - }, - "grain" : { - "plural" : "grains", - "aliases" : ["grain", "gr", "troy grain", "troy grains"], - "type" : "mass", - "unit" : "grain", - "factor" : "15432358.3529414" - }, - "square mile" : { - "factor" : "0.00386102160083284", - "unit" : "square mile", - "type" : "area", - "plural" : "square miles", - "aliases" : ["sq mi", "square statute mile", "square statute miles", "square land mile", "square land miles", "miles^2", "miles²"] - }, - "long ton" : { - "type" : "mass", - "aliases" : ["weight ton", "imperial ton", "long tons", "weight tons", "imperial tons"], - "plural" : "long tons", - "factor" : "0.984207", - "unit" : "long ton" - }, - "newton" : { - "factor" : "1", - "unit" : "newton", - "type" : "force", - "plural" : "newtons", - "aliases" : ["n"] - }, - "year" : { - "unit" : "year", - "factor" : "0.00273972602739726", - "aliases" : ["yr", "yrs"], - "plural" : "years", - "type" : "duration" - }, - "litre" : { - "factor" : "1", - "unit" : "litre", - "type" : "volume", - "plural" : "litres", - "aliases" : ["liter", "liters", "l", "litter", "litters"] - }, - "kilobyte" : { - "type" : "digital", - "aliases" : ["kb", "kbs"], - "plural" : "kilobytes", - "factor" : "0.000125", - "unit" : "kilobyte" - }, - "week" : { - "unit" : "week", - "factor" : "0.142857142857143", - "aliases" : ["wks", "wk"], - "plural" : "weeks", - "type" : "duration" - }, - "megadyne" : { - "factor" : "10", - "unit" : "megadyne", - "type" : "force", - "aliases" : [], - "plural" : "megadynes" - }, - "nautical mile" : { - "type" : "length", - "aliases" : ["n", "ns", "nm", "nms", "nmi", "nmis"], - "plural" : "nautical miles", - "factor" : "0.000539957", - "unit" : "nautical mile" - }, - "square inch" : { - "unit" : "square inch", - "factor" : "15500031", - "aliases" : ["inch^2", "inches^2", "squinch", "in^2", "in²"], - "plural" : "square inches", - "type" : "area" - }, - "millennium" : { - "unit" : "millennium", - "factor" : "0.00000273972602739726", - "aliases" : [], - "plural" : "millennia", - "type" : "duration" - }, - "gigabyte" : { - "plural" : "gigabytes", - "aliases" : ["gb", "gbs"], - "type" : "digital", - "unit" : "gigabyte", - "factor" : "1.25e-10" - }, - "microsecond" : { - "plural" : "microseconds", - "aliases" : ["microsec", "microsecs", "µs"], - "type" : "duration", - "unit" : "microsecond", - "factor" : "86400000000" - }, - "celsius" : { - "unit" : "celsius", - "factor" : "1", - "plural" : "celsius", - "can_be_negative" : "1", - "aliases" : ["c", "°c"], - "type" : "temperature" - }, - "kilonewtons" : { - "unit" : "kilonewtons", - "factor" : "0.001", - "aliases" : ["kn"], - "plural" : "kilonewtons", - "type" : "force" - }, - "second" : { - "factor" : "86400", - "unit" : "second", - "type" : "duration", - "plural" : "seconds", - "aliases" : ["sec", "s"] - }, - "electron volt" : { - "factor" : "6.2415096e+18", - "unit" : "electron volt", - "type" : "energy", - "plural" : "electron volts", - "aliases" : ["electronvolt", "electronvolts", "ev", "evs"] - }, - "gradian" : { - "factor" : "1.11111111111111", - "unit" : "gradian", - "type" : "angle", - "plural" : "gradians", - "aliases" : ["grad", "grads", "gon", "gons", "grade", "grades"] - }, - "kilobit" : { - "aliases" : ["kbit", "kbits"], - "plural" : "kilobits", - "type" : "digital", - "unit" : "kilobit", - "factor" : "0.001" - }, - "kilowatt-hour" : { - "factor" : "2.77777777777778e-07", - "unit" : "kilowatt-hour", - "type" : "energy", - "aliases" : ["kilowatt hour", "kilowatt hours", "kwh"], - "plural" : "kilowatt-hours" - }, - "pound" : { - "type" : "mass", - "aliases" : ["lb", "lbm", "pound mass", "lbs", "lbms", "pounds mass"], - "plural" : "pounds", - "factor" : "2204.62", - "unit" : "pound" - }, - "terabyte" : { - "plural" : "terabytes", - "aliases" : ["tb", "tbs"], - "type" : "digital", - "unit" : "terabyte", - "factor" : "1.25e-13" - }, - "avoirdupois dram" : { - "type" : "mass", - "plural" : "avoirdupois drams", - "aliases" : ["dram", "drams", "dram avoirdupois", "drams avoirdupois", "avoirdupois dram"], - "factor" : "564383.3912", - "unit" : "avoirdupois dram" - }, - "gram" : { - "factor" : "1000000", - "unit" : "gram", - "type" : "mass", - "plural" : "grams", - "aliases" : ["g", "gm", "gramme", "gs", "gms", "grammes"] - }, - "inch" : { - "factor" : "39.37007874015748031496062992126", - "unit" : "inch", - "type" : "length", - "aliases" : ["in", "ins"], - "plural" : "inches" - }, - "gibibit" : { - "type" : "digital", - "plural" : "gibibits", - "aliases" : ["gibit", "gibits"], - "factor" : "9.31322574615479e-10", - "unit" : "gibibit" - }, - "century" : { - "plural" : "centuries", - "aliases" : [], - "type" : "duration", - "unit" : "century", - "factor" : "0.0000273972602739726" - }, - "erg" : { - "factor" : "1e-07", - "unit" : "erg", - "type" : "energy", - "aliases" : ["ergon", "ergons"], - "plural" : "ergs" - }, - "terawatt" : { - "type" : "power", - "aliases" : ["tw"], - "plural" : "terawatts", - "factor" : "1e-12", - "unit" : "terawatt" - }, - "joule" : { - "aliases" : ["j", "js"], - "plural" : "joules", - "type" : "energy", - "unit" : "joule", - "factor" : "1" - }, - "milliwatt" : { - "type" : "power", - "plural" : "milliwatts", - "aliases" : [], - "factor" : "1000", - "unit" : "milliwatt" - }, - "chain" : { - "unit" : "chain", - "factor" : "0.0497096953789867", - "plural" : "chains", - "aliases" : ["gunter's chains"], - "type" : "length" - }, - "us gallon" : { - "type" : "volume", - "plural" : "us gallons", - "aliases" : ["fluid gallon", "us fluid gallon", "fluid gallons", "gallon", "gallons"], - "factor" : "0.264172052358148", - "unit" : "us gallon" - }, - "electrical horsepower" : { - "type" : "power", - "plural" : "electrical horsepower", - "aliases" : ["electrical horsepowers", "hp", "hp"], - "factor" : "0.00134048257372654", - "unit" : "electrical horsepower" - }, - "fathom" : { - "type" : "length", - "plural" : "fathoms", - "aliases" : ["ftm", "ftms"], - "factor" : "0.539611824837685", - "unit" : "fathom" - }, - "megabit" : { - "aliases" : ["mbit", "mbits"], - "plural" : "megabits", - "type" : "digital", - "unit" : "megabit", - "factor" : "1e-06" - }, - "metric teaspoon" : { - "unit" : "metric teaspoon", - "factor" : "200", - "plural" : "metric teaspoons", - "aliases" : ["metric tsp", "metric tsp."], - "type" : "volume" - }, - "milligram" : { - "factor" : "1000000000", - "unit" : "milligram", - "type" : "mass", - "plural" : "milligrams", - "aliases" : ["mg", "mgs"] - }, - "microgram" : { - "unit" : "microgram", - "factor" : "1000000000000", - "aliases" : ["mcg", "mcgs", "µg"], - "plural" : "micrograms", - "type" : "mass" - }, - "m/s" : { - "unit" : "m/s", - "factor" : "1", - "plural" : "m/s", - "aliases" : ["meters per second", "metres per second", "meter per second", "metre per second", "meter/second", "metre/second", "meters/second", "metres/second", "mps"], - "type" : "speed" - }, - "meganewton" : { - "factor" : "1e-06", - "unit" : "meganewton", - "type" : "force", - "aliases" : ["mn"], - "plural" : "meganewtons" - }, - "decade" : { - "aliases" : [], - "plural" : "decades", - "type" : "duration", - "unit" : "decade", - "factor" : "0.000273972602739726" - }, - "mebibyte" : { - "type" : "digital", - "aliases" : ["mib", "mibs"], - "plural" : "mebibytes", - "factor" : "1.19209289550781e-07", - "unit" : "mebibyte" - }, - "kibibit" : { - "factor" : "0.0009765625", - "unit" : "kibibit", - "type" : "digital", - "plural" : "kibibits", - "aliases" : ["kibit", "kibits"] - }, - "degree" : { - "factor" : "1", - "unit" : "degree", - "type" : "angle", - "plural" : "degrees", - "aliases" : ["deg", "degs"] - }, - "byte" : { - "factor" : "0.125", - "unit" : "byte", - "type" : "digital", - "plural" : "bytes", - "aliases" : [] - }, - "large calorie" : { - "plural" : "large calories", - "aliases" : ["food calorie", "food calories", "kcals", "kcal"], - "type" : "energy", - "unit" : "large calorie", - "factor" : "0.000239005736137667" - }, - "cubic inch" : { - "plural" : "cubic inches", - "aliases" : ["cubic inch", "cubic in", "cu inch", "cu in", "inch^3", "in^3", "cui"], - "type" : "volume", - "unit" : "cubic inch", - "factor" : "61.024" - }, - "rankine" : { - "unit" : "rankine", - "factor" : "1", - "plural" : "rankine", - "aliases" : ["r"], - "type" : "temperature" - }, - "zettabit" : { - "type" : "digital", - "aliases" : ["zbit", "zbits"], - "plural" : "zettabits", - "factor" : "1e-21", - "unit" : "zettabit" - }, - "hour" : { - "plural" : "hours", - "aliases" : ["hr", "hrs", "h"], - "type" : "duration", - "unit" : "hour", - "factor" : "24" - }, - "acre" : { - "plural" : "acres", - "aliases" : [], - "type" : "area", - "unit" : "acre", - "factor" : "2.4710439" - }, - "yard" : { - "aliases" : ["yd", "yds", "yrds"], - "plural" : "yards", - "type" : "length", - "unit" : "yard", - "factor" : "1.0936132983377077865266841644794" - }, - "ton" : { - "factor" : "1.10231", - "unit" : "ton", - "type" : "mass", - "plural" : "tons", - "aliases" : ["short ton", "short tons"] - }, - "giganewton" : { - "factor" : "1e-09", - "unit" : "giganewton", - "type" : "force", - "aliases" : ["gn"], - "plural" : "giganewtons" - }, - "poundal" : { - "factor" : "7.23301385120989", - "unit" : "poundal", - "type" : "force", - "aliases" : ["pdl"], - "plural" : "poundals" - }, - "stone" : { - "type" : "mass", - "aliases" : ["st", "stones", "sts"], - "plural" : "stone", - "factor" : "157.473", - "unit" : "stone" - }, - "fortnight" : { - "unit" : "fortnight", - "factor" : "0.0714285714285714", - "plural" : "fortnights", - "aliases" : [], - "type" : "duration" - }, - "zebibit" : { - "type" : "digital", - "aliases" : ["zibit", "zibits"], - "plural" : "zebibits", - "factor" : "8.470329472543e-22", - "unit" : "zebibit" - }, - "megawatt" : { - "factor" : "1e-06", - "unit" : "megawatt", - "type" : "power", - "plural" : "megawatts", - "aliases" : ["mw"] - }, - "mph" : { - "plural" : "mph", - "aliases" : ["mi/h", "miles/hour", "miles per hour", "mile per hour"], - "type" : "speed", - "unit" : "mph", - "factor" : "2.236941851939304" - }, - "square millimeter" : { - "unit" : "square millimeter", - "factor" : "10000000000", - "plural" : "square millimeters", - "aliases" : ["square millimetre", "square millimetres", "mm^2", "mm²"], - "type" : "area" - }, - "km/h" : { - "factor" : "3.6", - "unit" : "km/h", - "type" : "speed", - "plural" : "km/h", - "aliases" : ["kilometer per hour", "kilometre per hour", "kph", "kmph", "kilometers per hour", "kilometres per hour"] - }, - "坪" : { - "unit" : "坪", - "factor" : "3024.80338778", - "plural" : "坪", - "aliases" : ["ping"], - "type" : "area" - }, - "imperial quart" : { - "unit" : "imperial quart", - "factor" : "7.03901594557081", - "plural" : "imperial quarts", - "aliases" : ["british quarts", "british quart"], - "type" : "volume" - }, - "quadrant" : { - "plural" : "quadrants", - "aliases" : ["quads", "quad"], - "type" : "angle", - "unit" : "quadrant", - "factor" : "0.0111111111111111" - }, - "us fluid ounce" : { - "type" : "volume", - "plural" : "us fluid ounces", - "aliases" : ["us fl oz", "fl oz", "fl. oz", "fluid oz"], - "factor" : "33.814022701843", - "unit" : "us fluid ounce" - } -} From 539e5dcd781a09fd8bcf314b399984aa9893c180 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:20:08 +0100 Subject: [PATCH 47/91] Conversions: Tiding up a little --- lib/DDG/Goodie/Conversions.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index 2bd25b733..c05902906 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -21,7 +21,7 @@ my @types = LoadFile(share('ratios.yml')); my %plurals = (); my @units = (); -foreach my $type (@types) { +foreach my $type (@types) { push(@units, $type->{'unit'}); push(@units, $type->{'plural'}) unless $type->{'unit'} eq $type->{'plural'}; push(@units, @{$type->{'aliases'}}); @@ -159,11 +159,9 @@ handle query_lc => sub { $result->{'to_unit'} = ($result->{'result'} == 1 ? "degree" : "degrees") . " $result->{'to_unit'}" if ($result->{'to_unit'} ne "kelvin"); } else { $result->{'from_unit'} = set_unit_pluralisation($result->{'from_unit'}, $factor); - $result->{'to_unit'} = set_unit_pluralisation($result->{'to_unit'}, $result->{'result'}); + $result->{'to_unit'} = set_unit_pluralisation($result->{'to_unit'}, $result->{'result'}); } - #warn($result->{'from_unit'}. " | ". $result->{'to_unit'}); - $result->{'result'} = $formatted_result; $result->{'result'} =~ s/\.0{$precision}$//; $result->{'result'} = $styler->for_display($result->{'result'}); From 6775764f28e25059a1feaebb42a0b2e76427d0d7 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:25:37 +0100 Subject: [PATCH 48/91] Conversions: refactoring and tidying up around set_unit_pluralisation --- lib/DDG/Goodie/Conversions.pm | 15 +++------------ share/goodie/conversions/ratios.yml | 0 2 files changed, 3 insertions(+), 12 deletions(-) mode change 100755 => 100644 share/goodie/conversions/ratios.yml diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index c05902906..1f7a715cf 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -249,7 +249,7 @@ sub convert { my ($conversion) = @_; my @matches = get_matches($conversion->{'from_unit'}, $conversion->{'to_unit'}); - + return if $conversion->{'factor'} < 0 && !($matches[0]->{'can_be_negative'}); # matches must be of the same type (e.g., can't convert mass to length): @@ -274,17 +274,8 @@ sub convert { sub set_unit_pluralisation { my ($unit, $count) = @_; - my $proper_unit = $unit; - - my $already_plural = looks_plural($unit); - - if ($already_plural && $count == 1) { - $proper_unit = $unit; - } elsif (!$already_plural && $count != 1) { - $proper_unit = $plurals{lc $unit}; - } - - return $proper_unit; + $unit = $plurals{lc $unit} if ($count != 1 && !looks_plural($unit)); + return $unit; } 1; diff --git a/share/goodie/conversions/ratios.yml b/share/goodie/conversions/ratios.yml old mode 100755 new mode 100644 From cd4bf80a17d89566a83c2b4f0cc4be0383e8f6bc Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:28:00 +0100 Subject: [PATCH 49/91] Conversions: Minor code tidies --- lib/DDG/Goodie/Conversions.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index 1f7a715cf..e7e9cddd6 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -197,7 +197,7 @@ sub looks_plural { my $is_plural = 0; foreach my $x (keys(%plurals)) { - $is_plural = 1 if lc $plurals{$x} eq lc $unit; + $is_plural = 1 if(lc($plurals{$x}) eq lc($unit)); } return $is_plural; From 679a1d7fdfe9a5238ba682d408aaf08d5f2e8a5d Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:28:49 +0100 Subject: [PATCH 50/91] Conversions: Plural isn't used in the response from get_matches as it's looked up in the hash --- lib/DDG/Goodie/Conversions.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index e7e9cddd6..4de715a17 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -236,7 +236,6 @@ sub get_matches { type => $type->{'type'}, factor => $type->{'factor'}, unit => $type->{'unit'}, - plural => $type->{'plural'}, can_be_negative => $type->{'can_be_negative'} || '0' }); } From 4417d51443c3570a11a70770f80f0507b8c73e8e Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:30:34 +0100 Subject: [PATCH 51/91] Conversions: More tidying up; also dodged bug where units would be added twice --- lib/DDG/Goodie/Conversions.pm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index 4de715a17..f4c8b7939 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -9,7 +9,6 @@ use Math::Round qw/nearest/; use utf8; use YAML::XS 'LoadFile'; use List::Util qw(any); -use Data::Dump qw(dump); zci answer_type => 'conversions'; zci is_cached => 1; @@ -19,11 +18,10 @@ use bignum; my @types = LoadFile(share('ratios.yml')); my %plurals = (); - my @units = (); foreach my $type (@types) { push(@units, $type->{'unit'}); - push(@units, $type->{'plural'}) unless $type->{'unit'} eq $type->{'plural'}; + push(@units, $type->{'plural'}) unless lc $type->{'unit'} eq lc $type->{'plural'}; push(@units, @{$type->{'aliases'}}); $plurals{lc $type->{'unit'}} = lc $type->{'plural'}; } From 9418f7baef63c2c59d7bb553fcf1a4a1a9ea2431 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:31:36 +0100 Subject: [PATCH 52/91] Conversions: Didn't use List::Util in the end as it's all in hashes --- lib/DDG/Goodie/Conversions.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index f4c8b7939..bd46ca912 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -8,7 +8,6 @@ with 'DDG::GoodieRole::NumberStyler'; use Math::Round qw/nearest/; use utf8; use YAML::XS 'LoadFile'; -use List::Util qw(any); zci answer_type => 'conversions'; zci is_cached => 1; From 13509c09b109518f6511d6adc4b8b86f495a8d78 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:33:02 +0100 Subject: [PATCH 53/91] Conversions: Not sure why I was looking up the value everytime from the hash here --- lib/DDG/Goodie/Conversions.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index bd46ca912..a53d658aa 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -190,11 +190,11 @@ handle query_lc => sub { }; sub looks_plural { - my ($unit) = @_; + my ($input) = @_; my $is_plural = 0; - foreach my $x (keys(%plurals)) { - $is_plural = 1 if(lc($plurals{$x}) eq lc($unit)); + foreach my $x (values(%plurals)) { + $is_plural = 1 if(lc($x) eq lc($input)); } return $is_plural; From bdd54b6a8f70d7feb5b9ed4c64d197a08a8c9057 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 9 May 2016 20:34:15 +0100 Subject: [PATCH 54/91] Conversions: now it's in a list of values; we can use List::Util again! --- lib/DDG/Goodie/Conversions.pm | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index a53d658aa..fe4dc215a 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -8,6 +8,7 @@ with 'DDG::GoodieRole::NumberStyler'; use Math::Round qw/nearest/; use utf8; use YAML::XS 'LoadFile'; +use List::Util qw(any); zci answer_type => 'conversions'; zci is_cached => 1; @@ -191,13 +192,7 @@ handle query_lc => sub { sub looks_plural { my ($input) = @_; - - my $is_plural = 0; - foreach my $x (values(%plurals)) { - $is_plural = 1 if(lc($x) eq lc($input)); - } - - return $is_plural; + return any {lc($_) eq lc($input)} values(%plurals); } sub convert_temperatures { From 16f3fd45991fe98e12031f1bb017e63f8571d738 Mon Sep 17 00:00:00 2001 From: Rasika Pohankar Date: Wed, 11 May 2016 02:11:54 +0530 Subject: [PATCH 55/91] Zapp Brannigan: Convert to full template (#2994) * Change to full template, add handlebars file for new line in quote. * Change data to -ANY- in test file. * Replace regex with re(). --- lib/DDG/Goodie/ZappBrannigan.pm | 16 ++++++++++---- .../goodie/zapp_brannigan/content.handlebars | 1 + t/ZappBrannigan.t | 22 +++++++++++++------ 3 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 share/goodie/zapp_brannigan/content.handlebars diff --git a/lib/DDG/Goodie/ZappBrannigan.pm b/lib/DDG/Goodie/ZappBrannigan.pm index 34b6721bb..3c470ec3e 100644 --- a/lib/DDG/Goodie/ZappBrannigan.pm +++ b/lib/DDG/Goodie/ZappBrannigan.pm @@ -22,9 +22,17 @@ handle query => sub { return join("\n", @quote), structured_answer => { - input => [], - operation => 'Zapp Brannigan quote', - result => join('
', @quote)}; + data => { + content => join("
", @quote), + subtitle => 'Zapp Brannigan quote' + }, + templates => { + group => "text", + options => { + content => 'DDH.zapp_brannigan.content' + } + } + }; }; -1; +1; \ No newline at end of file diff --git a/share/goodie/zapp_brannigan/content.handlebars b/share/goodie/zapp_brannigan/content.handlebars new file mode 100644 index 000000000..b2f25cf9e --- /dev/null +++ b/share/goodie/zapp_brannigan/content.handlebars @@ -0,0 +1 @@ +

{{{content}}}

\ No newline at end of file diff --git a/t/ZappBrannigan.t b/t/ZappBrannigan.t index 836f092c2..11ec2b548 100644 --- a/t/ZappBrannigan.t +++ b/t/ZappBrannigan.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'zapp_brannigan'; @@ -10,14 +11,21 @@ zci is_cached => 0; ddg_goodie_test( [qw( DDG::Goodie::ZappBrannigan )], - 'zapp brannigan quote' => test_zci( - qr/Zapp Brannigan: /, + 'zapp brannigan quote' => test_zci( + re('Zapp Brannigan: '), structured_answer => { - input => [], - operation => 'Zapp Brannigan quote', - result => qr/Zapp Brannigan: /, - }, + data => { + subtitle => 'Zapp Brannigan quote', + content => re('Zapp Brannigan: ') + }, + templates => { + group => "text", + options => { + content => 'DDH.zapp_brannigan.content' + } + } + }, ), ); -done_testing; +done_testing; \ No newline at end of file From a4595319501d263bde6a22f82343f8d235cf5a6e Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Tue, 10 May 2016 21:46:51 +0100 Subject: [PATCH 56/91] Remove trailing white space --- t/ZappBrannigan.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/ZappBrannigan.t b/t/ZappBrannigan.t index 11ec2b548..90c70b034 100644 --- a/t/ZappBrannigan.t +++ b/t/ZappBrannigan.t @@ -11,10 +11,10 @@ zci is_cached => 0; ddg_goodie_test( [qw( DDG::Goodie::ZappBrannigan )], - 'zapp brannigan quote' => test_zci( + 'zapp brannigan quote' => test_zci( re('Zapp Brannigan: '), structured_answer => { - data => { + data => { subtitle => 'Zapp Brannigan quote', content => re('Zapp Brannigan: ') }, @@ -23,9 +23,9 @@ ddg_goodie_test( options => { content => 'DDH.zapp_brannigan.content' } - } - }, + } + }, ), ); -done_testing; \ No newline at end of file +done_testing; From ab81e41359260e70d0bdd38c63b06a7411fb3dd1 Mon Sep 17 00:00:00 2001 From: Sebastian Nemak Date: Tue, 10 May 2016 22:54:08 +0200 Subject: [PATCH 57/91] Update the description --- share/goodie/cheat_sheets/json/zfs.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/goodie/cheat_sheets/json/zfs.json b/share/goodie/cheat_sheets/json/zfs.json index 22758e12f..6f79c2de7 100644 --- a/share/goodie/cheat_sheets/json/zfs.json +++ b/share/goodie/cheat_sheets/json/zfs.json @@ -1,7 +1,7 @@ { "id": "zfs_cheat_sheet", "name": "ZFS", - "description": "The combined file system and logical volume manager.", + "description": "The combined file system and logical volume manager. Data are important - be careful with it.", "metadata": { "sourceName": "FreeBSD handbook - The Z File System (ZFS)", "sourceUrl": "https://www.freebsd.org/doc/handbook/zfs.html" From d2996bf4d5ae4d4054c5ff5cfdb574a3bb0a94bd Mon Sep 17 00:00:00 2001 From: Rasika Pohankar Date: Wed, 11 May 2016 02:30:42 +0530 Subject: [PATCH 58/91] Birthstone: Convert to full template (#2807) * Added plaintext response. * Removed id and name. * Fixed alignment. * Changed subtitle to Birthstone for month. * Changed subtitle in test file. --- lib/DDG/Goodie/BirthStone.pm | 16 +++++---- t/BirthStone.t | 63 +++++++++++++----------------------- 2 files changed, 33 insertions(+), 46 deletions(-) diff --git a/lib/DDG/Goodie/BirthStone.pm b/lib/DDG/Goodie/BirthStone.pm index 84c60a699..67aeb2ebc 100644 --- a/lib/DDG/Goodie/BirthStone.pm +++ b/lib/DDG/Goodie/BirthStone.pm @@ -30,13 +30,17 @@ handle remainder => sub { return unless $month; my $stone = $birthstones{$month}; return unless $stone; - + return $month . " birthstone: $stone", - structured_answer => { - input => [$month], - operation => 'Birthstone', - result => $stone - }; + structured_answer => { + data => { + title => $stone, + subtitle => 'Birthstone for '.$month + }, + templates => { + group => "text", + } + } }; 1; diff --git a/t/BirthStone.t b/t/BirthStone.t index f819252bf..7600209b2 100644 --- a/t/BirthStone.t +++ b/t/BirthStone.t @@ -8,48 +8,31 @@ use DDG::Test::Goodie; zci answer_type => "birth_stone"; zci is_cached => 1; +sub get_structured_answer { + my($month, $birthstone) = @_; + return $month . " birthstone: $birthstone", + structured_answer => { + data => { + title => $birthstone, + subtitle => 'Birthstone for '.$month + }, + templates => { + group => "text", + } + } +} + +sub build_test { + test_zci(get_structured_answer(@_)); +} + ddg_goodie_test( [qw( DDG::Goodie::BirthStone )], - 'april birth stone' => test_zci( - 'April birthstone: Diamond', - structured_answer => { - input => ['April'], - operation => 'Birthstone', - result => 'Diamond' - } - ), - 'birthstone JUNE' => test_zci( - 'June birthstone: Pearl', - structured_answer => { - input => ['June'], - operation => 'Birthstone', - result => 'Pearl' - } - ), - 'DecEmber birthstone' => test_zci( - 'December birthstone: Turquoise', - structured_answer => { - input => ['December'], - operation => 'Birthstone', - result => 'Turquoise' - } - ), - 'birthstone april' => test_zci( - 'April birthstone: Diamond', - structured_answer => { - input => ['April'], - operation => 'Birthstone', - result => 'Diamond' - } - ), - 'may birth stone' => test_zci( - 'May birthstone: Emerald', - structured_answer => { - input => ['May'], - operation => 'Birthstone', - result => 'Emerald' - } - ), + 'april birth stone' => build_test('April', 'Diamond'), + 'birthstone JUNE' => build_test('June', 'Pearl'), + 'DecEmber birthstone' => build_test('December', 'Turquoise'), + 'birthstone april' => build_test('April', 'Diamond'), + 'may birth stone' => build_test('May', 'Emerald') ); done_testing; From 9b5d96c5c3d38ab13faecb627e7bb8081d48f6af Mon Sep 17 00:00:00 2001 From: Rasika Pohankar Date: Wed, 11 May 2016 17:13:08 +0530 Subject: [PATCH 59/91] Update ValarMorghulis to use full template. (#3034) --- lib/DDG/Goodie/ValarMorghulis.pm | 10 +++++++--- t/ValarMorghulis.t | 12 ++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/DDG/Goodie/ValarMorghulis.pm b/lib/DDG/Goodie/ValarMorghulis.pm index 0e0aa5750..90521008c 100644 --- a/lib/DDG/Goodie/ValarMorghulis.pm +++ b/lib/DDG/Goodie/ValarMorghulis.pm @@ -17,9 +17,13 @@ handle remainder => sub { return $answer, structured_answer => { - input => ['Valar morghulis'], - operation => 'Code phrase', - result => $answer + data => { + title => $answer, + subtitle => 'Code phrase: Valar morghulis' + }, + templates => { + group => 'text' + } }; }; diff --git a/t/ValarMorghulis.t b/t/ValarMorghulis.t index c97855886..b36e35436 100644 --- a/t/ValarMorghulis.t +++ b/t/ValarMorghulis.t @@ -14,13 +14,17 @@ ddg_goodie_test( 'valar morghulis' => test_zci( 'Valar dohaeris', structured_answer => { - input => ['Valar morghulis'], - operation => 'Code phrase', - result => 'Valar dohaeris' + data => { + title => 'Valar dohaeris', + subtitle => 'Code phrase: Valar morghulis' + }, + templates => { + group => 'text' + } } ), 'what is valar morghulis' => undef, 'valar morghulis meaning' => undef, ); -done_testing; +done_testing; \ No newline at end of file From 3831d2bf71ab2f2c4bc6d444bb2ce9c742f8f4ae Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Wed, 11 May 2016 18:45:02 +0100 Subject: [PATCH 60/91] Conversions: Fixing tnt vs TNT for @guiltydolphin --- lib/DDG/Goodie/Conversions.pm | 2 +- t/Conversions.t | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index fe4dc215a..4cfb5ff6a 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -23,7 +23,7 @@ foreach my $type (@types) { push(@units, $type->{'unit'}); push(@units, $type->{'plural'}) unless lc $type->{'unit'} eq lc $type->{'plural'}; push(@units, @{$type->{'aliases'}}); - $plurals{lc $type->{'unit'}} = lc $type->{'plural'}; + $plurals{lc $type->{'unit'}} = $type->{'plural'}; } # build triggers based on available conversion units: diff --git a/t/Conversions.t b/t/Conversions.t index 1bee674b4..f2873ebe0 100755 --- a/t/Conversions.t +++ b/t/Conversions.t @@ -588,14 +588,14 @@ ddg_goodie_test( }) ), '2500kcal in tons of tnt' => test_zci( - '2,500 large calories = 0.003 tons of tnt', + '2,500 large calories = 0.003 tons of TNT', structured_answer => make_answer({ markup_input => '2,500', raw_input => '2500', from_unit => 'large calories', styled_output => '0.003', raw_answer => '0.003', - to_unit => 'tons of tnt', + to_unit => 'tons of TNT', physical_quantity => 'energy' }) ), From f62adb5b709583f77e3e2d94f21c9e42c6a3109e Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Wed, 11 May 2016 18:49:28 +0100 Subject: [PATCH 61/91] Conversions: Adding hash for the opposite direction (plural_to_unit) to quickly determine if a unit/alias is plural --- lib/DDG/Goodie/Conversions.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index 4cfb5ff6a..f9d088e63 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -17,13 +17,15 @@ use bignum; my @types = LoadFile(share('ratios.yml')); -my %plurals = (); +my %unit_to_plural = (); my @units = (); +my %plural_to_unit = (); foreach my $type (@types) { push(@units, $type->{'unit'}); push(@units, $type->{'plural'}) unless lc $type->{'unit'} eq lc $type->{'plural'}; push(@units, @{$type->{'aliases'}}); - $plurals{lc $type->{'unit'}} = $type->{'plural'}; + $unit_to_plural{lc $type->{'unit'}} = $type->{'plural'}; + $plural_to_unit{lc $type->{'plural'}} = $type->{'unit'}; } # build triggers based on available conversion units: @@ -192,7 +194,7 @@ handle query_lc => sub { sub looks_plural { my ($input) = @_; - return any {lc($_) eq lc($input)} values(%plurals); + return defined $plural_to_unit{lc $input}; } sub convert_temperatures { @@ -265,7 +267,7 @@ sub convert { sub set_unit_pluralisation { my ($unit, $count) = @_; - $unit = $plurals{lc $unit} if ($count != 1 && !looks_plural($unit)); + $unit = $unit_to_plural{lc $unit} if ($count != 1 && !looks_plural($unit)); return $unit; } From 54ef078da563df606560c72e0081b3a45d051264 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Wed, 11 May 2016 18:54:16 +0100 Subject: [PATCH 62/91] Conversions: Singular test for ton of TNT --- t/Conversions.t | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/t/Conversions.t b/t/Conversions.t index f2873ebe0..2377510e6 100755 --- a/t/Conversions.t +++ b/t/Conversions.t @@ -599,6 +599,18 @@ ddg_goodie_test( physical_quantity => 'energy' }) ), + '1000000 kcal in tons of tnt' => test_zci( + '1,000,000 large calories = 1 ton of TNT', + structured_answer => make_answer({ + markup_input => '1,000,000', + raw_input => '1000000', + from_unit => 'large calories', + styled_output => '1', + raw_answer => '1', + to_unit => 'ton of TNT', + physical_quantity => 'energy' + }) + ), '90 ps in watts' => test_zci( '90 metric horsepower = 66,194.888 watts', structured_answer => make_answer({ From 10eac5a7988850e6d84318619810d83cb56b3bca Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Wed, 11 May 2016 20:03:11 +0100 Subject: [PATCH 63/91] Conversions: Adding tests around singular for mmHg --- t/Conversions.t | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/t/Conversions.t b/t/Conversions.t index 2377510e6..67afa60b5 100755 --- a/t/Conversions.t +++ b/t/Conversions.t @@ -359,6 +359,18 @@ ddg_goodie_test( physical_quantity => 'pressure' }) ), + '0.01933677566613741911668448550544 psi in mmHg' => test_zci( + '0.01933677566613741911668448550544 pounds per square inch = 1 mmHg', + structured_answer => make_answer({ + markup_input => '0.01933677566613741911668448550544', + raw_input => '0.01933677566613741911668448550544', + from_unit => 'pounds per square inch', + styled_output => '1', + raw_answer => '1', + to_unit => 'mmHg', + physical_quantity => 'pressure' + }) + ), '2 thou to mm' => test_zci( '2 thousandths of an inch = 0.051 millimeters', structured_answer => make_answer({ From b6ae44f9b810dca45b28ced34c0b5ffa99ba3c01 Mon Sep 17 00:00:00 2001 From: JOBIN PHILIP ABRAHAM Date: Thu, 12 May 2016 17:47:48 +0530 Subject: [PATCH 64/91] Update sql.json Removed second appearance of "foreign key" fixed#3036 --- share/goodie/cheat_sheets/json/sql.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/share/goodie/cheat_sheets/json/sql.json b/share/goodie/cheat_sheets/json/sql.json index 0b8cc90b7..e2e11f03b 100644 --- a/share/goodie/cheat_sheets/json/sql.json +++ b/share/goodie/cheat_sheets/json/sql.json @@ -236,9 +236,6 @@ }, { "key": "FOREIGN KEY", "val": "Ensure the referential integrity of the data in one table to match values in another table" - }, { - "key": "FOREIGN KEY", - "val": "Ensure the referential integrity of the data in one table to match values in another table" }, { "key": "DEFAULT", "val": "Specifies a default value for a column" From a426dccaf576bacce3f2c852b6e37532a6c99aa6 Mon Sep 17 00:00:00 2001 From: Naveen Karippai Date: Thu, 12 May 2016 15:23:28 +0200 Subject: [PATCH 65/91] Convert CountryCodes to full template goodie (#3037) Goodies have full support for templates, and it'd be great to make sure that all goodies use full templates. The "simple structured_answer" was provided as a temporary workaround. * change to 'text' template for structured_answer object * refactored test suite See also: Updates CountryCodes Goodie Re: #2767 --- lib/DDG/Goodie/CountryCodes.pm | 10 ++- t/CountryCodes.t | 137 ++++++++------------------------- 2 files changed, 37 insertions(+), 110 deletions(-) diff --git a/lib/DDG/Goodie/CountryCodes.pm b/lib/DDG/Goodie/CountryCodes.pm index 3bef07382..520d06ff8 100644 --- a/lib/DDG/Goodie/CountryCodes.pm +++ b/lib/DDG/Goodie/CountryCodes.pm @@ -36,9 +36,13 @@ handle remainder => sub { return 'ISO 3166: '. ucfirst $input .' - '. $answer[0], structured_answer => { - input => [ucfirst $input], - operation => 'ISO 3166 Country code', - result => ($answer[0]), + data => { + title => $answer[0], + subtitle => "ISO 3166 Country code: " . ucfirst ($input) + }, + templates => { + group => "text" + } }; }; diff --git a/t/CountryCodes.t b/t/CountryCodes.t index 614c0c01d..d283c8617 100644 --- a/t/CountryCodes.t +++ b/t/CountryCodes.t @@ -9,116 +9,39 @@ use DDG::Test::Goodie; zci answer_type => "country_codes"; zci is_cached => 1; -my $text = '
ISO 3166 Country code for'; +sub build_structured_answer{ + my ($country, $response) = @_; + return 'ISO 3166: '. ucfirst $country .' - '. $response, + structured_answer => { + data => { + title => $response, + subtitle => "ISO 3166 Country code: " . ucfirst ($country), + }, + templates => { + group => "text", + }, + }, +} + +sub build_test { test_zci(build_structured_answer(@_)) } ddg_goodie_test( [ 'DDG::Goodie::CountryCodes' ], - "country code Japan" => test_zci( - qq(ISO 3166: Japan - jp), - structured_answer => { - input => ['Japan'], - operation => 'ISO 3166 Country code', - result => 'jp' - } - ), - "3 letter country code Japan" => test_zci( - qq(ISO 3166: Japan - jpn), - structured_answer => { - input => ['Japan'], - operation => 'ISO 3166 Country code', - result => 'jpn' - } - ), - "3 letter country code of China" => test_zci( - qq(ISO 3166: China - chn), - structured_answer => { - input => ['China'], - operation => 'ISO 3166 Country code', - result => 'chn' - } - ), - "Japan 3 letter country code" => test_zci( - qq(ISO 3166: Japan - jpn), - structured_answer => { - input => ['Japan'], - operation => 'ISO 3166 Country code', - result => 'jpn' - } - ), - "Russia two letter country code" => test_zci( - qq(ISO 3166: Russia - ru), - structured_answer => { - input => ['Russia'], - operation => 'ISO 3166 Country code', - result => 'ru' - } - ), - "two letter country code Japan" => test_zci( - qq(ISO 3166: Japan - jp), - structured_answer => { - input => ['Japan'], - operation => 'ISO 3166 Country code', - result => 'jp' - } - ), - "three letter country code for Japan" => test_zci( - qq(ISO 3166: Japan - jpn), - structured_answer => { - input => ['Japan'], - operation => 'ISO 3166 Country code', - result => 'jpn' - } - ), - "numerical iso code japan" => test_zci( - qq(ISO 3166: Japan - 392), - structured_answer => { - input => ['Japan'], - operation => 'ISO 3166 Country code', - result => '392' - } - ), - "iso code for spain" => test_zci( - qq(ISO 3166: Spain - es), - structured_answer => { - input => ['Spain'], - operation => 'ISO 3166 Country code', - result => 'es' - } - ), - "country code jp" => test_zci( - qq(ISO 3166: Japan - jp), - structured_answer => { - input => ['Japan'], - operation => 'ISO 3166 Country code', - result => 'jp' - } - ), - "japan numerical iso 3166" => test_zci( - qq(ISO 3166: Japan - 392), - structured_answer => { - input => ['Japan'], - operation => 'ISO 3166 Country code', - result => '392' - } - ), - "united states of america iso code" => test_zci( - qq(ISO 3166: United states of america - us), - structured_answer => { - input => ['United states of america'], - operation => 'ISO 3166 Country code', - result => 'us' - } - ), - "3 letter iso code isle of man" => test_zci( - qq(ISO 3166: Isle of man - imn), - structured_answer => { - input => ['Isle of man'], - operation => 'ISO 3166 Country code', - result => 'imn' - } - ), - 'country code for gelgamek' => undef, - 'iso code for english' => undef, + "country code Japan" => build_test("Japan","jp"), + "3 letter country code Japan" => build_test("Japan","jpn"), + "3 letter country code of China" => build_test("China","chn"), + "Japan 3 letter country code" => build_test("Japan","jpn"), + "Russia two letter country code" => build_test("Russia","ru"), + "two letter country code Japan" => build_test("Japan","jp"), + "three letter country code for Japan" => build_test("Japan","jpn"), + "numerical iso code japan" => build_test("Japan",392), + "iso code for spain" => build_test("Spain","es"), + "country code jp" => build_test("Japan","jp"), + "japan numerical iso 3166" => build_test("Japan",392), + "united states of america iso code" => build_test("United states of america","us"), + "3 letter iso code isle of man" => build_test("Isle of man","imn"), + 'country code for gelgamek' => undef, + 'iso code for english' => undef, ); done_testing; From e44920542d5f80fa84e746afd1b0e087c936f318 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Thu, 12 May 2016 20:40:00 +0100 Subject: [PATCH 66/91] Switch to lc handler So we don't need to normalize later. --- lib/DDG/Goodie/CheatSheets.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/DDG/Goodie/CheatSheets.pm b/lib/DDG/Goodie/CheatSheets.pm index 66bf5357e..0cfd591eb 100644 --- a/lib/DDG/Goodie/CheatSheets.pm +++ b/lib/DDG/Goodie/CheatSheets.pm @@ -113,7 +113,7 @@ my $aliases = get_aliases(); my ($trigger_ignore, %trigger_lookup) = generate_triggers($aliases); -handle remainder => sub { +handle remainder_lc => sub { my $remainder = shift; my $trigger = join(' ', split /\s+/o, lc($req->matched_trigger)); @@ -125,7 +125,7 @@ handle remainder => sub { $remainder =~ s/^\s*(.+?)\s*$/$1/; } - my $file = $aliases->{join(' ', split /\s+/o, lc($remainder))} or return; + my $file = $aliases->{join(' ', split /\s+/o, $remainder)} or return; open my $fh, $file or return; my $json = do { local $/; <$fh> }; my $data = decode_json($json) or return; From aedf7ea3f5f02d9eacff2c97e7ad70d44b2f9a00 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Thu, 12 May 2016 20:48:37 +0100 Subject: [PATCH 67/91] Improve efficiency of removing ignore phrases Thanks to @zachthompson for the algorithm (much faster). --- lib/DDG/Goodie/CheatSheets.pm | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/DDG/Goodie/CheatSheets.pm b/lib/DDG/Goodie/CheatSheets.pm index 0cfd591eb..985fde5b6 100644 --- a/lib/DDG/Goodie/CheatSheets.pm +++ b/lib/DDG/Goodie/CheatSheets.pm @@ -114,18 +114,14 @@ my $aliases = get_aliases(); my ($trigger_ignore, %trigger_lookup) = generate_triggers($aliases); handle remainder_lc => sub { - my $remainder = shift; + my @query_parts = split /\s+/o, shift; my $trigger = join(' ', split /\s+/o, lc($req->matched_trigger)); my $lookup = $trigger_lookup{$trigger}; - if (exists $trigger_ignore->{$trigger}) { - foreach my $ignore (keys %{$trigger_ignore->{$trigger}}) { - $remainder =~ s/\b$ignore\b//; - } - $remainder =~ s/^\s*(.+?)\s*$/$1/; - } - - my $file = $aliases->{join(' ', split /\s+/o, $remainder)} or return; + my $alias = join ' ', exists $trigger_ignore->{$trigger} + ? grep { not exists $trigger_ignore->{$trigger}{$_} } @query_parts + : @query_parts; + my $file = $aliases->{$alias} or return; open my $fh, $file or return; my $json = do { local $/; <$fh> }; my $data = decode_json($json) or return; From 1695ba5fd0fe6b8c6843ab47c76c8b081583cbc3 Mon Sep 17 00:00:00 2001 From: Vikash Verma Date: Fri, 13 May 2016 17:30:34 +0530 Subject: [PATCH 68/91] Update IA ID and aliases (#3039) --- .../cheat_sheets/json/{backbonejs.json => backbone-js.json} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename share/goodie/cheat_sheets/json/{backbonejs.json => backbone-js.json} (99%) diff --git a/share/goodie/cheat_sheets/json/backbonejs.json b/share/goodie/cheat_sheets/json/backbone-js.json similarity index 99% rename from share/goodie/cheat_sheets/json/backbonejs.json rename to share/goodie/cheat_sheets/json/backbone-js.json index fec562ccf..ee646dcff 100644 --- a/share/goodie/cheat_sheets/json/backbonejs.json +++ b/share/goodie/cheat_sheets/json/backbone-js.json @@ -1,5 +1,5 @@ { - "id": "backbonejs_cheat_sheet", + "id": "backbone_js_cheat_sheet", "name": "Backbone.js", "description": "A quick reference for Backbone.js, a JavaScript framework with a RESTful JSON interface and is based on the model–view–presenter (MVP) application design paradigm", "metadata": { @@ -8,7 +8,7 @@ }, "aliases": [ "backbone.js", - "backbone js", + "backbonejs", "backbone" ], "template_type": "terminal", @@ -162,4 +162,4 @@ "key": "Backbone.setDomLibrary(jQueryNew);" }] } -} \ No newline at end of file +} From d115e04a9505e6d17e8aa5b36ea8f65ae1495108 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Mon, 9 May 2016 18:19:50 +0100 Subject: [PATCH 69/91] Add check for IA page existence We check to make sure that an IA page with the correct ID exists. --- t/CheatSheets/CheatSheetsJSON.t | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/t/CheatSheets/CheatSheetsJSON.t b/t/CheatSheets/CheatSheetsJSON.t index ecb3e3b44..6b2f1d038 100755 --- a/t/CheatSheets/CheatSheetsJSON.t +++ b/t/CheatSheets/CheatSheetsJSON.t @@ -13,6 +13,7 @@ use IO::All; use List::Util qw(first none all any max); use YAML::XS qw(LoadFile); use File::Find::Rule; +use DDG::Meta::Data; my $json_dir = "share/goodie/cheat_sheets/json"; @@ -70,6 +71,15 @@ sub check_aliases_for_ignore { return %bad_aliases; } +sub verify_meta { + my $json = shift; + my @tests; + my $id = $json->{id}; + my $meta = DDG::Meta::Data->get_ia(id => $id); + push(@tests, {msg => "No Instant Answer page found with ID '$id'", critical => 1, pass => defined $meta}); + return @tests; +} + my @fnames = @ARGV ? map { "$_.json" } @ARGV : ("*.json"); my @test_paths = File::Find::Rule->file()->name(@fnames)->in($json_dir); @@ -254,6 +264,8 @@ foreach my $path (sort { cmp_base } @test_paths) { } } + push @tests, verify_meta($json); + PRINT_RESULTS: my $result = print_results($name, \@tests); From 6df517e87ac43ad3ccdfdcdbda375d9d4e545b74 Mon Sep 17 00:00:00 2001 From: Naveen Karippai Date: Sat, 14 May 2016 13:17:47 +0200 Subject: [PATCH 70/91] Convert RandomNumbers to full template goodie (#3014) * Convert RandomNumbers to full template --- lib/DDG/Goodie/RandomNumber.pm | 12 ++++-- t/RandomNumber.t | 71 ++++++++++++++-------------------- 2 files changed, 37 insertions(+), 46 deletions(-) diff --git a/lib/DDG/Goodie/RandomNumber.pm b/lib/DDG/Goodie/RandomNumber.pm index bbe7ad0a7..ea1347848 100644 --- a/lib/DDG/Goodie/RandomNumber.pm +++ b/lib/DDG/Goodie/RandomNumber.pm @@ -38,11 +38,15 @@ handle query_lc => sub { $rand = int($rand) + $start; } - return $rand . " (random number)", + return "$rand (random number)", structured_answer => { - input => [$start, $end], - operation => 'Random number between', - result => $rand + data => { + title => $rand, + subtitle => "Random number between $start - $end" + }, + templates => { + group => "text", + } }; }; diff --git a/t/RandomNumber.t b/t/RandomNumber.t index b73380d9e..39d0bfa87 100644 --- a/t/RandomNumber.t +++ b/t/RandomNumber.t @@ -3,53 +3,40 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'rand'; zci is_cached => 0; +sub build_structured_answer { + my ($number_one, $number_two, $response) = @_; + return re(qr/^$response \(random number\)$/), + structured_answer => { + data => { + title => re(qr/^$response$/), + subtitle => "Random number between $number_one - $number_two" + }, + templates => { + group => "text", + } + } +} + +sub build_test { + test_zci(build_structured_answer(@_)); +} + ddg_goodie_test( [qw( DDG::Goodie::RandomNumber )], - 'random number between 12 and 45' => test_zci( - qr/\d{2} \(random number\)/, - structured_answer => { - input => [12, 45], - operation => 'Random number between', - result => qr/^\d{2}$/ - } - ), - 'random number' => test_zci(qr/\d{1}\.\d+ \(random number\)/, - structured_answer => { - input => [0, 1], - operation => 'Random number between', - result => qr/\d{1}\.\d+/, - } - ), - 'random number between 0 and 1' => test_zci( - qr/\d{1} \(random number\)/, - structured_answer => { - input => [0, 1], - operation => 'Random number between', - result => qr/^\d{1}\.\d+$/ - } - ), - 'random number between 0 and 10' => test_zci( - qr/\d{1,2} \(random number\)/, - structured_answer => { - input => [0, 10], - operation => 'Random number between', - result => qr/^\d{1,2}$/ - } - ), - 'random number between 0 and 100' => test_zci( - qr/\d{1,3} \(random number\)/, - structured_answer => { - input => [0, 100], - operation => 'Random number between', - result => qr/^\d{1,3}$/ - } - ), - 'random day' => undef, - 'random access' => undef, + + 'random number between 12 and 45' => build_test(12, 45, qr/\d{2}/), + 'random number' => build_test(0, 1, qr/\d{1}\.\d+/), + 'random number between 0 and 1' => build_test(0, 1, qr/\d{1}\.\d+/), + 'random number between 0 and 10' => build_test(0, 10, qr/\d{1,2}/), + 'random number between 0 and 100' => build_test(0, 100, qr/\d{1,3}/), + 'random day' => undef, + 'random access' => undef ); -done_testing + +done_testing; From afcbf71591b7ee5733d964f796e19ff618ea00b5 Mon Sep 17 00:00:00 2001 From: nkarippai Date: Sat, 14 May 2016 12:24:38 +0000 Subject: [PATCH 71/91] Fix typo on css cheatsheet There was a typo on css cheatsheet and this should be fixed. See also: #2937 --- share/goodie/cheat_sheets/json/css.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/goodie/cheat_sheets/json/css.json b/share/goodie/cheat_sheets/json/css.json index e79903f4b..9402db08e 100644 --- a/share/goodie/cheat_sheets/json/css.json +++ b/share/goodie/cheat_sheets/json/css.json @@ -138,7 +138,7 @@ "val": "Specifies the type of positioning method used for an element", "key": "position:" }, { - "val": "Specifies the stack order of an elemen", + "val": "Specifies the stack order of an element", "key": "z-index:" }], "Background Properties": [{ From 289948173db6f88fbc842ff73f5fb1ea41b11a2a Mon Sep 17 00:00:00 2001 From: Roy Kokkelkoren Date: Sat, 14 May 2016 19:28:04 +0200 Subject: [PATCH 72/91] GreatestCommonFactor: Use Math::BigInt & change to text template (#2990) * Removed custom GCD function replaced with library function * Changed view to text template and updated tests * Cleanup of tests and removed unnecessary code --- lib/DDG/Goodie/GreatestCommonFactor.pm | 22 ++-- t/GreatestCommonFactor.t | 152 ++++++------------------- 2 files changed, 41 insertions(+), 133 deletions(-) diff --git a/lib/DDG/Goodie/GreatestCommonFactor.pm b/lib/DDG/Goodie/GreatestCommonFactor.pm index 329b07d01..9d2363ba6 100644 --- a/lib/DDG/Goodie/GreatestCommonFactor.pm +++ b/lib/DDG/Goodie/GreatestCommonFactor.pm @@ -3,6 +3,7 @@ package DDG::Goodie::GreatestCommonFactor; use strict; use DDG::Goodie; +use Math::BigInt try => 'GMP'; zci answer_type => "greatest_common_factor"; zci is_cached => 1; @@ -22,23 +23,18 @@ handle remainder => sub { my $formatted_numbers = join(', ', @numbers); $formatted_numbers =~ s/, ([^,]*)$/ and $1/; - my $result = shift @numbers; - foreach (@numbers) { - $result = gcf($result, $_) - } + my $result = Math::BigInt::bgcd(@numbers); return "Greatest common factor of $formatted_numbers is $result.", structured_answer => { - input => [$formatted_numbers], - operation => 'Greatest common factor', - result => $result + data => { + title => "$result", + subtitle => "Greatest common factor: $formatted_numbers" + }, + templates => { + group => "text", + } }; }; -sub gcf { - my ($x, $y) = @_; - ($x, $y) = ($y, $x % $y) while $y; - return $x; -} - 1; diff --git a/t/GreatestCommonFactor.t b/t/GreatestCommonFactor.t index f6f872317..2b94d5d40 100644 --- a/t/GreatestCommonFactor.t +++ b/t/GreatestCommonFactor.t @@ -8,128 +8,40 @@ use DDG::Test::Goodie; zci answer_type => "greatest_common_factor"; zci is_cached => 1; +# Build a structured answer that should match the response from the +# Perl file. +sub build_answer { + my ($numbers, $result) = @_; + + return "Greatest common factor of $numbers is $result.", + structured_answer => { + data => { + title => $result, + subtitle => "Greatest common factor: $numbers" + }, + templates => { + group => "text" + } + }; +} + ddg_goodie_test( [qw( DDG::Goodie::GreatestCommonFactor )], - 'gcf 9 81' => test_zci( - 'Greatest common factor of 9 and 81 is 9.', - structured_answer => { - input => ['9 and 81'], - operation => 'Greatest common factor', - result => 9 - } - ), - '1000 100 greatest common factor' => test_zci( - 'Greatest common factor of 100 and 1000 is 100.', - structured_answer => { - input => ['100 and 1000'], - operation => 'Greatest common factor', - result => 100 - } - ), - 'GCF 12 76' => test_zci( - 'Greatest common factor of 12 and 76 is 4.', - structured_answer => { - input => ['12 and 76'], - operation => 'Greatest common factor', - result => 4 - } - ), - 'GCF 121 11' => test_zci( - 'Greatest common factor of 11 and 121 is 11.', - structured_answer => { - input => ['11 and 121'], - operation => 'Greatest common factor', - result => 11 - } - ), - '99 9 greatest common factor' => test_zci( - 'Greatest common factor of 9 and 99 is 9.', - structured_answer => { - input => ['9 and 99'], - operation => 'Greatest common factor', - result => 9 - } - ), - 'greatest common divisor 4 6' => test_zci( - 'Greatest common factor of 4 and 6 is 2.', - structured_answer => { - input => ['4 and 6'], - operation => 'Greatest common factor', - result => 2 - } - ), - 'gcd 4 6' => test_zci( - 'Greatest common factor of 4 and 6 is 2.', - structured_answer => { - input => ['4 and 6'], - operation => 'Greatest common factor', - result => 2 - } - ), - 'gcd 2' => test_zci( - 'Greatest common factor of 2 is 2.', - structured_answer => { - input => ['2'], - operation => 'Greatest common factor', - result => 2 - } - ), - 'gcd 12 18 24' => test_zci( - 'Greatest common factor of 12, 18 and 24 is 6.', - structured_answer => { - input => ['12, 18 and 24'], - operation => 'Greatest common factor', - result => 6 - } - ), - 'gcd 25 20 15 10 5' => test_zci( - 'Greatest common factor of 5, 10, 15, 20 and 25 is 5.', - structured_answer => { - input => ['5, 10, 15, 20 and 25'], - operation => 'Greatest common factor', - result => 5 - } - ), - 'gcd 6, 9, ,,,, 12 15' => test_zci( - 'Greatest common factor of 6, 9, 12 and 15 is 3.', - structured_answer => { - input => ['6, 9, 12 and 15'], - operation => 'Greatest common factor', - result => 3 - } - ), - 'gcd 2 3' => test_zci( - 'Greatest common factor of 2 and 3 is 1.', - structured_answer => { - input => ['2 and 3'], - operation => 'Greatest common factor', - result => 1 - } - ), - 'gcd 2 3 5' => test_zci( - 'Greatest common factor of 2, 3 and 5 is 1.', - structured_answer => { - input => ['2, 3 and 5'], - operation => 'Greatest common factor', - result => 1 - } - ), - 'gcd 0 2' => test_zci( - 'Greatest common factor of 0 and 2 is 2.', - structured_answer => { - input => ['0 and 2'], - operation => 'Greatest common factor', - result => 2 - } - ), - 'gcd 0 0' => test_zci( - 'Greatest common factor of 0 and 0 is 0.', - structured_answer => { - input => ['0 and 0'], - operation => 'Greatest common factor', - result => 0 - } - ), + 'gcf 9 81' => test_zci(build_answer('9 and 81', 9)), + '1000 100 greatest common factor' => test_zci(build_answer('100 and 1000', 100)), + 'GCF 12 76' => test_zci(build_answer('12 and 76', 4)), + 'GCF 121 11' => test_zci(build_answer('11 and 121', 11)), + '99 9 greatest common factor' => test_zci(build_answer('9 and 99', 9)), + 'greatest common divisor 4 6' => test_zci(build_answer('4 and 6', 2)), + 'gcd 4 6' => test_zci(build_answer('4 and 6', 2)), + 'gcd 2' => test_zci(build_answer('2', 2)), + 'gcd 12 18 24' => test_zci(build_answer('12, 18 and 24', 6)), + 'gcd 25 20 15 10 5' => test_zci(build_answer('5, 10, 15, 20 and 25', 5)), + 'gcd 6, 9, ,,,, 12 15' => test_zci(build_answer('6, 9, 12 and 15', 3)), + 'gcd 2 3' => test_zci(build_answer('2 and 3', 1)), + 'gcd 2 3 5' => test_zci(build_answer('2, 3 and 5', 1)), + 'gcd 0 2' => test_zci(build_answer('0 and 2', 2)), + 'gcd 0 0' => test_zci(build_answer('0 and 0', 0)) ); done_testing; From e2717603772155c08bcb7ff9b84103c44e194e18 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Sat, 14 May 2016 18:42:58 +0100 Subject: [PATCH 73/91] GreatestCommonFactor: Update tests to use 'build_test' (#3048) * Update tests to use 'build_test' * Fix indenting --- t/GreatestCommonFactor.t | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/t/GreatestCommonFactor.t b/t/GreatestCommonFactor.t index 2b94d5d40..22c726c27 100644 --- a/t/GreatestCommonFactor.t +++ b/t/GreatestCommonFactor.t @@ -10,7 +10,7 @@ zci is_cached => 1; # Build a structured answer that should match the response from the # Perl file. -sub build_answer { +sub build_structured_answer { my ($numbers, $result) = @_; return "Greatest common factor of $numbers is $result.", @@ -25,23 +25,25 @@ sub build_answer { }; } +sub build_test { test_zci(build_structured_answer(@_)) } + ddg_goodie_test( [qw( DDG::Goodie::GreatestCommonFactor )], - 'gcf 9 81' => test_zci(build_answer('9 and 81', 9)), - '1000 100 greatest common factor' => test_zci(build_answer('100 and 1000', 100)), - 'GCF 12 76' => test_zci(build_answer('12 and 76', 4)), - 'GCF 121 11' => test_zci(build_answer('11 and 121', 11)), - '99 9 greatest common factor' => test_zci(build_answer('9 and 99', 9)), - 'greatest common divisor 4 6' => test_zci(build_answer('4 and 6', 2)), - 'gcd 4 6' => test_zci(build_answer('4 and 6', 2)), - 'gcd 2' => test_zci(build_answer('2', 2)), - 'gcd 12 18 24' => test_zci(build_answer('12, 18 and 24', 6)), - 'gcd 25 20 15 10 5' => test_zci(build_answer('5, 10, 15, 20 and 25', 5)), - 'gcd 6, 9, ,,,, 12 15' => test_zci(build_answer('6, 9, 12 and 15', 3)), - 'gcd 2 3' => test_zci(build_answer('2 and 3', 1)), - 'gcd 2 3 5' => test_zci(build_answer('2, 3 and 5', 1)), - 'gcd 0 2' => test_zci(build_answer('0 and 2', 2)), - 'gcd 0 0' => test_zci(build_answer('0 and 0', 0)) + 'gcf 9 81' => build_test('9 and 81', 9), + '1000 100 greatest common factor' => build_test('100 and 1000', 100), + 'GCF 12 76' => build_test('12 and 76', 4), + 'GCF 121 11' => build_test('11 and 121', 11), + '99 9 greatest common factor' => build_test('9 and 99', 9), + 'greatest common divisor 4 6' => build_test('4 and 6', 2), + 'gcd 4 6' => build_test('4 and 6', 2), + 'gcd 2' => build_test('2', 2), + 'gcd 12 18 24' => build_test('12, 18 and 24', 6), + 'gcd 25 20 15 10 5' => build_test('5, 10, 15, 20 and 25', 5), + 'gcd 6, 9, ,,,, 12 15' => build_test('6, 9, 12 and 15', 3), + 'gcd 2 3' => build_test('2 and 3', 1), + 'gcd 2 3 5' => build_test('2, 3 and 5', 1), + 'gcd 0 2' => build_test('0 and 2', 2), + 'gcd 0 0' => build_test('0 and 0', 0), ); done_testing; From af18492b8a88b9c513dfb3102c3f035a0e1feaf8 Mon Sep 17 00:00:00 2001 From: Naveen Karippai Date: Sat, 14 May 2016 20:00:12 +0200 Subject: [PATCH 74/91] Convert simple structured to full template goodie (#3000) * Convert simple structured to full template goodie Goodies have full support for templates, and it'd be great to make sure all Goodies use full templates. The "simple structured_answer" was provided as a way to get goodies using basic templates before they had full template support. * change to 'text' template for structured_answer object * refactored test suite * added alias and removed encode See also: Updates FlipText Goodie Re: #2767 IA: https://duck.co/ia/view/flip_text * Remove unnecessary trigger words on flipText goodie There were trigger words added to flipText goodie which may not be used or confuse the search results. This should be removed. * extra triggers removed See also: Updates FlipText Goodie Re: #2767 * Indent code on FlipText goodie It would be easier to eyes in the long run to understand code when it's properly indented. * code indented on .pm and .t --- lib/DDG/Goodie/FlipText.pm | 10 +++++-- t/FlipText.t | 57 +++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/lib/DDG/Goodie/FlipText.pm b/lib/DDG/Goodie/FlipText.pm index a3a4cd6c8..baeb543f3 100644 --- a/lib/DDG/Goodie/FlipText.pm +++ b/lib/DDG/Goodie/FlipText.pm @@ -20,9 +20,13 @@ handle remainder => sub { return $result, structured_answer => { - input => [html_enc($input)], - operation => 'Flip text', - result => html_enc($result), + data => { + title => $result, + subtitle => "Flip text $input" + }, + templates => { + group => 'text', + } }; }; diff --git a/t/FlipText.t b/t/FlipText.t index 1b251f5c1..b072035aa 100644 --- a/t/FlipText.t +++ b/t/FlipText.t @@ -9,40 +9,33 @@ use DDG::Test::Goodie; zci answer_type => 'flip_text'; zci is_cached => 1; +sub build_structured_answer{ + my ($input,$result) = @_; + return $result, + structured_answer => { + data => { + title => $result, + subtitle => "Flip text $input" + }, + templates => { + group => 'text', + } + } +} + +sub build_test{ test_zci(build_structured_answer(@_)) } + ddg_goodie_test( [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ǝʇ' - } - ), + 'flip text test' => build_test('test','ʇsǝʇ'), + 'mirror text test' => build_test('test','ʇsǝʇ'), + 'flip text my sentence' => build_test('my sentence','ǝɔuǝʇuǝs ʎɯ'), + 'mirror text text' => build_test('text','ʇxǝʇ'), + 'flip text ' => build_test('',''), + 'rotate text "hello world"' => build_test('"hello world"','„pʃɹoʍ oʃʃǝɥ„'), + 'spin text ;hello world;' => build_test(';hello world;','؛pʃɹoʍ oʃʃǝɥ؛'), + 'spin text [\'hello\']' => build_test('[\'hello\']','[,oʃʃǝɥ,]'), + 'spin text <<"hello\' % & * () = + . #@!^(/world">>' => build_test('<<"hello\' % & * () = + . #@!^(/world">>','<<„pʃɹoʍ/)∨¡@# ˙ + = () ⁎ ⅋ % ,oʃʃǝɥ„>>'), ); done_testing; From da3c7b26c72ab0bf209c6a4f9d6d269f2eed339c Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Sat, 14 May 2016 19:14:43 +0100 Subject: [PATCH 75/91] Fix test for real numbers (#3049) Wasn't allowing the case for numbers like `1.3e-7`. --- t/RandomNumber.t | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/RandomNumber.t b/t/RandomNumber.t index 39d0bfa87..8fe555c9f 100644 --- a/t/RandomNumber.t +++ b/t/RandomNumber.t @@ -5,6 +5,7 @@ use warnings; use Test::More; use Test::Deep; use DDG::Test::Goodie; +use Regexp::Common; zci answer_type => 'rand'; zci is_cached => 0; @@ -31,8 +32,8 @@ ddg_goodie_test( [qw( DDG::Goodie::RandomNumber )], 'random number between 12 and 45' => build_test(12, 45, qr/\d{2}/), - 'random number' => build_test(0, 1, qr/\d{1}\.\d+/), - 'random number between 0 and 1' => build_test(0, 1, qr/\d{1}\.\d+/), + 'random number' => build_test(0, 1, qr/$RE{num}{real}/), + 'random number between 0 and 1' => build_test(0, 1, qr/$RE{num}{real}/), 'random number between 0 and 10' => build_test(0, 10, qr/\d{1,2}/), 'random number between 0 and 100' => build_test(0, 100, qr/\d{1,3}/), 'random day' => undef, From 3bf7aa07311592a2763927a97b6be49fd94bbf77 Mon Sep 17 00:00:00 2001 From: Pawan Pal Date: Sat, 14 May 2016 23:48:01 +0530 Subject: [PATCH 76/91] New youtube-dl cheat sheet (#2465) * added youtube-dl cheat sheet * edit name, alias and indentation * edit source name --- share/goodie/cheat_sheets/json/youtubedl.json | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 share/goodie/cheat_sheets/json/youtubedl.json diff --git a/share/goodie/cheat_sheets/json/youtubedl.json b/share/goodie/cheat_sheets/json/youtubedl.json new file mode 100644 index 000000000..7468b6ecf --- /dev/null +++ b/share/goodie/cheat_sheets/json/youtubedl.json @@ -0,0 +1,110 @@ +{ + "id": "youtubedl_cheat_sheet", + "name": "Youtube-dl", + "description": "Small command-line program to download videos from YouTube.com and other video sites", + + "metadata": { + "sourceName": "Github", + "sourceUrl": "https://github.com/rg3/youtube-dl/blob/master/README.md#readme" + }, + + "aliases": [ + "youtube-dl", "youtube dl" + ], + + "template_type": "terminal", + + "section_order": [ + "Network Options", + "Video Selection", + "Download Options", + "Filesystem Options", + "Video Format Options" + ], + + "sections": { + "Network Options": [{ + "key": "--proxy URL", + "val": "Use the specified HTTP/HTTPS proxy. Pass in an empty string (--proxy ) for direct connection" + }, { + "key": "-4, --force-ipv4", + "val": " Make all connections via IPv4" + }, { + "key": "-6, --force-ipv6", + "val": " Make all connections via IPv6" + }, { + "key": "--source-address IP ", + "val": "Client-side IP address to bind to" + }], + "Video Selection": [{ + "key": "--playlist-start NUMBER", + "val": "Playlist video to start at (default is 1)" + }, { + "key": "--playlist-end NUMBER", + "val": "Playlist video to end at (default is last)" + }, { + "key": "--max-downloads NUMBER", + "val": "Abort after downloading NUMBER files" + }, { + "key": "--include-ads", + "val": "Download advertisements as well" + }, { + "key": "--yes-playlist", + "val": "Download the playlist, if the URL refers to a video and a playlist" + }], + "Download Options": [{ + "key": "-r, --rate-limit LIMIT", + "val": "Maximum download rate in bytes per second" + }, { + "key": "-R, --retries RETRIES", + "val": "Number of retries (default is 10), or infinite" + }, { + "key": "--buffer-size SIZE", + "val": "Size of download buffer (e.g. 1024 or 16K)" + }, { + "key": "--external-downloader COMMAND", + "val": "Use the specified external downloader Currently supports" + }, { + "key": "--external-downloader-args ARGS", + "val": "Give these arguments to the external downloader" + }], + "Filesystem Options": [{ + "key": "-a, --batch-file FILE", + "val": "File containing URLs to download" + }, { + "key": "--id", + "val": "Use only video ID in file name" + }, { + "key": "--autonumber-size NUMBER", + "val": "Specify the number of digits in %(autonumber)s when it is present in output filename template or --auto-number option is given" + }, { + "key": "-c, --continue", + "val": "Force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible." + }, { + "key": "--no-continue", + "val": "Do not resume partially downloaded files" + }, { + "key": "--cookies FILE", + "val": "File to read cookies from and dump cookie jar in" + }], + "Video Format Options": [{ + "key": "-f, --format FORMAT", + "val": "Video format code, see the FORMAT SELECTION for all the info" + }, { + "key": "--all-formats", + "val": "Download all available video formats" + }, { + "key": "--prefer-free-formats", + "val": "Prefer free video formats unless a specific one is requested" + }, { + "key": "-F, --list-formats", + "val": "List all available formats of requested videos" + }, { + "key": "--youtube-skip-dash-manifest", + "val": "Do not download the DASH manifests and related data on YouTube videos" + }, { + "key": "--merge-output-format FORMAT", + "val": "If a merge is required (e.g. bestvideo+bestaudio), output to given container format. One of mkv, mp4, ogg, webm, flv. Ignored if no merge is required" + }] + } +} \ No newline at end of file From e3ee63998ca388e255e89ef4558037b8c92ce1ac Mon Sep 17 00:00:00 2001 From: Sebastian Weddmark Olsson Date: Sat, 14 May 2016 20:23:50 +0200 Subject: [PATCH 77/91] Add f/1 to shell commands (#2962) --- share/goodie/cheat_sheets/json/erlang.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/goodie/cheat_sheets/json/erlang.json b/share/goodie/cheat_sheets/json/erlang.json index 30d54450f..e1a022030 100644 --- a/share/goodie/cheat_sheets/json/erlang.json +++ b/share/goodie/cheat_sheets/json/erlang.json @@ -120,6 +120,9 @@ }, { "val": "repeat the expression in query ", "key": "e(N)." + }, { + "val": "forget variable binding ", + "key": "f(N)." }, { "val": "forget all variable bindings", "key": "f()." From 4abd29f5f971b40e32a56f0113632c0bbd0adba3 Mon Sep 17 00:00:00 2001 From: Pawan Pal Date: Sun, 15 May 2016 00:27:41 +0530 Subject: [PATCH 78/91] New wget Cheat sheet (#2471) * Added wget Cheat sheet --- share/goodie/cheat_sheets/json/wget.json | 61 ++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 share/goodie/cheat_sheets/json/wget.json diff --git a/share/goodie/cheat_sheets/json/wget.json b/share/goodie/cheat_sheets/json/wget.json new file mode 100644 index 000000000..97ad65566 --- /dev/null +++ b/share/goodie/cheat_sheets/json/wget.json @@ -0,0 +1,61 @@ +{ + "id": "wget_cheat_sheet", + "name": "Wget", + "description": "A computer program that retrieves content from web servers via HTTP, HTTPS, and FTP protocols", + + "metadata": { + "sourceName": "GNU", + "sourceUrl" : "https://www.gnu.org/manual/manual.html" + }, + + "aliases": [ + "gnu wget" + ], + + "template_type": "terminal", + + "section_order": [ + "Useful Commands" + ], + + "sections": { + "Useful Commands": [ + { + "key": "wget ", + "val": "Download single file and stores in a current directory" + }, + { + "key": "-O (uppercase)", + "val": "Download file with different name" + }, + { + "key": "http:// , ftp://", + "val": "Download multiple file with http and ftp protocol" + }, + { + "key": "wget -i /wget/tmp.txt", + "val": "Read URL’s from a file" + }, + { + "key": "wget -c", + "val": "Resume uncompleted download" + }, + { + "key": "wget -b", + "val": "Download files in background" + }, + { + "key": "wget -c --limit-rate=100k", + "val": "Restrict download speed limits" + }, + { + "key": "wget --http-user=narad --http-password=password", + "val": "Restricted FTP and HTTP downloads with username and password" + }, + { + "key": "wget --version", + "val": "Find wget version" + } + ] + } +} From ad089234aeb1fa4c2e57a4bd0ea492e1b5befaa8 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sat, 14 May 2016 22:44:23 +0100 Subject: [PATCH 79/91] Titlecase: Converting to text template (#3056) --- lib/DDG/Goodie/TitleCase.pm | 15 ++++---- t/TitleCase.t | 69 +++++++++++-------------------------- 2 files changed, 30 insertions(+), 54 deletions(-) mode change 100644 => 100755 lib/DDG/Goodie/TitleCase.pm mode change 100644 => 100755 t/TitleCase.t diff --git a/lib/DDG/Goodie/TitleCase.pm b/lib/DDG/Goodie/TitleCase.pm old mode 100644 new mode 100755 index cf4835515..b2986a510 --- a/lib/DDG/Goodie/TitleCase.pm +++ b/lib/DDG/Goodie/TitleCase.pm @@ -29,12 +29,15 @@ handle remainder => sub { } @words ); - return $title_case, - structured_answer => { - input => [html_enc($input)], - operation => 'Title case', - result => html_enc($title_case), - }; + return $title_case, structured_answer => { + data => { + title => html_enc($title_case), + subtitle => 'Title case: '.html_enc($input) + }, + templates => { + group => 'text' + } + }; }; 1; diff --git a/t/TitleCase.t b/t/TitleCase.t old mode 100644 new mode 100755 index e355371c5..6de5bd04f --- a/t/TitleCase.t +++ b/t/TitleCase.t @@ -8,56 +8,29 @@ use DDG::Test::Goodie; zci answer_type => 'title_case'; zci is_cached => 1; +sub build_test +{ + my ($text, $input) = @_; + + return test_zci($text, structured_answer => { + data => { + title => $text, + subtitle => 'Title case: '.$input + }, + templates => { + group => 'text' + } + }); +} + ddg_goodie_test( [qw( DDG::Goodie::TitleCase)], - 'titlecase test this out' => test_zci( - 'Test This Out', - structured_answer => { - input => ['test this out'], - operation => 'Title case', - result => 'Test This Out' - }, - ), - 'titlecase this is a walk in the park' => test_zci( - 'This Is a Walk in the Park', - structured_answer => { - input => ['this is a walk in the park'], - operation => 'Title case', - result => 'This Is a Walk in the Park' - }, - ), - 'titlecase a good day to die hard' => test_zci( - 'A Good Day to Die Hard', - structured_answer => { - input => ['a good day to die hard'], - operation => 'Title case', - result => 'A Good Day to Die Hard' - }, - ), - 'titlecase A GOOD DAY TO DIE HARD' => test_zci( - 'A Good Day to Die Hard', - structured_answer => { - input => ['A GOOD DAY TO DIE HARD'], - operation => 'Title case', - result => 'A Good Day to Die Hard' - }, - ), - 'titlecase here i am testing-hyphenated-words' => test_zci( - 'Here I Am Testing-Hyphenated-Words', - structured_answer => { - input => ['here i am testing-hyphenated-words'], - operation => 'Title case', - result => 'Here I Am Testing-Hyphenated-Words' - }, - ), - 'titlecase test' => test_zci( - 'Test', - structured_answer => { - input => ['test'], - operation => 'Title case', - result => 'Test' - }, - ), + 'titlecase test this out' => build_test('Test This Out', 'test this out'), + 'titlecase this is a walk in the park' => build_test('This Is a Walk in the Park', 'this is a walk in the park'), + 'titlecase a good day to die hard' => build_test('A Good Day to Die Hard', 'a good day to die hard'), + 'titlecase A GOOD DAY TO DIE HARD' => build_test('A Good Day to Die Hard', 'A GOOD DAY TO DIE HARD'), + 'titlecase here i am testing-hyphenated-words' => build_test('Here I Am Testing-Hyphenated-Words', 'here i am testing-hyphenated-words'), + 'titlecase test' => build_test('Test', 'test'), 'how do i make something titlecase' => undef, ); From 6a2fdedbf6c32cf6ac70c34c07cc504cd52187b5 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sat, 14 May 2016 22:46:41 +0100 Subject: [PATCH 80/91] Lowercase: Flipping out to Text template (#3055) * Lowercase: Flipping out to Text template --- lib/DDG/Goodie/Lowercase.pm | 15 +++++--- t/Lowercase.t | 77 ++++++++++--------------------------- 2 files changed, 30 insertions(+), 62 deletions(-) mode change 100644 => 100755 lib/DDG/Goodie/Lowercase.pm mode change 100644 => 100755 t/Lowercase.t diff --git a/lib/DDG/Goodie/Lowercase.pm b/lib/DDG/Goodie/Lowercase.pm old mode 100644 new mode 100755 index e9594dd32..7b50aa97e --- a/lib/DDG/Goodie/Lowercase.pm +++ b/lib/DDG/Goodie/Lowercase.pm @@ -18,12 +18,15 @@ handle remainder => sub { return if ($lower eq $input); - return $lower, - structured_answer => { - input => [html_enc($input)], - operation => 'Lowercase', - result => html_enc($lower) - }; + return $lower, structured_answer => { + data => { + title => html_enc($lower), + subtitle => "Lowercase: " . html_enc($input) + }, + templates => { + group => 'text', + } + }; }; 1; diff --git a/t/Lowercase.t b/t/Lowercase.t old mode 100644 new mode 100755 index d35c277b6..8b8894d64 --- a/t/Lowercase.t +++ b/t/Lowercase.t @@ -9,67 +9,32 @@ use DDG::Test::Goodie; zci answer_type => 'lowercase'; zci is_cached => 1; +sub build_test +{ + my ($text, $subtitle) = @_; + return test_zci($text, structured_answer => { + data => { + title => $text, + subtitle => "Lowercase: $subtitle" + }, + templates => { + group => 'text' + } + }); +} + ddg_goodie_test( ['DDG::Goodie::Lowercase'], 'lowercase foo' => undef, 'lowercase 123' => undef, 'lower case foo123' => undef, - 'lower case foO' => test_zci( - 'foo', - structured_answer => { - input => ['foO'], - operation => 'Lowercase', - result => 'foo' - }, - ), - 'lowercase john Doe' => test_zci( - 'john doe', - structured_answer => { - input => ['john Doe'], - operation => 'Lowercase', - result => 'john doe' - }, - ), - 'lowercase GitHub' => test_zci( - 'github', - structured_answer => { - input => ['GitHub'], - operation => 'Lowercase', - result => 'github' - }, - ), - 'lower case GitHub' => test_zci( - 'github', - structured_answer => { - input => ['GitHub'], - operation => 'Lowercase', - result => 'github' - }, - ), - 'lc GitHub' => test_zci( - 'github', - structured_answer => { - input => ['GitHub'], - operation => 'Lowercase', - result => 'github' - }, - ), - 'strtolower GitHub' => test_zci( - 'github', - structured_answer => { - input => ['GitHub'], - operation => 'Lowercase', - result => 'github' - }, - ), - 'tolower GitHub' => test_zci( - 'github', - structured_answer => { - input => ['GitHub'], - operation => 'Lowercase', - result => 'github' - }, - ), + 'lower case foO' => build_test('foo', 'foO'), + 'lowercase john Doe' => build_test('john doe', 'john Doe'), + 'lowercase GitHub' => build_test('github', 'GitHub'), + 'lower case GitHub' => build_test('github', 'GitHub'), + 'lc GitHub' => build_test('github', 'GitHub'), + 'strtolower GitHub' => build_test('github', 'GitHub'), + 'tolower GitHub' => build_test('github', 'GitHub'), 'how to lowercase text' => undef ); From 0e438ddc085be851c7c59bbf83c0ad6c01be8a53 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sat, 14 May 2016 22:52:17 +0100 Subject: [PATCH 81/91] Uppercase: Converting to text template (#3057) --- lib/DDG/Goodie/Uppercase.pm | 15 ++++++++------ t/Uppercase.t | 41 +++++++++++++++---------------------- 2 files changed, 26 insertions(+), 30 deletions(-) mode change 100644 => 100755 lib/DDG/Goodie/Uppercase.pm mode change 100644 => 100755 t/Uppercase.t diff --git a/lib/DDG/Goodie/Uppercase.pm b/lib/DDG/Goodie/Uppercase.pm old mode 100644 new mode 100755 index 1bd383eac..27478dbf2 --- a/lib/DDG/Goodie/Uppercase.pm +++ b/lib/DDG/Goodie/Uppercase.pm @@ -20,12 +20,15 @@ handle remainder => sub { my $upper = uc $input; - return $upper, - structured_answer => { - input => [html_enc($input)], - operation => 'Uppercase', - result => html_enc($upper), - }; + return $upper, structured_answer => { + data => { + title => html_enc($upper), + subtitle => "Uppercase: ".html_enc($input) + }, + templates => { + group => 'text' + } + }; }; 1; diff --git a/t/Uppercase.t b/t/Uppercase.t old mode 100644 new mode 100755 index 149d33d59..114e04777 --- a/t/Uppercase.t +++ b/t/Uppercase.t @@ -8,32 +8,25 @@ use DDG::Test::Goodie; zci answer_type => 'uppercase'; zci is_cached => 1; +sub build_test +{ + my ($text, $subtitle) = @_; + return test_zci($text, structured_answer => { + data => { + title => $text, + subtitle => "Uppercase: $subtitle" + }, + templates => { + group => 'text' + } + }); +} + ddg_goodie_test( [qw( DDG::Goodie::Uppercase)], - 'upper case this' => test_zci( - 'THIS', - structured_answer => { - input => ['this'], - operation => 'Uppercase', - result => 'THIS' - } - ), - 'uppercase that' => test_zci( - 'THAT', - structured_answer => { - input => ['that'], - operation => 'Uppercase', - result => 'THAT' - } - ), - 'allcaps this string' => test_zci( - 'THIS STRING', - structured_answer => { - input => ['this string'], - operation => 'Uppercase', - result => 'THIS STRING' - } - ), + 'upper case this' => build_test('THIS', 'this'), + 'uppercase that' => build_test('THAT', 'that'), + 'allcaps this string' => build_test('THIS STRING','this string'), 'that string all caps' => undef, 'is this uppercase, sir?' => undef, 'uppercase HELLO' => undef, From 707350bf90303ed46aa71dcaad6f6e83cc5c3b57 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sat, 14 May 2016 23:04:54 +0100 Subject: [PATCH 82/91] Combination: Switching to text template (#3058) --- lib/DDG/Goodie/Combination.pm | 13 +++++--- t/Combination.t | 63 ++++++++++++----------------------- 2 files changed, 29 insertions(+), 47 deletions(-) mode change 100644 => 100755 lib/DDG/Goodie/Combination.pm mode change 100644 => 100755 t/Combination.t diff --git a/lib/DDG/Goodie/Combination.pm b/lib/DDG/Goodie/Combination.pm old mode 100644 new mode 100755 index 4999ddd2c..0e248f28c --- a/lib/DDG/Goodie/Combination.pm +++ b/lib/DDG/Goodie/Combination.pm @@ -51,11 +51,14 @@ handle query => sub { my $formatted_result = $style->for_display($result); - return $formatted_result, - structured_answer => { - input => [$style->for_display($n) . " $operation " . $style->for_display($k)], - operation => 'Calculate', - result => $formatted_result, + return $formatted_result, structured_answer => { + data => { + title => $formatted_result, + subtitle => $style->for_display($n) . " $operation " . $style->for_display($k) + }, + templates => { + group => 'text' + } }; }; diff --git a/t/Combination.t b/t/Combination.t old mode 100644 new mode 100755 index 36e31e79e..6c3a2a711 --- a/t/Combination.t +++ b/t/Combination.t @@ -8,50 +8,29 @@ use DDG::Test::Goodie; zci answer_type => "combination"; zci is_cached => 1; +sub build_test +{ + my ($answer, $question) = @_; + return test_zci( + $answer, structured_answer => { + data => { + title => $answer, + subtitle => $question + }, + templates => { + group => 'text' + } + } + ); +} ddg_goodie_test( [qw( DDG::Goodie::Combination )], - '10 choose 3' => test_zci('120', - structured_answer => { - input => ['10 choose 3'], - operation => 'Calculate', - result => '120', - } - ), - '10 nCr 3' => test_zci('120', - structured_answer => { - input => ['10 choose 3'], - operation => 'Calculate', - result => '120', - } - ), - '25 permute 16' => test_zci('4.27447366714368 * 10^19', - structured_answer => { - input => ['25 permute 16'], - operation => 'Calculate', - result => '4.27447366714368 * 10^19' - } - ), - '16 permutation 3' => test_zci('3,360', - structured_answer => { - input => ['16 permute 3'], - operation => 'Calculate', - result => '3,360' - } - ), - '15 permutation 0' => test_zci('1', - structured_answer => { - input => ['15 permute 0'], - operation => 'Calculate', - result => '1' - } - ), - '1,000 choose 2' => test_zci('499,500', - structured_answer => { - input => ['1,000 choose 2'], - operation => 'Calculate', - result => '499,500' - } - ), + '10 choose 3' => build_test('120', '10 choose 3'), + '10 nCr 3' => build_test('120', '10 choose 3'), + '25 permute 16' => build_test('4.27447366714368 * 10^19', '25 permute 16'), + '16 permutation 3' => build_test('3,360', '16 permute 3'), + '15 permutation 0' => build_test('1', '15 permute 0'), + '1,000 choose 2' => build_test('499,500', '1,000 choose 2'), '0 choose 100' => undef, '10 choose 100' => undef, '10.5 choose 1' => undef, From 348df8e52654acb88f8d8ea68bb41cb91f857617 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sat, 14 May 2016 23:32:11 +0100 Subject: [PATCH 83/91] POTUS: Flipping out to text template (#3053) * POTUS: Flipping out to text template * POTUS: Tests should be calling `build_test` :) * POTUS: Test refactor --- lib/DDG/Goodie/POTUS.pm | 15 +++--- t/POTUS.t | 108 ++++++++++------------------------------ 2 files changed, 36 insertions(+), 87 deletions(-) mode change 100644 => 100755 lib/DDG/Goodie/POTUS.pm mode change 100644 => 100755 t/POTUS.t diff --git a/lib/DDG/Goodie/POTUS.pm b/lib/DDG/Goodie/POTUS.pm old mode 100644 new mode 100755 index 73a295c91..847e134f5 --- a/lib/DDG/Goodie/POTUS.pm +++ b/lib/DDG/Goodie/POTUS.pm @@ -37,12 +37,15 @@ handle remainder => sub { my $the_guy = $presidents[$index]; my $which = ordinate($num); - return "$the_guy $fact $which $POTUS.", - structured_answer => { - input => [$which], - operation => $POTUS, - result => $the_guy, - }; + return "$the_guy $fact $which $POTUS.", structured_answer => { + data => { + title => $the_guy, + subtitle => "$which $POTUS", + }, + templates => { + group => 'text' + } + }; }; 1; diff --git a/t/POTUS.t b/t/POTUS.t old mode 100644 new mode 100755 index 1b490583e..9b4ac77b5 --- a/t/POTUS.t +++ b/t/POTUS.t @@ -8,90 +8,36 @@ use DDG::Test::Goodie; zci answer_type => 'potus'; zci is_cached => 1; +sub build_test +{ + my ($who, $article, $number) = @_; + + return test_zci("$who $article the $number President of the United States.", structured_answer => { + data => { + title => $who, + subtitle => "$number President of the United States" + }, + templates => { + group => 'text' + } + }); +} + ddg_goodie_test( [qw( DDG::Goodie::POTUS)], - 'who is president of the united states' => test_zci( - 'Barack Obama is the 44th President of the United States.', - structured_answer => { - input => ['44th'], - operation => 'President of the United States', - result => 'Barack Obama' - } - ), - 'who is the fourth president of the united states' => test_zci( - 'James Madison was the 4th President of the United States.', - structured_answer => { - input => ['4th'], - operation => 'President of the United States', - result => 'James Madison' - } - ), - 'who is the nineteenth president of the united states' => test_zci( - 'Rutherford B. Hayes was the 19th President of the United States.', - structured_answer => { - input => ['19th'], - operation => 'President of the United States', - result => 'Rutherford B. Hayes' - } - ), - 'who was the 1st president of the united states' => test_zci( - 'George Washington was the 1st President of the United States.', - structured_answer => { - input => ['1st'], - operation => 'President of the United States', - result => 'George Washington' - } - ), - 'who was the 31 president of the united states' => test_zci( - 'Herbert Hoover was the 31st President of the United States.', - structured_answer => { - input => ['31st'], - operation => 'President of the United States', - result => 'Herbert Hoover' - } - ), - 'who was the 22 president of the united states' => test_zci( - 'Grover Cleveland was the 22nd President of the United States.', - structured_answer => { - input => ['22nd'], - operation => 'President of the United States', - result => 'Grover Cleveland' - } - ), - 'potus 11' => test_zci( - 'James K. Polk was the 11th President of the United States.', - structured_answer => { - input => ['11th'], - operation => 'President of the United States', - result => 'James K. Polk' - } - ), - 'POTUS 24' => test_zci( - 'Grover Cleveland was the 24th President of the United States.', - structured_answer => { - input => ['24th'], - operation => 'President of the United States', - result => 'Grover Cleveland' - } - ), - 'who was the twenty-second POTUS?' => test_zci( - 'Grover Cleveland was the 22nd President of the United States.', - structured_answer => { - input => ['22nd'], - operation => 'President of the United States', - result => 'Grover Cleveland' - } - ), - 'potus 16' => test_zci( - 'Abraham Lincoln was the 16th President of the United States.', - structured_answer => { - input => ['16th'], - operation => 'President of the United States', - result => 'Abraham Lincoln' - } - ), + 'who is president of the united states' => build_test('Barack Obama', 'is',"44th"), + 'who is the fourth president of the united states' => build_test('James Madison', 'was', '4th'), + 'who is the nineteenth president of the united states' => build_test('Rutherford B. Hayes', 'was','19th'), + 'who was the 1st president of the united states' => build_test('George Washington', 'was', '1st'), + 'who was the 31 president of the united states' => build_test('Herbert Hoover', 'was', '31st'), + 'who was the 22 president of the united states' => build_test('Grover Cleveland', 'was','22nd'), + 'potus 11' => build_test('James K. Polk', 'was','11th'), + 'POTUS 24' => build_test('Grover Cleveland', 'was', '24th'), + 'who was the twenty-second POTUS?' => build_test('Grover Cleveland', 'was', '22nd'), + 'potus 16' => build_test('Abraham Lincoln', 'was', '16th'), 'who is the vice president of the united states?' => undef, - 'vice president of the united states' => undef + 'vice president of the united states' => undef, + 'VPOTUS' => undef ); done_testing; From 0cc555fe1b9bc5d26215e781e654f92055852cbf Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 15 May 2016 17:13:24 +0100 Subject: [PATCH 84/91] HexToDec: Convert to text template (#3054) * HexToDec: Converting to text template * HexToDec: Refactoring tests --- lib/DDG/Goodie/HexToDec.pm | 12 +++-- t/HexToDec.t | 91 +++++++++++++------------------------- 2 files changed, 39 insertions(+), 64 deletions(-) mode change 100644 => 100755 lib/DDG/Goodie/HexToDec.pm mode change 100644 => 100755 t/HexToDec.t diff --git a/lib/DDG/Goodie/HexToDec.pm b/lib/DDG/Goodie/HexToDec.pm old mode 100644 new mode 100755 index b28edf5c8..7ae59b633 --- a/lib/DDG/Goodie/HexToDec.pm +++ b/lib/DDG/Goodie/HexToDec.pm @@ -17,10 +17,14 @@ handle query_raw => sub { my $decimal = Math::BigInt->from_hex($hex); return "$hex base 16 = $decimal base 10", structured_answer => { - input => ['0x' . $hex], - operation => 'Hex to decimal', - result => "$decimal", # Quoted for display precision as string. + data => { + title => "$decimal", # Quoted for display precision as string. + subtitle => "Hex to decimal: 0x" . $hex + }, + templates => { + group => 'text', + } }; }; -0x41414141; +0x01; diff --git a/t/HexToDec.t b/t/HexToDec.t old mode 100644 new mode 100755 index f40ca41db..cf430da76 --- a/t/HexToDec.t +++ b/t/HexToDec.t @@ -8,72 +8,43 @@ use DDG::Test::Goodie; zci answer_type => 'hex_to_dec'; zci is_cached => 1; +sub build_test +{ + my ($text, $title, $subtitle) = @_; + + return test_zci($text, structured_answer => { + data => { + title => $title, + subtitle => "Hex to decimal: $subtitle" + }, + templates => { + group => 'text' + } + }); +} + ddg_goodie_test( [qw( DDG::Goodie::HexToDec )], - '0xd1038d2e07b42569' => test_zci( + '0xd1038d2e07b42569' => build_test( 'd1038d2e07b42569 base 16 = 15061036807694329193 base 10', - structured_answer => { - input => ['0xd1038d2e07b42569'], - operation => 'Hex to decimal', - result => 15061036807694329193 - } + 15061036807694329193, + '0xd1038d2e07b42569' ), - '0x44696f21' => test_zci( - '44696f21 base 16 = 1147760417 base 10', - structured_answer => { - input => ['0x44696f21'], - operation => 'Hex to decimal', - result => 1147760417, - } + '0x44696f21' => build_test( + '44696f21 base 16 = 1147760417 base 10', + 1147760417, + '0x44696f21' ), - '0xffffffffffffffffffffff' => test_zci( - 'ffffffffffffffffffffff base 16 = 309485009821345068724781055 base 10', - structured_answer => { - input => ['0xffffffffffffffffffffff'], - operation => 'Hex to decimal', - result => "309485009821345068724781055", - } - ), - '0xff in decimal' => test_zci( - 'ff base 16 = 255 base 10', - structured_answer => { - input => ['0xff'], - operation => 'Hex to decimal', - result => "255", - } - ), - '0xff hex to dec' => test_zci( - 'ff base 16 = 255 base 10', - structured_answer => { - input => ['0xff'], - operation => 'Hex to decimal', - result => "255", - } - ), - '0xff as base 10' => test_zci( - 'ff base 16 = 255 base 10', - structured_answer => { - input => ['0xff'], - operation => 'Hex to decimal', - result => "255", - } - ), - '0xff in base-10' => test_zci( - 'ff base 16 = 255 base 10', - structured_answer => { - input => ['0xff'], - operation => 'Hex to decimal', - result => "255", - } - ), - '0xff hex to base10' => test_zci( - 'ff base 16 = 255 base 10', - structured_answer => { - input => ['0xff'], - operation => 'Hex to decimal', - result => "255", - } + '0xffffffffffffffffffffff' => build_test( + 'ffffffffffffffffffffff base 16 = 309485009821345068724781055 base 10', + "309485009821345068724781055", + '0xffffffffffffffffffffff' ), + '0xff in decimal' => build_test('ff base 16 = 255 base 10', "255", '0xff'), + '0xff hex to dec' => build_test('ff base 16 = 255 base 10', "255", '0xff'), + '0xff as base 10' => build_test('ff base 16 = 255 base 10', "255", '0xff'), + '0xff in base-10' => build_test('ff base 16 = 255 base 10', "255", '0xff'), + '0xff hex to base10' => build_test('ff base 16 = 255 base 10', "255", '0xff'), '0x44696f2Z' => undef, 'ascii 0x74657374' => undef, '0x255 hex' => undef, From fb88949c4446ef5da9cd4e260ea7c82c4f6e9499 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 15 May 2016 18:12:51 +0100 Subject: [PATCH 85/91] GenerateMAC: Switching tests to Test::Deep and text template --- t/GenerateMAC.t | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) mode change 100644 => 100755 t/GenerateMAC.t diff --git a/t/GenerateMAC.t b/t/GenerateMAC.t old mode 100644 new mode 100755 index a6e6c351a..2eaf3549d --- a/t/GenerateMAC.t +++ b/t/GenerateMAC.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "MAC Address"; @@ -11,22 +12,27 @@ zci is_cached => 0; my $mac_regxp = "([0-9A-F]{2}[:-]){5}([0-9A-F]{2})"; my $text_start = "Here's a random MAC address: "; -my @answer = ( - qr/^$text_start$mac_regxp$/, - structured_answer => { - input => [], - operation => 'Random MAC address', - result => qr/$mac_regxp/ +sub build_test +{ + return test_zci(qr/^$text_start$mac_regxp$/, structured_answer => { + data => { + title => re($mac_regxp), + subtitle => "Random MAC Address" + }, + templates => { + group => 'text' + } }); +} #regexp from http://stackoverflow.com/questions/4260467/what-is-a-regular-expression-for-a-mac-address ddg_goodie_test( ['DDG::Goodie::GenerateMAC'], - 'generate mac address' => test_zci(@answer), - 'generate mac addr' => test_zci(@answer), - 'random mac address' => test_zci(@answer), - 'random mac addr' => test_zci(@answer), - 'please generate mac address' => test_zci(@answer), + 'generate mac address' => build_test(), + 'generate mac addr' => build_test(), + 'random mac address' => build_test(), + 'random mac addr' => build_test(), + 'please generate mac address' => build_test(), ); done_testing; From 49e0d7b186f50a180ae1a581bd335d95516380c0 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 15 May 2016 18:13:12 +0100 Subject: [PATCH 86/91] GenerateMAC: Switching implementation to text template --- lib/DDG/Goodie/GenerateMAC.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) mode change 100644 => 100755 lib/DDG/Goodie/GenerateMAC.pm diff --git a/lib/DDG/Goodie/GenerateMAC.pm b/lib/DDG/Goodie/GenerateMAC.pm old mode 100644 new mode 100755 index b73c8559c..c621911a9 --- a/lib/DDG/Goodie/GenerateMAC.pm +++ b/lib/DDG/Goodie/GenerateMAC.pm @@ -20,12 +20,15 @@ handle remainder => sub { my $address = join(':', map { sprintf '%0.2X', rand(255) } (1 .. 6)); - return "Here's a random MAC address: $address", - structured_answer => { - input => [], - operation => 'Random MAC address', - result => $address - }; + return "Here's a random MAC address: $address", structured_answer => { + data => { + title => $address, + subtitle => 'Random MAC Address' + }, + templates => { + group => 'text' + } + }; }; 1; From 3349534b76acbf9cdaa0d0b1d7bcd2e23f6ef16a Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 15 May 2016 18:38:30 +0100 Subject: [PATCH 87/91] Factors: Convert to text template (#3061) --- lib/DDG/Goodie/Factors.pm | 15 +++++++----- t/Factors.t | 50 ++++++++++++++------------------------- 2 files changed, 27 insertions(+), 38 deletions(-) mode change 100644 => 100755 lib/DDG/Goodie/Factors.pm mode change 100644 => 100755 t/Factors.t diff --git a/lib/DDG/Goodie/Factors.pm b/lib/DDG/Goodie/Factors.pm old mode 100644 new mode 100755 index 9b7e13415..66b6a7b6d --- a/lib/DDG/Goodie/Factors.pm +++ b/lib/DDG/Goodie/Factors.pm @@ -17,12 +17,15 @@ handle remainder => sub { my $factors = join ', ', divisors($query); - return "Factors of $query: $factors", - structured_answer => { - input => [$query], - operation => 'Factors', - result => $factors - }; + return "Factors of $query: $factors", structured_answer => { + data => { + title => $factors, + subtitle => "Factors of: $query" + }, + templates => { + group => 'text' + } + }; }; 1; diff --git a/t/Factors.t b/t/Factors.t old mode 100644 new mode 100755 index ddd11f206..6d51457b0 --- a/t/Factors.t +++ b/t/Factors.t @@ -8,40 +8,26 @@ use DDG::Test::Goodie; zci answer_type => "factors"; zci is_cached => 1; +sub build_test +{ + my ($text_answer, $input, $answer) = @_; + return test_zci($text_answer, structured_answer =>{ + data => { + title => $answer, + subtitle => "Factors of: $input" + }, + templates => { + group => 'text' + } + }); +} + ddg_goodie_test( [qw( DDG::Goodie::Factors)], - '30 factors' => test_zci( - 'Factors of 30: 1, 2, 3, 5, 6, 10, 15, 30', - structured_answer => { - input => ['30'], - operation => 'Factors', - result => '1, 2, 3, 5, 6, 10, 15, 30' - } - ), - 'factors of 72' => test_zci( - 'Factors of 72: 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72', - structured_answer => { - input => ['72'], - operation => 'Factors', - result => '1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72' - } - ), - 'factors of 30' => test_zci( - 'Factors of 30: 1, 2, 3, 5, 6, 10, 15, 30', - structured_answer => { - input => ['30'], - operation => 'Factors', - result => '1, 2, 3, 5, 6, 10, 15, 30' - } - ), - '72 factors' => test_zci( - 'Factors of 72: 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72', - structured_answer => { - input => ['72'], - operation => 'Factors', - result => '1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72' - } - ), + '30 factors' => build_test('Factors of 30: 1, 2, 3, 5, 6, 10, 15, 30', '30', '1, 2, 3, 5, 6, 10, 15, 30'), + 'factors of 72' => build_test('Factors of 72: 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72', '72', '1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72'), + 'factors of 30' => build_test('Factors of 30: 1, 2, 3, 5, 6, 10, 15, 30', '30', '1, 2, 3, 5, 6, 10, 15, 30'), + '72 factors' => build_test('Factors of 72: 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72', '72', '1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72'), ); done_testing; From 104b963bcae46980982f8d42230dd345d128cfa2 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 15 May 2016 19:22:30 +0100 Subject: [PATCH 88/91] GenerateMAC: Switching out to use Test::Deep --- t/GenerateMAC.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/GenerateMAC.t b/t/GenerateMAC.t index 2eaf3549d..17c42c159 100755 --- a/t/GenerateMAC.t +++ b/t/GenerateMAC.t @@ -14,7 +14,7 @@ my $text_start = "Here's a random MAC address: "; sub build_test { - return test_zci(qr/^$text_start$mac_regxp$/, structured_answer => { + return test_zci(re(qr/^$text_start$mac_regxp$/), structured_answer => { data => { title => re($mac_regxp), subtitle => "Random MAC Address" From 58ce9b09c9bb6057c506e42a86cf2b46612c0fd3 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sun, 15 May 2016 20:01:11 +0100 Subject: [PATCH 89/91] Fortune: Switching to text template (#3063) * Fortune: Switching to text template * Fortune: Adding subtitle and using Test::Deep --- lib/DDG/Goodie/Fortune.pm | 15 +++++++++------ t/Fortune.t | 30 ++++++++++++++++++------------ 2 files changed, 27 insertions(+), 18 deletions(-) mode change 100644 => 100755 lib/DDG/Goodie/Fortune.pm mode change 100644 => 100755 t/Fortune.t diff --git a/lib/DDG/Goodie/Fortune.pm b/lib/DDG/Goodie/Fortune.pm old mode 100644 new mode 100755 index b343e1180..7fce452d6 --- a/lib/DDG/Goodie/Fortune.pm +++ b/lib/DDG/Goodie/Fortune.pm @@ -18,12 +18,15 @@ handle remainder => sub { my $output = $fortune_file->get_random_fortune(); $output =~ s/\n/ /g; - return $output, - structured_answer => { - input => [], - operation => 'Random fortune', - result => $output - }; + return $output, structured_answer => { + data => { + title => $output, + subtitle => "Random Fortune" + }, + templates => { + group => 'text' + } + }; }; 1; diff --git a/t/Fortune.t b/t/Fortune.t old mode 100644 new mode 100755 index f960e9b87..07ccd8613 --- a/t/Fortune.t +++ b/t/Fortune.t @@ -3,26 +3,32 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'fortune'; zci is_cached => 0; -my @fortune = ( - '-ANY-', - structured_answer => { - input => [], - operation => 'Random fortune', - result => '-ANY-' - }); +sub build_test +{ + return test_zci(re(qr/.+/), structured_answer => { + data => { + title => re(qr/.+/), + subtitle => 'Random Fortune' + }, + templates => { + group => 'text' + } + }) +} ddg_goodie_test( [qw( DDG::Goodie::Fortune )], - 'gimmie a fortune cookie' => test_zci(@fortune), - 'gimmie a unix fortune' => test_zci(@fortune), - 'give me a fortune cookie' => test_zci(@fortune), - 'give me a unix fortune' => test_zci(@fortune), - 'unix fortune cookie' => test_zci(@fortune), + 'gimmie a fortune cookie' => build_test(), + 'gimmie a unix fortune' => build_test(), + 'give me a fortune cookie' => build_test(), + 'give me a unix fortune' => build_test(), + 'unix fortune cookie' => build_test(), 'how do I make a fortune overnight' => undef, "bill gates' fortune" => undef, ); From 5f85cf4121b521b2056d8ae8846765cc8c7a2e43 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Mon, 16 May 2016 14:07:57 +0100 Subject: [PATCH 90/91] Update Goodies to use Test::Deep * Ensure Test::Deep is imported. * Replace '-ANY-' with ignore() * Replace regexes with re(...) --- t/ABC.t | 28 +++--- t/AltCalendars.t | 3 +- t/Anagram.t | 3 +- t/AspectRatio.t | 3 +- t/Atbash.t | 3 +- t/Average.t | 2 +- t/BPMToMs.t | 31 ++++--- t/BRT.t | 3 +- t/Base.t | 2 +- t/Base64.t | 3 +- t/BashPrimaryExpressions.t | 29 +++--- t/BeamMeUpScotty.t | 3 +- t/Bin2Unicode.t | 3 +- t/Binary.t | 3 +- t/BinaryLogic.t | 3 +- t/BirthStone.t | 3 +- t/Bitsum.t | 3 +- t/BloodDonor.t | 3 +- t/Braille.t | 3 +- t/CaesarCipher.t | 5 +- t/CalcRoots.t | 3 +- t/Calculator.t | 185 +++++++++++++++++++------------------ t/CalendarConversion.t | 3 +- t/CalendarToday.t | 70 +++++++------- t/CallingCodes.t | 3 +- t/CamelCase.t | 3 +- t/Chars.t | 2 +- t/Chess960.t | 4 +- t/ChineseZodiac.t | 2 +- t/CoffeeToWaterRatio.t | 3 +- t/Coin.t | 43 ++++----- t/ColorCodes.t | 3 +- t/Combination.t | 3 +- t/Constants.t | 3 +- t/Conversions.t | 3 +- t/ConvertLatLon.t | 6 +- t/CountryCodes.t | 3 +- t/CryptHashCheck.t | 2 +- t/CurrencyIn.t | 3 +- t/Cusip.t | 60 ++++++------ t/DHL.t | 2 +- t/DateMath.t | 3 +- t/DayOfWeek.t | 3 +- t/DaysBetween.t | 31 ++++--- t/Dessert.t | 39 ++++---- t/Dewey.t | 3 +- t/Dice.t | 111 +++++++++++----------- t/DuckDuckGo.t | 2 +- t/EmToPx.t | 3 +- t/EmailValidator.t | 33 +++---- t/FIGlet.t | 3 +- t/Factors.t | 3 +- t/FedEx.t | 3 +- t/FenViewer.t | 3 +- t/Fibonacci.t | 3 +- t/FirefoxOS.t | 5 +- t/FlipText.t | 3 +- t/Fortune.t | 1 - t/Frequency.t | 3 +- t/FrequencySpectrum.t | 75 +++++++-------- t/GUID.t | 5 +- t/Game2048.t | 7 +- t/GenerateMAC.t | 2 +- t/GibberishGenerator.t | 7 +- t/GoldenRatio.t | 3 +- t/GreatestCommonFactor.t | 3 +- t/GuitarChords.t | 15 +-- t/HKDK.t | 2 +- t/HTMLEntitiesDecode.t | 17 ++-- t/HTMLEntitiesEncode.t | 69 +++++++------- t/HelpLine.t | 5 +- t/HexToASCII.t | 3 +- t/HexToDec.t | 2 +- t/IDN.t | 2 +- t/IPS.t | 2 +- t/ISO639.t | 3 +- t/IndependenceDay.t | 3 +- t/Jira.t | 3 +- t/JohnCena.t | 3 +- t/Kana.t | 3 +- t/KernelTaint.t | 3 +- t/LaserShip.t | 2 +- t/Latex.t | 9 +- t/LeapYear.t | 3 +- t/LeetSpeak.t | 3 +- t/Loan.t | 3 +- t/LoremIpsum.t | 7 +- t/Lowercase.t | 3 +- t/MD4.t | 3 +- t/MD5.t | 3 +- t/MacAddress.t | 3 +- t/MagicEightBall.t | 7 +- t/MakeMeASandwich.t | 3 +- t/MarkdownReference.t | 3 +- t/Minecraft.t | 3 +- t/MoonPhases.t | 15 +-- t/Morse.t | 3 +- t/NLetterWords.t | 7 +- t/NameDays.t | 3 +- t/NoteFrequency.t | 3 +- t/OnionAddress.t | 3 +- t/POTUS.t | 3 +- t/PaleoIngredientCheck.t | 1 + t/Palindrome.t | 2 +- t/Paper.t | 3 +- t/Parcelforce.t | 2 +- t/ParseCron.t | 3 +- t/Passphrase.t | 7 +- t/Password.t | 79 ++++++++-------- t/PercentError.t | 2 +- t/PercentOf.t | 3 +- t/Perimeter.t | 3 +- t/PeriodicTable.t | 3 +- t/PhoneAlphabet.t | 3 +- t/Phonetic.t | 3 +- t/Pi.t | 3 +- t/PigLatin.t | 3 +- t/Poker.t | 3 +- t/PrimeFactors.t | 3 +- t/PrimeNumber.t | 3 +- t/PrivateNetwork.t | 5 +- t/PublicDNS.t | 9 +- t/RIPEMD.t | 2 +- t/Rafl.t | 5 +- t/Randagram.t | 7 +- t/RandomName.t | 9 +- t/RandomNumber.t | 2 +- t/Rc4.t | 3 +- t/Regexp.t | 3 +- t/ResistorColors.t | 4 +- t/Reverse.t | 2 +- t/ReverseComplement.t | 2 +- t/ReverseResistorColours.t | 3 +- t/Roman.t | 3 +- t/Rot13.t | 3 +- t/RouterPasswords.t | 3 +- t/RubiksCubePatterns.t | 3 +- t/SHA3.t | 2 +- t/Scramble.t | 5 +- t/ScreenResolution.t | 3 +- t/SecurityAddons.t | 3 +- t/Sha.t | 3 +- t/Shruggie.t | 3 +- t/SigFigs.t | 3 +- t/SolarSystem.t | 3 +- t/Sort.t | 3 +- t/Stardate.t | 7 +- t/SubnetCalc.t | 3 +- t/Sudoku.t | 27 +++--- t/SumOfNaturalNumbers.t | 3 +- t/SunInfo.t | 23 ++--- t/Teredo.t | 3 +- t/TimezoneConverter.t | 33 +++---- t/Tips.t | 3 +- t/TitleCase.t | 3 +- t/TwelveOclock.t | 3 +- t/UN.t | 2 +- t/UPS.t | 2 +- t/URLDecode.t | 3 +- t/URLEncode.t | 3 +- t/USPS.t | 2 +- t/UltimateAnswer.t | 3 +- t/Unicode.t | 3 +- t/UnicodeFuzzySearch.t | 3 +- t/Unicornify.t | 3 +- t/Unidecode.t | 2 +- t/UnixPermissions.t | 3 +- t/UnixTime.t | 19 ++-- t/Uppercase.t | 3 +- t/Uptime.t | 3 +- t/VIN.t | 3 +- t/ValarMorghulis.t | 1 + t/Wavelength.t | 3 +- t/Week.t | 9 +- t/WeekdaysBetween.t | 3 +- t/Weight.t | 3 +- t/WhereAmI.t | 3 +- t/WorkdaysBetween.t | 15 +-- t/ZappBrannigan.t | 2 +- t/Zodiac.t | 3 +- 180 files changed, 855 insertions(+), 709 deletions(-) diff --git a/t/ABC.t b/t/ABC.t index 0d4601bdb..759095b78 100755 --- a/t/ABC.t +++ b/t/ABC.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'choice'; @@ -12,7 +13,7 @@ sub create_structured_answer { my $data = shift; return { - data => $data, #'-ANY-', + data => $data, #ignore(), templates => { group => 'text', moreAt => 0 @@ -30,28 +31,28 @@ ddg_goodie_test( 'choose his or or her house' => undef, 'choose from products like turkey or venison' => undef, 'choose pick or axe' => test_zci( - qr/(pick|axe) \(Random\)/, - structured_answer => create_structured_answer('-ANY-') + re(qr/(pick|axe) \(Random\)/), + structured_answer => create_structured_answer(ignore()) ), 'choose yes or no' => test_zci( - qr/(yes|no) \(Random\)/, - structured_answer => create_structured_answer('-ANY-') + re(qr/(yes|no) \(Random\)/), + structured_answer => create_structured_answer(ignore()) ), 'choose this or that or none' => test_zci( - qr/(this|that|none) \(Random\)/, - structured_answer => create_structured_answer('-ANY-') + re(qr/(this|that|none) \(Random\)/), + structured_answer => create_structured_answer(ignore()) ), 'pick this or that or none' => test_zci( - qr/(this|that|none) \(Random\)/, - structured_answer => create_structured_answer('-ANY-') + re(qr/(this|that|none) \(Random\)/), + structured_answer => create_structured_answer(ignore()) ), 'select heads or tails' => test_zci( - qr/(heads|tails) \(Random\)/, - structured_answer => create_structured_answer('-ANY-') + re(qr/(heads|tails) \(Random\)/), + structured_answer => create_structured_answer(ignore()) ), 'choose heads or tails' => test_zci( - qr/(heads|tails) \(Random\)/, - structured_answer => create_structured_answer('-ANY-') + re(qr/(heads|tails) \(Random\)/), + structured_answer => create_structured_answer(ignore()) ), 'choose duckduckgo or google or bing or something' => test_zci( 'duckduckgo (Non-random)', @@ -70,4 +71,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/AltCalendars.t b/t/AltCalendars.t index c38016a41..203ab74a2 100644 --- a/t/AltCalendars.t +++ b/t/AltCalendars.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'date_conversion'; @@ -84,4 +85,4 @@ sub make_structured_answer { }; }; -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Anagram.t b/t/Anagram.t index 54d158988..345aed433 100644 --- a/t/Anagram.t +++ b/t/Anagram.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'anagram'; @@ -42,4 +43,4 @@ ddg_goodie_test( 'anagrams of "Mixing it up"' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/AspectRatio.t b/t/AspectRatio.t index a5df07e7a..a83801717 100644 --- a/t/AspectRatio.t +++ b/t/AspectRatio.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'aspect_ratio'; @@ -33,4 +34,4 @@ ddg_goodie_test( 'aspect ratio 1:1.5 ?:15' => build_test('1:1.5', '10:15') ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Atbash.t b/t/Atbash.t index dabe896b5..1b08554c3 100755 --- a/t/Atbash.t +++ b/t/Atbash.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'atbash'; @@ -92,4 +93,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Average.t b/t/Average.t index 48afc131a..ea25210ab 100644 --- a/t/Average.t +++ b/t/Average.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'average'; @@ -42,4 +43,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/BPMToMs.t b/t/BPMToMs.t index 97402e616..d31d558a7 100644 --- a/t/BPMToMs.t +++ b/t/BPMToMs.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "bpmto_ms"; @@ -30,49 +31,49 @@ ddg_goodie_test( "120 beats per minute to ms" => test_zci( $plaintext_120, structured_answer => { - data => '-ANY-', + data => ignore(), # [ # { # note_type => "Whole Note", # triplet => 1333, # dotted => 3000, # milliseconds => 2000, -# image => qr/.*/ +# image => re(qr/.*/) # }, # { # note_type => "Half Note", # triplet => 667, # dotted => 1500, # milliseconds => 1000, -# image => qr/.*/ +# image => re(qr/.*/) # }, # { # note_type => "Quarter Note", # triplet => 333, # dotted => 750, # milliseconds => 500, -# image => qr/.*/ +# image => re(qr/.*/) # }, # { # note_type => "1/8 Note", # triplet => 167, # dotted => 375, # milliseconds => 250, -# image => qr/.*/ +# image => re(qr/.*/) # }, # { # note_type => "1/16 Note", # triplet => 83, # dotted => 188, # milliseconds => 125, -# image => qr/.*/ +# image => re(qr/.*/) # }, # { # note_type => "1/32 Note", # triplet => 42, # dotted => 94, # milliseconds => 63, -# image => qr/.*/ +# image => re(qr/.*/) # } # ], meta => { @@ -92,49 +93,49 @@ ddg_goodie_test( "61 beats per minute to ms" => test_zci( $plaintext_61, structured_answer => { - data => '-ANY-', + data => ignore(), # [ # { # note_type => "Whole Note", # triplet => 2623, # dotted => 5902, # milliseconds => 3934, -# image => qr/.*/ +# image => re(qr/.*/) # }, # { # note_type => "Half Note", # triplet => 1311, # dotted => 2951, # milliseconds => 1967, -# image => qr/.*/ +# image => re(qr/.*/) # }, # { # note_type => "Quarter Note", # triplet => 656, # dotted => 1475, # milliseconds => 984, -# image => qr/.*/ +# image => re(qr/.*/) # }, # { # note_type => "1/8 Note", # triplet => 328, # dotted => 738, # milliseconds => 492, -# image => qr/.*/ +# image => re(qr/.*/) # }, # { # note_type => "1/16 Note", # triplet => 164, # dotted => 369, # milliseconds => 246, -# image => qr/.*/ +# image => re(qr/.*/) # }, # { # note_type => "1/32 Note", # triplet => 82, # dotted => 184, # milliseconds => 123, -# image => qr/.*/ +# image => re(qr/.*/) # } # ], meta => { @@ -156,4 +157,4 @@ ddg_goodie_test( 'bpm' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/BRT.t b/t/BRT.t index 9a90bb1ad..5fae6b456 100644 --- a/t/BRT.t +++ b/t/BRT.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "brt"; @@ -30,4 +31,4 @@ ddg_goodie_test( "brt 12345678901234567890" => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Base.t b/t/Base.t index 24e282f42..d36921eaa 100644 --- a/t/Base.t +++ b/t/Base.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'conversion'; @@ -39,4 +40,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/Base64.t b/t/Base64.t index 413a402b9..e0b6bc729 100644 --- a/t/Base64.t +++ b/t/Base64.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'base64_conversion'; @@ -45,4 +46,4 @@ ddg_goodie_test( "base64 decode" => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/BashPrimaryExpressions.t b/t/BashPrimaryExpressions.t index dbc107bd7..bd366d116 100644 --- a/t/BashPrimaryExpressions.t +++ b/t/BashPrimaryExpressions.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'expression_description'; @@ -12,7 +13,7 @@ ddg_goodie_test( 'DDG::Goodie::BashPrimaryExpressions' ], "bash [ -a b ]" => test_zci( - qr/.+ true if b exists./, + re(qr/.+ true if b exists./), structured_answer => { data => { intro => "[ -a b ]", @@ -39,9 +40,9 @@ ddg_goodie_test( } ), 'bash [[ "abc" < "cba" ]]' => test_zci( - qr/.+ true if "abc" string-sorts before "cba" in the current locale./, + re(qr/.+ true if "abc" string-sorts before "cba" in the current locale./), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -52,9 +53,9 @@ ddg_goodie_test( } ), 'bash [ 2 -gt 1 ]' => test_zci( - qr/.+ true if 2 is numerically greater than 1./, + re(qr/.+ true if 2 is numerically greater than 1./), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -65,9 +66,9 @@ ddg_goodie_test( } ), 'bash [ ! hello == world ]' => test_zci( - qr/.+ false if the strings hello and world are equal./, + re(qr/.+ false if the strings hello and world are equal./), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -78,9 +79,9 @@ ddg_goodie_test( } ), 'bash [[ /tmp/hello -nt /etc/test ]]' => test_zci ( - qr#.+ true if /tmp/hello has been changed more recently than /etc/test or if /tmp/hello exists and /etc/test does not.#, + re(qr#.+ true if /tmp/hello has been changed more recently than /etc/test or if /tmp/hello exists and /etc/test does not.#), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -91,9 +92,9 @@ ddg_goodie_test( } ), 'bash [ -z hello ]' => test_zci( - qr/.+ true if the length of 'hello' is zero./, + re(qr/.+ true if the length of 'hello' is zero./), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -104,9 +105,9 @@ ddg_goodie_test( } ), 'bash if [[ "abc" -lt "cba" ]]' => test_zci( - qr/.+ true if "abc" is numerically less than "cba"./, + re(qr/.+ true if "abc" is numerically less than "cba"./), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -120,4 +121,4 @@ ddg_goodie_test( 'bash if [ ![ 1 -lt 2 ] ]' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/BeamMeUpScotty.t b/t/BeamMeUpScotty.t index f1a645a01..389b850ea 100644 --- a/t/BeamMeUpScotty.t +++ b/t/BeamMeUpScotty.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "beam_me_up_scotty"; @@ -32,4 +33,4 @@ ddg_goodie_test( 'scotty beam us up' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Bin2Unicode.t b/t/Bin2Unicode.t index 5ff9bf030..4a70adb71 100644 --- a/t/Bin2Unicode.t +++ b/t/Bin2Unicode.t @@ -1,6 +1,7 @@ #!/usr/bin/env perl use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -77,4 +78,4 @@ ddg_goodie_test( %ctrl_tests ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Binary.t b/t/Binary.t index d4225b10c..2257ccb80 100644 --- a/t/Binary.t +++ b/t/Binary.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'binary_conversion'; @@ -56,4 +57,4 @@ ddg_goodie_test( 'to binary' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/BinaryLogic.t b/t/BinaryLogic.t index fbcb2d420..3b39d60f0 100755 --- a/t/BinaryLogic.t +++ b/t/BinaryLogic.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -65,4 +66,4 @@ ddg_goodie_test( 'what do number and letter codes in a lens name mean' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/BirthStone.t b/t/BirthStone.t index 7600209b2..add7946d8 100644 --- a/t/BirthStone.t +++ b/t/BirthStone.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "birth_stone"; @@ -35,4 +36,4 @@ ddg_goodie_test( 'may birth stone' => build_test('May', 'Emerald') ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Bitsum.t b/t/Bitsum.t index 9762c5155..bc107b31f 100644 --- a/t/Bitsum.t +++ b/t/Bitsum.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "bitsum"; @@ -46,4 +47,4 @@ ddg_goodie_test( 'bitsum 0b' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/BloodDonor.t b/t/BloodDonor.t index 7f326b865..22a0ddc69 100755 --- a/t/BloodDonor.t +++ b/t/BloodDonor.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "blood_donor"; @@ -89,4 +90,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Braille.t b/t/Braille.t index d853f6d05..3175b23e8 100644 --- a/t/Braille.t +++ b/t/Braille.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use Convert::Braille; use utf8; @@ -43,4 +44,4 @@ ddg_goodie_test( 'braille to braille is good' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/CaesarCipher.t b/t/CaesarCipher.t index e7eedede5..e5e79b1f8 100644 --- a/t/CaesarCipher.t +++ b/t/CaesarCipher.t @@ -3,13 +3,14 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'caesar_cipher'; zci is_cached => 1; my $decode_response = { - data => '-ANY-', # We only need to check it is the right template. + data => ignore(), # We only need to check it is the right template. meta => { sourceUrl => 'https://en.wikipedia.org/wiki/Caesar_cipher', sourceName => 'Wikipedia', @@ -70,4 +71,4 @@ ddg_goodie_test( 'how to decode caesar' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/CalcRoots.t b/t/CalcRoots.t index ef1149ee8..e0086a5a2 100644 --- a/t/CalcRoots.t +++ b/t/CalcRoots.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'root'; @@ -49,4 +50,4 @@ ddg_goodie_test( } ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Calculator.t b/t/Calculator.t index 86313a896..a2bb88991 100644 --- a/t/Calculator.t +++ b/t/Calculator.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use DDG::Goodie::Calculator; # For function subtests. use utf8; @@ -18,7 +19,7 @@ ddg_goodie_test( structured_answer => { input => ['2 - 2'], operation => 'Calculate', - result => qr/>0 re(qr/>0 test_zci( @@ -27,7 +28,7 @@ ddg_goodie_test( structured_answer => { input => ['2 + 2'], operation => 'Calculate', - result => qr/>4 re(qr/>4 test_zci( @@ -36,7 +37,7 @@ ddg_goodie_test( structured_answer => { input => ['2 ^ 8'], operation => 'Calculate', - result => qr/>256 re(qr/>256 test_zci( @@ -45,7 +46,7 @@ ddg_goodie_test( structured_answer => { input => ['2 * 7'], operation => 'Calculate', - result => qr/>14 re(qr/>14 test_zci( @@ -54,7 +55,7 @@ ddg_goodie_test( structured_answer => { input => ['4 * 5'], operation => 'Calculate', - result => qr/>20 re(qr/>20 test_zci( @@ -63,7 +64,7 @@ ddg_goodie_test( structured_answer => { input => ['6 * 7'], operation => 'Calculate', - result => qr/>42 re(qr/>42 test_zci( @@ -72,7 +73,7 @@ ddg_goodie_test( structured_answer => { input => ['3 * dozen'], operation => 'Calculate', - result => qr/>36 re(qr/>36 test_zci( @@ -81,7 +82,7 @@ ddg_goodie_test( structured_answer => { input => ['dozen / 4'], operation => 'Calculate', - result => qr/>3 re(qr/>3 test_zci( @@ -90,7 +91,7 @@ ddg_goodie_test( structured_answer => { input => ['1 dozen * 2'], operation => 'Calculate', - result => qr/>24 re(qr/>24 test_zci( @@ -99,7 +100,7 @@ ddg_goodie_test( structured_answer => { input => ['dozen + dozen'], operation => 'Calculate', - result => qr/>24 re(qr/>24 test_zci( @@ -108,7 +109,7 @@ ddg_goodie_test( structured_answer => { input => ['2 divided by 4'], operation => 'Calculate', - result => qr/>0.5 re(qr/>0.5 test_zci( @@ -117,7 +118,7 @@ ddg_goodie_test( structured_answer => { input => ['2 ^ 2'], operation => 'Calculate', - result => qr/>4 re(qr/>4 test_zci( @@ -126,7 +127,7 @@ ddg_goodie_test( structured_answer => { input => ['2 ^ 0.2'], operation => 'Calculate', - result => qr/>1\.14869835499704 re(qr/>1\.14869835499704 test_zci( @@ -135,7 +136,7 @@ ddg_goodie_test( structured_answer => { input => ['cos(0)'], operation => 'Calculate', - result => qr/>1 re(qr/>1 test_zci( @@ -144,7 +145,7 @@ ddg_goodie_test( structured_answer => { input => ['tan(1)'], operation => 'Calculate', - result => qr/>1\.5574077246549 re(qr/>1\.5574077246549 test_zci( @@ -153,7 +154,7 @@ ddg_goodie_test( structured_answer => { input => ['tanh(1)'], operation => 'Calculate', - result => qr/>0\.761594155955765 re(qr/>0\.761594155955765 test_zci( @@ -162,7 +163,7 @@ ddg_goodie_test( structured_answer => { input => ['cotan(1)'], operation => 'Calculate', - result => qr/>0\.642092615934331 re(qr/>0\.642092615934331 test_zci( @@ -171,7 +172,7 @@ ddg_goodie_test( structured_answer => { input => ['sin(1)'], operation => 'Calculate', - result => qr/>0\.841470984807897 re(qr/>0\.841470984807897 test_zci( @@ -180,7 +181,7 @@ ddg_goodie_test( structured_answer => { input => ['csc(1)'], operation => 'Calculate', - result => qr/>1\.18839510577812 re(qr/>1\.18839510577812 test_zci( @@ -189,7 +190,7 @@ ddg_goodie_test( structured_answer => { input => ['sec(1)'], operation => 'Calculate', - result => qr/>1\.85081571768093 re(qr/>1\.85081571768093 test_zci( @@ -198,7 +199,7 @@ ddg_goodie_test( structured_answer => { input => ['log(3)'], operation => 'Calculate', - result => qr/>1\.09861228866811 re(qr/>1\.09861228866811 test_zci( @@ -207,7 +208,7 @@ ddg_goodie_test( structured_answer => { input => ['log(3)'], operation => 'Calculate', - result => qr/>1\.09861228866811 re(qr/>1\.09861228866811 test_zci( @@ -216,7 +217,7 @@ ddg_goodie_test( structured_answer => { input => ['log10(100.00)'], operation => 'Calculate', - result => qr/>2 re(qr/>2 test_zci( @@ -225,7 +226,7 @@ ddg_goodie_test( structured_answer => { input => ['log_10(100.00)'], operation => 'Calculate', - result => qr/>2 re(qr/>2 test_zci( @@ -234,7 +235,7 @@ ddg_goodie_test( structured_answer => { input => ['log_2(16)'], operation => 'Calculate', - result => qr/>4 re(qr/>4 test_zci( @@ -243,7 +244,7 @@ ddg_goodie_test( structured_answer => { input => ['log_23(25)'], operation => 'Calculate', - result => qr/>1\.0265928122321 re(qr/>1\.0265928122321 test_zci( @@ -252,7 +253,7 @@ ddg_goodie_test( structured_answer => { input => ['log23(25)'], operation => 'Calculate', - result => qr/>1\.0265928122321 re(qr/>1\.0265928122321 test_zci( @@ -261,7 +262,7 @@ ddg_goodie_test( structured_answer => { input => ['$3.43 + $34.45'], operation => 'Calculate', - result => qr/>\$37\.88 re(qr/>\$37\.88 test_zci( @@ -270,7 +271,7 @@ ddg_goodie_test( structured_answer => { input => ['$3.45 + $34.45'], operation => 'Calculate', - result => qr/>\$37\.90 re(qr/>\$37\.90 test_zci( @@ -279,7 +280,7 @@ ddg_goodie_test( structured_answer => { input => ['$3 + $34'], operation => 'Calculate', - result => qr/>\$37\.00 re(qr/>\$37\.00 test_zci( @@ -288,7 +289,7 @@ ddg_goodie_test( structured_answer => { input => ['$3,4 + $34,4'], operation => 'Calculate', - result => qr/>\$37,80 re(qr/>\$37,80 test_zci( @@ -297,7 +298,7 @@ ddg_goodie_test( structured_answer => { input => ['64 * 343'], operation => 'Calculate', - result => qr/>21,952 re(qr/>21,952 test_zci( @@ -306,7 +307,7 @@ ddg_goodie_test( structured_answer => { input => ['(1 * 10 ^ 2) + 1'], operation => 'Calculate', - result => qr/>101 re(qr/>101 test_zci( @@ -315,7 +316,7 @@ ddg_goodie_test( structured_answer => { input => ['1 + (1 * 10 ^ 2)'], operation => 'Calculate', - result => qr/>101 re(qr/>101 test_zci( @@ -324,7 +325,7 @@ ddg_goodie_test( structured_answer => { input => ['2 * 3 + (1 * 10 ^ 2)'], operation => 'Calculate', - result => qr/>106 re(qr/>106 test_zci( @@ -333,7 +334,7 @@ ddg_goodie_test( structured_answer => { input => ['(1 * 10 ^ 2) + 2 * 3'], operation => 'Calculate', - result => qr/>106 re(qr/>106 test_zci( @@ -342,7 +343,7 @@ ddg_goodie_test( structured_answer => { input => ['(1 * 10 ^ 2) / 2'], operation => 'Calculate', - result => qr/>50 re(qr/>50 test_zci( @@ -351,7 +352,7 @@ ddg_goodie_test( structured_answer => { input => ['2 / (1 * 10 ^ 2)'], operation => 'Calculate', - result => qr/>0\.02 re(qr/>0\.02 test_zci( @@ -360,7 +361,7 @@ ddg_goodie_test( structured_answer => { input => ['424334 + 2253828'], operation => 'Calculate', - result => qr/>2,678,162 re(qr/>2,678,162 test_zci( @@ -369,7 +370,7 @@ ddg_goodie_test( structured_answer => { input => ['4.243,34 + 22.538,28'], operation => 'Calculate', - result => qr/>26\.781,62 re(qr/>26\.781,62 test_zci( @@ -378,7 +379,7 @@ ddg_goodie_test( structured_answer => { input => ['sin(1,0) + 1,05'], operation => 'Calculate', - result => qr/>1,8914709848079 re(qr/>1,8914709848079 test_zci( @@ -387,7 +388,7 @@ ddg_goodie_test( structured_answer => { input => ['21 + 15 * 0 + 5'], operation => 'Calculate', - result => qr/>26 re(qr/>26 test_zci( @@ -396,7 +397,7 @@ ddg_goodie_test( structured_answer => { input => ['0.8158 - 0.8157'], operation => 'Calculate', - result => qr/>0\.0001 re(qr/>0\.0001 test_zci( @@ -405,7 +406,7 @@ ddg_goodie_test( structured_answer => { input => ['2,90 + 4,6'], operation => 'Calculate', - result => qr/>7,50 re(qr/>7,50 test_zci( @@ -414,7 +415,7 @@ ddg_goodie_test( structured_answer => { input => ['2,90 + sec(4,6)'], operation => 'Calculate', - result => qr/>-6,01642861135959 re(qr/>-6,01642861135959 test_zci( @@ -423,7 +424,7 @@ ddg_goodie_test( structured_answer => { input => ['100 - 96.54'], operation => 'Calculate', - result => qr/>3\.46 re(qr/>3\.46 test_zci( @@ -432,7 +433,7 @@ ddg_goodie_test( structured_answer => { input => ['1. + 1.'], operation => 'Calculate', - result => qr/>2 re(qr/>2 test_zci( @@ -441,7 +442,7 @@ ddg_goodie_test( structured_answer => { input => ['1 + sin(pi)'], operation => 'Calculate', - result => qr/>1 re(qr/>1 test_zci( @@ -450,7 +451,7 @@ ddg_goodie_test( structured_answer => { input => ['1 - 1'], operation => 'Calculate', - result => qr/>0 re(qr/>0 test_zci( @@ -459,7 +460,7 @@ ddg_goodie_test( structured_answer => { input => ['sin(pi / 2)'], operation => 'Calculate', - result => qr/>1 re(qr/>1 test_zci( @@ -468,7 +469,7 @@ ddg_goodie_test( structured_answer => { input => ['sin(pi)'], operation => 'Calculate', - result => qr/>0 re(qr/>0 test_zci( @@ -477,7 +478,7 @@ ddg_goodie_test( structured_answer => { input => ['cos(2 pi)'], operation => 'Calculate', - result => qr/>1 re(qr/>1 test_zci( @@ -486,7 +487,7 @@ ddg_goodie_test( structured_answer => { input => ['5 ^ 2'], operation => 'Calculate', - result => qr/>25 re(qr/>25 test_zci( @@ -495,7 +496,7 @@ ddg_goodie_test( structured_answer => { input => ['sqrt(4)'], operation => 'Calculate', - result => qr/>2 re(qr/>2 test_zci( @@ -504,7 +505,7 @@ ddg_goodie_test( structured_answer => { input => ['1.0 + 5 ^ 2'], operation => 'Calculate', - result => qr/>26 re(qr/>26 test_zci( @@ -513,7 +514,7 @@ ddg_goodie_test( structured_answer => { input => ['3 ^ 2 + 4 ^ 2'], operation => 'Calculate', - result => qr/>25 re(qr/>25 test_zci( @@ -522,7 +523,7 @@ ddg_goodie_test( structured_answer => { input => ['2,2 ^ 2'], operation => 'Calculate', - result => qr/>4,84 re(qr/>4,84 test_zci( @@ -531,7 +532,7 @@ ddg_goodie_test( structured_answer => { input => ['0.8 ^ 2 + 0.6 ^ 2'], operation => 'Calculate', - result => qr/>1 re(qr/>1 test_zci( @@ -540,7 +541,7 @@ ddg_goodie_test( structured_answer => { input => ['2 ^ 2 ^ 3'], operation => 'Calculate', - result => qr/>256 re(qr/>256 test_zci( @@ -549,7 +550,7 @@ ddg_goodie_test( structured_answer => { input => ['2 ^ 2 ^ 3.06'], operation => 'Calculate', - result => qr/>323\.972172143725 re(qr/>323\.972172143725 test_zci( @@ -558,7 +559,7 @@ ddg_goodie_test( structured_answer => { input => ['2 ^ 3 ^ 2'], operation => 'Calculate', - result => qr/>512 re(qr/>512 test_zci( @@ -567,7 +568,7 @@ ddg_goodie_test( structured_answer => { input => ['sqrt(2)'], operation => 'Calculate', - result => qr/>1\.4142135623731 re(qr/>1\.4142135623731 test_zci( @@ -576,7 +577,7 @@ ddg_goodie_test( structured_answer => { input => ['sqrt(3 pi / 4 + 1) + 1'], operation => 'Calculate', - result => qr/>2\.83199194599549 re(qr/>2\.83199194599549 test_zci( @@ -585,7 +586,7 @@ ddg_goodie_test( structured_answer => { input => ['4 score + 7'], operation => 'Calculate', - result => qr/>87 re(qr/>87 test_zci( @@ -594,7 +595,7 @@ ddg_goodie_test( structured_answer => { input => ['418.1 / 2'], operation => 'Calculate', - result => qr/>209\.05 re(qr/>209\.05 test_zci( @@ -603,7 +604,7 @@ ddg_goodie_test( structured_answer => { input => ['418.005 / 8'], operation => 'Calculate', - result => qr/>52\.250625 re(qr/>52\.250625 test_zci( @@ -612,7 +613,7 @@ ddg_goodie_test( structured_answer => { input => ['(pi ^ 4 + pi ^ 5) ^ (1 / 6)'], operation => 'Calculate', - result => qr/>2\.71828180861191 re(qr/>2\.71828180861191 test_zci( @@ -621,7 +622,7 @@ ddg_goodie_test( structured_answer => { input => ['(pi ^ 4 + pi ^ 5) ^ (1 / 6) + 1'], operation => 'Calculate', - result => qr/>3\.71828180861191 re(qr/>3\.71828180861191 test_zci( @@ -630,7 +631,7 @@ ddg_goodie_test( structured_answer => { input => ['5 ^ 4 ^ (3 - 2) ^ 1'], operation => 'Calculate', - result => qr/>625 re(qr/>625 test_zci( @@ -639,7 +640,7 @@ ddg_goodie_test( structured_answer => { input => ['(5 - 4) ^ (3 - 2) ^ 1'], operation => 'Calculate', - result => qr/>1 re(qr/>1 test_zci( @@ -648,7 +649,7 @@ ddg_goodie_test( structured_answer => { input => ['(5 + 4 - 3) ^ (2 - 1)'], operation => 'Calculate', - result => qr/>6 re(qr/>6 test_zci( @@ -657,7 +658,7 @@ ddg_goodie_test( structured_answer => { input => ['5 ^ ((4 - 3) * (2 + 1)) + 6'], operation => 'Calculate', - result => qr/>131 re(qr/>131 test_zci( @@ -666,7 +667,7 @@ ddg_goodie_test( structured_answer => { input => ['20 * 07'], operation => 'Calculate', - result => qr/>140 re(qr/>140 test_zci( @@ -675,7 +676,7 @@ ddg_goodie_test( structured_answer => { input => ['83.166.167.160 / 33'], operation => 'Calculate', - result => qr/>2\.520\.186\.883,63636 re(qr/>2\.520\.186\.883,63636 test_zci( @@ -684,7 +685,7 @@ ddg_goodie_test( structured_answer => { input => ['123.123.123.123 / 255.255.255.256'], operation => 'Calculate', - result => qr/>0,482352941174581 re(qr/>0,482352941174581 test_zci( @@ -693,7 +694,7 @@ ddg_goodie_test( structured_answer => { input => ['(4 * 10 ^ 5) + 1'], operation => 'Calculate', - result => qr/>400,001 re(qr/>400,001 test_zci( @@ -702,7 +703,7 @@ ddg_goodie_test( structured_answer => { input => ['(4 * 10 ^ 5) + 1'], operation => 'Calculate', - result => qr/>400,001 re(qr/>400,001 test_zci( @@ -711,7 +712,7 @@ ddg_goodie_test( structured_answer => { input => ['(3 * 10 ^- 2) * 9'], operation => 'Calculate', - result => qr/>0.27 re(qr/>0.27 test_zci( @@ -720,7 +721,7 @@ ddg_goodie_test( structured_answer => { input => ['(7 * 10 ^- 4) * 8'], operation => 'Calculate', - result => qr/>0.0056 re(qr/>0.0056 test_zci( @@ -729,7 +730,7 @@ ddg_goodie_test( structured_answer => { input => ['6 * (2 * 10 ^- 11)'], operation => 'Calculate', - result => qr/>1\.2 \* 10-10<\/sup> re(qr/>1\.2 \* 10-10<\/sup> test_zci( @@ -738,7 +739,7 @@ ddg_goodie_test( structured_answer => { input => ['7 + (7 * 10 ^- 7)'], operation => 'Calculate', - result => qr/>7.0000007 re(qr/>7.0000007 test_zci( @@ -747,7 +748,7 @@ ddg_goodie_test( structured_answer => { input => ['1 * 7 + e - 7'], operation => 'Calculate', - result => qr/>2.71828182845905 re(qr/>2.71828182845905 test_zci( @@ -756,7 +757,7 @@ ddg_goodie_test( structured_answer => { input => ['7 * e - 5'], operation => 'Calculate', - result => qr/>14.0279727992134 re(qr/>14.0279727992134 test_zci( @@ -765,7 +766,7 @@ ddg_goodie_test( structured_answer => { input => ['pi / (1 * 10 ^ 9)'], operation => 'Calculate', - result => qr/>3\.14159265358979 \* 10-9<\/sup> re(qr/>3\.14159265358979 \* 10-9<\/sup> test_zci( @@ -774,7 +775,7 @@ ddg_goodie_test( structured_answer => { input => ['pi * (1 * 10 ^ 9)'], operation => 'Calculate', - result => qr/>3,141,592,653\.58979 re(qr/>3,141,592,653\.58979 test_zci( @@ -783,7 +784,7 @@ ddg_goodie_test( structured_answer => { input => ['1234 + 5432'], operation => 'Calculate', - result => qr/6,666/ + result => re(qr/6,666/) } ), '1_234 + 5_432' => test_zci( @@ -792,7 +793,7 @@ ddg_goodie_test( structured_answer => { input => ['1234 + 5432'], operation => 'Calculate', - result => qr/6,666/ + result => re(qr/6,666/) } ), '(0.4e^(0))*cos(0)' => test_zci( @@ -801,7 +802,7 @@ ddg_goodie_test( structured_answer => { input => ['(0.4e ^ (0)) * cos(0)'], operation => 'Calculate', - result => qr'0.4' + result => re(qr'0.4') } ), '2pi' => test_zci( @@ -810,7 +811,7 @@ ddg_goodie_test( structured_answer => { input => ['2 pi'], operation => 'Calculate', - result => qr"6.28318530717958" + result => re(qr"6.28318530717958") } ), 'fact(3)' => test_zci( @@ -819,7 +820,7 @@ ddg_goodie_test( structured_answer => { input => ['fact(3)'], operation => 'Calculate', - result => qr/>6 re(qr/>6 test_zci( @@ -828,7 +829,7 @@ ddg_goodie_test( structured_answer => { input => ['fact(3)'], operation => 'Calculate', - result => qr/>6 re(qr/>6 undef, @@ -860,4 +861,4 @@ ddg_goodie_test( '(01780) 111 111' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/CalendarConversion.t b/t/CalendarConversion.t index 059a0cdb2..84e840deb 100644 --- a/t/CalendarConversion.t +++ b/t/CalendarConversion.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'calendar_conversion'; @@ -48,4 +49,4 @@ ddg_goodie_test( '22nd Aug 2003 in gregorian time' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/CalendarToday.t b/t/CalendarToday.t index 8fd3a0ab1..6c33fa98a 100755 --- a/t/CalendarToday.t +++ b/t/CalendarToday.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use Test::MockTime qw( :all ); @@ -14,9 +15,9 @@ ddg_goodie_test( DDG::Goodie::CalendarToday )], 'calendar' => test_zci( - qr/\nS M T W T F S[ ]+[A-Za-z]+ [0-9]{4}\n.+/, + re(qr/\nS M T W T F S[ ]+[A-Za-z]+ [0-9]{4}\n.+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -27,9 +28,9 @@ ddg_goodie_test( } ), 'calendar november' => test_zci( - qr/\nS M T W T F S November [0-9]{4}\n.+/, + re(qr/\nS M T W T F S November [0-9]{4}\n.+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -40,9 +41,9 @@ ddg_goodie_test( } ), 'calendar november 12th' => test_zci( - qr/\nS M T W T F S November [0-9]{4}\n.+/, + re(qr/\nS M T W T F S November [0-9]{4}\n.+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -53,9 +54,9 @@ ddg_goodie_test( } ), 'calendar last november' => test_zci( - qr/\nS M T W T F S November [0-9]{4}\n.+/, + re(qr/\nS M T W T F S November [0-9]{4}\n.+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -66,9 +67,9 @@ ddg_goodie_test( } ), 'calendar next november' => test_zci( - qr/\nS M T W T F S November [0-9]{4}\n.+/, + re(qr/\nS M T W T F S November [0-9]{4}\n.+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -217,7 +218,7 @@ S M T W T F S November 2009 29 30 ", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -236,7 +237,7 @@ S M T W T F S November 2015 |29| 30 ", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -255,7 +256,7 @@ S M T W T F S November 2015 |29| 30 ", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -275,7 +276,7 @@ S M T W T F S November 1980 30 ", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -294,7 +295,7 @@ S M T W T F S November 2009 29 30 ", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -305,9 +306,9 @@ S M T W T F S November 2009 } ), 'next november on a calendar' => test_zci( - qr/\nS M T W T F S November [0-9]{4}\n.+/, + re(qr/\nS M T W T F S November [0-9]{4}\n.+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -318,9 +319,9 @@ S M T W T F S November 2009 } ), 'calendar for november' => test_zci( - qr/\nS M T W T F S November [0-9]{4}\n.+/, + re(qr/\nS M T W T F S November [0-9]{4}\n.+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -339,7 +340,7 @@ S M T W T F S November 2009 29 30 ", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -351,9 +352,9 @@ S M T W T F S November 2009 ), '22/8/2003 to the hijri calendar' => undef, "today's calendar" => test_zci( - qr/\nS M T W T F S [A-Z][a-z]+ [0-9]{4}\n.+/, + re(qr/\nS M T W T F S [A-Z][a-z]+ [0-9]{4}\n.+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -364,9 +365,9 @@ S M T W T F S November 2009 } ), "november's calendar" => test_zci( - qr/\nS M T W T F S November [0-9]{4}\n.+/, + re(qr/\nS M T W T F S November [0-9]{4}\n.+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -379,14 +380,14 @@ S M T W T F S November 2009 ); # Special focus on relative dates, examining the "today" circle -my $test_location_tz = qr/\(EDT, UTC-4\)/; +my $test_location_tz = re(qr/\(EDT, UTC-4\)/); set_fixed_time("2014-06-11T09:45:56"); ddg_goodie_test( [qw( DDG::Goodie::CalendarToday )], "calendar yesterday" => test_zci( - qr/June 2014.*\|10\|/s, + re(qr/June 2014.*\|10\|/s), structured_answer => { data => { month_year => "June 2014", @@ -445,7 +446,7 @@ ddg_goodie_test( } ), "calendar today" => test_zci( - qr/June 2014.*\|11\|/s, + re(qr/June 2014.*\|11\|/s), structured_answer => { data => { month_year => "June 2014", @@ -504,7 +505,7 @@ ddg_goodie_test( } ), "calendar tomorrow" => test_zci( - qr/June 2014.*\|12\|/s, + re(qr/June 2014.*\|12\|/s), structured_answer => { data => { month_year => "June 2014", @@ -563,7 +564,7 @@ ddg_goodie_test( } ), "calendar 20 days ago" => test_zci( - qr/May 2014.*\|22\|/s, + re(qr/May 2014.*\|22\|/s), structured_answer => { data => { month_year => "May 2014", @@ -627,7 +628,7 @@ ddg_goodie_test( } ), "calendar in 20 days" => test_zci( - qr/July 2014.*\| 1\|/s, + re(qr/July 2014.*\| 1\|/s), structured_answer => { data => { month_year => "July 2014", @@ -689,7 +690,7 @@ ddg_goodie_test( } ), "calendar last week" => test_zci( - qr/June 2014.*\| 4\|/s, + re(qr/June 2014.*\| 4\|/s), structured_answer => { data => { month_year => "June 2014", @@ -748,7 +749,7 @@ ddg_goodie_test( } ), "calendar next week" => - test_zci(qr/June 2014.*\|18\|/s, + test_zci(re(qr/June 2014.*\|18\|/s), structured_answer => { data => { month_year => "June 2014", @@ -807,7 +808,7 @@ ddg_goodie_test( } ), "calendar last year" => - test_zci(qr/June 2013.*\|11\|/s, + test_zci(re(qr/June 2013.*\|11\|/s), structured_answer => { data => { month_year => "June 2013", @@ -874,7 +875,7 @@ ddg_goodie_test( } ), "calendar next year" => - test_zci(qr/June 2015.*\|11\|/s, + test_zci(re(qr/June 2015.*\|11\|/s), structured_answer => { data => { month_year => "June 2015", @@ -937,4 +938,3 @@ ddg_goodie_test( restore_time(); done_testing; - diff --git a/t/CallingCodes.t b/t/CallingCodes.t index eff0e6b86..f1df2bf93 100644 --- a/t/CallingCodes.t +++ b/t/CallingCodes.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "calling_codes"; @@ -93,4 +94,4 @@ ddg_goodie_test( "calling code 599" => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/CamelCase.t b/t/CamelCase.t index ebff437f1..adb7a5230 100644 --- a/t/CamelCase.t +++ b/t/CamelCase.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "camel_case"; @@ -44,4 +45,4 @@ ddg_goodie_test( 'camelcase this' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Chars.t b/t/Chars.t index 8ec7f022c..10f977bd5 100644 --- a/t/Chars.t +++ b/t/Chars.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'chars'; @@ -103,4 +104,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/Chess960.t b/t/Chess960.t index 8831bf2eb..d8f26bae3 100644 --- a/t/Chess960.t +++ b/t/Chess960.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'chess960_position'; @@ -15,7 +16,7 @@ ddg_goodie_test( 'chess960 random' => test_zci( 'Chess 960', structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => "text", item => 0, @@ -28,4 +29,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/ChineseZodiac.t b/t/ChineseZodiac.t index 39b2f3f95..e1d71f598 100644 --- a/t/ChineseZodiac.t +++ b/t/ChineseZodiac.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::MockTime qw( :all ); use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -132,4 +133,3 @@ ddg_goodie_test( restore_time(); done_testing; - diff --git a/t/CoffeeToWaterRatio.t b/t/CoffeeToWaterRatio.t index 575717f22..fa429874e 100644 --- a/t/CoffeeToWaterRatio.t +++ b/t/CoffeeToWaterRatio.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "coffee_to_water_ratio"; @@ -79,4 +80,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Coin.t b/t/Coin.t index 7c64ed250..ffc23504d 100644 --- a/t/Coin.t +++ b/t/Coin.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'coin'; @@ -11,85 +12,85 @@ zci is_cached => 0; ddg_goodie_test( [qw( DDG::Goodie::Coin )], 'flip a coin' => test_zci( - qr/(heads|tails) \(random\)/, + re(qr/(heads|tails) \(random\)/), structured_answer => { input => [1], operation => 'Flip coin', - result => qr/^(heads|tails)$/ + result => re(qr/^(heads|tails)$/) } ), 'flip coin' => test_zci( - qr/(heads|tails) \(random\)/, + re(qr/(heads|tails) \(random\)/), structured_answer => { input => [1], operation => 'Flip coin', - result => qr/^(heads|tails)$/ + result => re(qr/^(heads|tails)$/) } ), 'flip 1 coin' => test_zci( - qr/(heads|tails) \(random\)/, + re(qr/(heads|tails) \(random\)/), structured_answer => { input => [1], operation => 'Flip coin', - result => qr/^(heads|tails)$/ + result => re(qr/^(heads|tails)$/) } ), 'flip 2 coins' => test_zci( - qr/(heads|tails), (heads|tails) \(random\)/, + re(qr/(heads|tails), (heads|tails) \(random\)/), structured_answer => { input => [2], operation => 'Flip coin', - result => qr/(heads|tails), / + result => re(qr/(heads|tails), /) } ), 'toss a coin' => test_zci( - qr/(heads|tails) \(random\)/, + re(qr/(heads|tails) \(random\)/), structured_answer => { input => [1], operation => 'Flip coin', - result => qr/^(heads|tails)$/ + result => re(qr/^(heads|tails)$/) } ), 'toss 1 coin' => test_zci( - qr/(heads|tails) \(random\)/, + re(qr/(heads|tails) \(random\)/), structured_answer => { input => [1], operation => 'Flip coin', - result => qr/^(heads|tails)$/ + result => re(qr/^(heads|tails)$/) } ), 'toss 2 coins' => test_zci( - qr/(heads|tails), (heads|tails) \(random\)/, + re(qr/(heads|tails), (heads|tails) \(random\)/), structured_answer => { input => [2], operation => 'Flip coin', - result => qr/(heads|tails), / + result => re(qr/(heads|tails), /) } ), 'heads or tails' => test_zci( - qr/(heads|tails) \(random\)/, + re(qr/(heads|tails) \(random\)/), structured_answer => { input => [1], operation => 'Flip coin', - result => qr/^(heads|tails)$/ + result => re(qr/^(heads|tails)$/) } ), 'heads or tails?' => test_zci( - qr/(heads|tails) \(random\)/, + re(qr/(heads|tails) \(random\)/), structured_answer => { input => [1], operation => 'Flip coin', - result => qr/^(heads|tails)$/ + result => re(qr/^(heads|tails)$/) } ), 'flip 4 coins' => test_zci( - qr/((heads|tails),? ){4}\(random\)/, + re(qr/((heads|tails),? ){4}\(random\)/), structured_answer => { input => [4], operation => 'Flip coin', - result => qr/(heads|tails),? / + result => re(qr/(heads|tails),? /) } ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/ColorCodes.t b/t/ColorCodes.t index da241cc03..613aea0e9 100755 --- a/t/ColorCodes.t +++ b/t/ColorCodes.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'color_code'; @@ -13,7 +14,7 @@ my $green_answer = 'Hex: #00FF00 ~ RGBA(0, 255, 0, 1) ~ RGB(0%, 100%, 0%) ~ HSL( my %basic_answer = ( structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, diff --git a/t/Combination.t b/t/Combination.t index 6c3a2a711..e1ad450b5 100755 --- a/t/Combination.t +++ b/t/Combination.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "combination"; @@ -38,4 +39,4 @@ ddg_goodie_test( '1000000000000 choose 2000' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Constants.t b/t/Constants.t index c2a743637..fae5315e8 100644 --- a/t/Constants.t +++ b/t/Constants.t @@ -4,6 +4,7 @@ use strict; use warnings; use utf8; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "constants"; @@ -54,4 +55,4 @@ ddg_goodie_test( "why?" => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Conversions.t b/t/Conversions.t index 67afa60b5..6cac584f1 100755 --- a/t/Conversions.t +++ b/t/Conversions.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; zci answer_type => 'conversions'; @@ -2815,4 +2816,4 @@ ddg_goodie_test( '1E300 miles in metres' => undef, '5 pas.i to atm' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/ConvertLatLon.t b/t/ConvertLatLon.t index 2f308600d..9cf973e6b 100644 --- a/t/ConvertLatLon.t +++ b/t/ConvertLatLon.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -102,14 +103,14 @@ ddg_goodie_test( 'convert 39.75 degrees to farenheit' => undef, #Check for to-format name - '16.5° S, 68.15° W dms' => test_zci(qr/./, + '16.5° S, 68.15° W dms' => test_zci(re(qr/./), structured_answer => { input => ["16.5° S", "68.15° W"], operation => "Convert to DMS", result => "16° 30′ S, 68° 9′ W", } ), - '16° 30′ S, 68° 9′ W decimal' => test_zci(qr/./, + '16° 30′ S, 68° 9′ W decimal' => test_zci(re(qr/./), structured_answer => { input => ["16° 30′ S", "68° 9′ W"], operation => "Convert to decimal", @@ -119,4 +120,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/CountryCodes.t b/t/CountryCodes.t index d283c8617..f2708625f 100644 --- a/t/CountryCodes.t +++ b/t/CountryCodes.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "country_codes"; @@ -44,4 +45,4 @@ ddg_goodie_test( 'iso code for english' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/CryptHashCheck.t b/t/CryptHashCheck.t index b0e5ff548..76b6747d0 100644 --- a/t/CryptHashCheck.t +++ b/t/CryptHashCheck.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'crypthashcheck'; @@ -171,4 +172,3 @@ ddg_goodie_test( done_testing; - diff --git a/t/CurrencyIn.t b/t/CurrencyIn.t index 5034b5f63..8509db17f 100644 --- a/t/CurrencyIn.t +++ b/t/CurrencyIn.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'currency_in'; @@ -84,4 +85,4 @@ ddg_goodie_test( ) ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Cusip.t b/t/Cusip.t index 440562c68..a9687f580 100644 --- a/t/Cusip.t +++ b/t/Cusip.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "cusip"; @@ -56,7 +57,7 @@ ddg_goodie_test( ), 'cusip check 037833100' => test_zci("037833100 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -64,7 +65,7 @@ ddg_goodie_test( ), 'cusip 844741108' => test_zci("844741108 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -72,7 +73,7 @@ ddg_goodie_test( ), '037833100 cusip' => test_zci("037833100 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -80,7 +81,7 @@ ddg_goodie_test( ), '037833100 cusip check' => test_zci("037833100 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -90,7 +91,7 @@ ddg_goodie_test( # starting white space should be stripped 'cusip 037833100' => test_zci("037833100 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -100,7 +101,7 @@ ddg_goodie_test( # ending white space should be stripped 'cusip 037833100 ' => test_zci("037833100 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -110,7 +111,7 @@ ddg_goodie_test( # starting and ending white space should be stripped 'cusip 037833100 ' => test_zci("037833100 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -120,7 +121,7 @@ ddg_goodie_test( # same AAPL queries with an incorrect check digit 'cusip 03783310A' => test_zci("03783310A is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -128,7 +129,7 @@ ddg_goodie_test( ), 'cusip 03783310A' => test_zci("03783310A is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -136,7 +137,7 @@ ddg_goodie_test( ), 'cusip 03783310A ' => test_zci("03783310A is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -144,7 +145,7 @@ ddg_goodie_test( ), 'cusip 03783310A ' => test_zci("03783310A is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -154,7 +155,7 @@ ddg_goodie_test( # check CUSIP IDs with capital letters (these are for GOOG and Blackberry) 'cusip 38259P706' => test_zci("38259P706 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -162,7 +163,7 @@ ddg_goodie_test( ), 'cusip 38259P508' => test_zci("38259P508 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -170,7 +171,7 @@ ddg_goodie_test( ), 'cusip 09228F103' => test_zci("09228F103 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -180,7 +181,7 @@ ddg_goodie_test( # check the same CUSIP IDs with lower case letters 'cusip 38259p706' => test_zci("38259P706 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -188,7 +189,7 @@ ddg_goodie_test( ), 'cusip 38259p508' => test_zci("38259P508 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -196,7 +197,7 @@ ddg_goodie_test( ), 'cusip 09228f103' => test_zci("09228F103 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -208,7 +209,7 @@ ddg_goodie_test( # if possible, these tests should be replaced with verified CUSIP IDs 'cusip 037833*00' => test_zci("037833*00 is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -216,7 +217,7 @@ ddg_goodie_test( ), 'cusip 037833*02' => test_zci("037833*02 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -224,7 +225,7 @@ ddg_goodie_test( ), 'cusip 0378331#0' => test_zci("0378331#0 is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -232,7 +233,7 @@ ddg_goodie_test( ), 'cusip 0378331#7' => test_zci("0378331#7 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -240,7 +241,7 @@ ddg_goodie_test( ), 'cusip 037833@00' => test_zci("037833\@00 is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -248,7 +249,7 @@ ddg_goodie_test( ), 'cusip 037833@01' => test_zci("037833\@01 is a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -259,7 +260,7 @@ ddg_goodie_test( # even though they are always invalid IDs 'cusip 03783310*' => test_zci("03783310* is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -267,7 +268,7 @@ ddg_goodie_test( ), 'cusip 03783310#' => test_zci("03783310# is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -275,7 +276,7 @@ ddg_goodie_test( ), 'cusip 03783310@' => test_zci("03783310\@ is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -285,7 +286,7 @@ ddg_goodie_test( # Odd CUSIP IDs should not break the IA 'cusip ********8' => test_zci("********8 is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -293,7 +294,7 @@ ddg_goodie_test( ), 'cusip ########9' => test_zci("########9 is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -301,7 +302,7 @@ ddg_goodie_test( ), 'cusip @#*@#*@#*' => test_zci("\@#*\@#*\@#* is not a properly formatted CUSIP number.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', } @@ -310,4 +311,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/DHL.t b/t/DHL.t index a6b24e6a8..6ce5c32ef 100644 --- a/t/DHL.t +++ b/t/DHL.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'dhl'; @@ -28,4 +29,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/DateMath.t b/t/DateMath.t index 061556d84..88b75d3e8 100755 --- a/t/DateMath.t +++ b/t/DateMath.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use Test::MockTime qw( :all ); use DDG::Test::Goodie; use DDG::Test::Location; @@ -125,4 +126,4 @@ location_test([ qw( DDG::Goodie::DateMath ) ], 'time ago' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/DayOfWeek.t b/t/DayOfWeek.t index dbd96b2c9..c2e292529 100644 --- a/t/DayOfWeek.t +++ b/t/DayOfWeek.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use Test::MockTime qw( :all ); @@ -70,4 +71,4 @@ ddg_goodie_test( restore_time(); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/DaysBetween.t b/t/DaysBetween.t index b6c95a8f9..454e626f2 100755 --- a/t/DaysBetween.t +++ b/t/DaysBetween.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use Test::MockTime qw( :all ); @@ -76,57 +77,57 @@ ddg_goodie_test( }, ), 'days between jan 1 and jan 15 inclusive' => test_zci( - qr/^There are 15 days between.+inclusive\.$/, + re(qr/^There are 15 days between.+inclusive\.$/), structured_answer => { - input => '-ANY-', + input => ignore(), operation => 'Days between, inclusive', result => 15 }, ), 'days between jan 1 and 15th feb' => test_zci( - qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/, + re(qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/), structured_answer => { - input => '-ANY-', + input => ignore(), operation => 'Days between', result => 45 }, ), 'number of days between jan 1 and 15th feb' => test_zci( - qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/, + re(qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/), structured_answer => { - input => '-ANY-', + input => ignore(), operation => 'Days between', result => 45 }, ), 'number of days from jan 1 and 15th feb' => test_zci( - qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/, + re(qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/), structured_answer => { - input => '-ANY-', + input => ignore(), operation => 'Days between', result => 45 }, ), 'days from jan 1 and 15th feb' => test_zci( - qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/, + re(qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/), structured_answer => { - input => '-ANY-', + input => ignore(), operation => 'Days between', result => 45 }, ), 'days between today and tomorrow' => test_zci( - qr/^There are 1 days between.+ and.+\.$/, + re(qr/^There are 1 days between.+ and.+\.$/), structured_answer => { - input => '-ANY-', + input => ignore(), operation => 'Days between', result => 1 }, ), 'how many days between feb 2 and feb 17' => test_zci( - qr/^There are 15 days between.+ and.+\.$/, + re(qr/^There are 15 days between.+ and.+\.$/), structured_answer => { - input => '-ANY-', + input => ignore(), operation => 'Days between', result => 15 }, @@ -149,4 +150,4 @@ ddg_goodie_test( ); restore_time(); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Dessert.t b/t/Dessert.t index 3c0dd720d..94b14b270 100644 --- a/t/Dessert.t +++ b/t/Dessert.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'dessert'; @@ -13,81 +14,81 @@ ddg_goodie_test( 'DDG::Goodie::Dessert' ], 'desserts beginning with a' => test_zci( - qr/(.*?) is a dessert that begins with 'a'\.$/, + re(qr/(.*?) is a dessert that begins with 'a'\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'info', } } ), 'desserts beginning with A' => test_zci( - qr/(.*?) is a dessert that begins with 'A'\.$/, + re(qr/(.*?) is a dessert that begins with 'A'\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'info', } } ), 'dessert start with a' => test_zci( - qr/(.*?) is a dessert that begins with 'a'\.$/, + re(qr/(.*?) is a dessert that begins with 'a'\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'info', } } ), 'desserts starting with a' => test_zci( - qr/(.*?) is a dessert that begins with 'a'\.$/, + re(qr/(.*?) is a dessert that begins with 'a'\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'info', } } ), 'dessert starts with a' => test_zci( - qr/(.*?) is a dessert that begins with 'a'\.$/, + re(qr/(.*?) is a dessert that begins with 'a'\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'info', } } ), 'desserts beginning with z' => test_zci( - qr/(.*?) is a dessert that begins with 'z'\.$/, + re(qr/(.*?) is a dessert that begins with 'z'\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'info', } } ), 'a dessert that begins with a' => test_zci( - qr/(.*?) is a dessert that begins with 'a'\.$/, + re(qr/(.*?) is a dessert that begins with 'a'\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'info', } } ), 'a dessert that starts with the letter a' => test_zci( - qr/(.*?) is a dessert that begins with 'a'\.$/, + re(qr/(.*?) is a dessert that begins with 'a'\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'info', } } ), 'dessert that begins with the letter z' => test_zci( - qr/(.*?) is a dessert that begins with 'z'\.$/, + re(qr/(.*?) is a dessert that begins with 'z'\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'info', } @@ -95,4 +96,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Dewey.t b/t/Dewey.t index f86e88eda..1fcb7050a 100644 --- a/t/Dewey.t +++ b/t/Dewey.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'dewey_decimal'; @@ -21,4 +22,4 @@ ddg_goodie_test( 'dewey 644' => test_zci('644 is household utilities in the Dewey Decimal System.', html => '644 is household utilities in the Dewey Decimal System.'), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Dice.t b/t/Dice.t index c08259297..dee3abfc3 100644 --- a/t/Dice.t +++ b/t/Dice.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'dice_roll'; @@ -17,9 +18,9 @@ ddg_goodie_test( # Check trigger kicks in. 'throw dice' => test_zci( - qr/^., .$/, + re(qr/^., .$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -29,9 +30,9 @@ ddg_goodie_test( } ), 'throw dices' => test_zci( - qr/^., .$/, + re(qr/^., .$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -41,9 +42,9 @@ ddg_goodie_test( } ), 'roll dice' => test_zci( - qr/^., .$/, + re(qr/^., .$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -53,9 +54,9 @@ ddg_goodie_test( } ), 'throw die' => test_zci( - qr/^.$/, + re(qr/^.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -68,9 +69,9 @@ ddg_goodie_test( # Simple "dice" query "roll 5 dice" => test_zci( - qr/., ., ., ., .$/, + re(qr/., ., ., ., .$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -82,9 +83,9 @@ ddg_goodie_test( # Simple shorthand query "roll 2d6" => test_zci( - qr/^\d (\+|-) \d$/, + re(qr/^\d (\+|-) \d$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -96,9 +97,9 @@ ddg_goodie_test( # Query with numbers as words "roll five dice" => test_zci( - qr/., ., ., ., .$/, + re(qr/., ., ., ., .$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -108,9 +109,9 @@ ddg_goodie_test( } ), "roll twenty five dice" => test_zci( - qr/., ., ., ., .$/, + re(qr/., ., ., ., .$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -120,9 +121,9 @@ ddg_goodie_test( } ), "roll fifty-four dice" => test_zci( - qr/., ., ., ., .$/, + re(qr/., ., ., ., .$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -132,9 +133,9 @@ ddg_goodie_test( } ), "roll seven dices" => test_zci( - qr/., ., ., ., .$/, + re(qr/., ., ., ., .$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -147,9 +148,9 @@ ddg_goodie_test( "roll foo dice" => undef, "throw 1d20" => test_zci( - qr/^\d{1,2}$/, + re(qr/^\d{1,2}$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -159,9 +160,9 @@ ddg_goodie_test( } ), "roll d20" => test_zci( - qr/^\d{1,2}$/, + re(qr/^\d{1,2}$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -173,9 +174,9 @@ ddg_goodie_test( # Simple shorthand queries with +- "roll 3d12 + 4" => test_zci( - qr/^\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2}$/, + re(qr/^\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2}$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -185,9 +186,9 @@ ddg_goodie_test( } ), "roll 3d8 - 8" => test_zci( - qr/^\d (\+|-) \d (\+|-) \d (\+|-) \d$/, + re(qr/^\d (\+|-) \d (\+|-) \d (\+|-) \d$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -197,9 +198,9 @@ ddg_goodie_test( } ), "roll 4d6-l" => test_zci( - qr/^([1-6] \+ ){3}[1-6] - [1-6]$/, + re(qr/^([1-6] \+ ){3}[1-6] - [1-6]$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -211,9 +212,9 @@ ddg_goodie_test( # Simple conjunctive "dice" query "throw 2 dice and 3 dice" => test_zci( - qr/., .., ., .Total: \d+$/, + re(qr/., .., ., .Total: \d+$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -225,9 +226,9 @@ ddg_goodie_test( # Shorthand conjunctive query "roll 2w6 and d20" => test_zci( - qr/^\d (\+|-) \d = \d+\d+Total: \d+$/, + re(qr/^\d (\+|-) \d = \d+\d+Total: \d+$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -239,9 +240,9 @@ ddg_goodie_test( # Shorthand conjunctive queries with +- "roll 2d6 and 3d12 + 4" => test_zci( - qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/, + re(qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -251,9 +252,9 @@ ddg_goodie_test( } ), "roll 2d6 and 3d12 - 4" => test_zci( - qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = -?\d+Total: \d+$/, + re(qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = -?\d+Total: \d+$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -263,9 +264,9 @@ ddg_goodie_test( } ), "throw 3d12 - 4 and 2d6" => test_zci( - qr/^\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = -?\d{1,2}\d (\+|-) \d = \d+Total: \d+$/, + re(qr/^\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = -?\d{1,2}\d (\+|-) \d = \d+Total: \d+$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -275,9 +276,9 @@ ddg_goodie_test( } ), "throw 2d6 and 3d12 + 4" => test_zci( - qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/, + re(qr/^\d (\+|-) \d = \d+\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -287,9 +288,9 @@ ddg_goodie_test( } ), "roll 2d6 and 4w6-l" => test_zci( - qr/^\d (\+|-) \d = \d+([1-6] \+ ){3}[1-6] - [1-6] = \d{1,2}Total: \d+$/, + re(qr/^\d (\+|-) \d = \d+([1-6] \+ ){3}[1-6] - [1-6] = \d{1,2}Total: \d+$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -299,9 +300,9 @@ ddg_goodie_test( } ), "roll 2 dice and 3d5 + 4" => test_zci( - qr/^., .\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/, + re(qr/^., .\d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} (\+|-) \d{1,2} = \d+Total: \d+$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -325,9 +326,9 @@ ddg_goodie_test( "roll 2d3 and 2d4-a" => undef, "throw die" => test_zci( - qr/^.$/, + re(qr/^.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -338,9 +339,9 @@ ddg_goodie_test( ), 'roll 3d12' => test_zci( - qr/\d{1,2} \+ \d{1,2} \+ \d{1,2}/, + re(qr/\d{1,2} \+ \d{1,2} \+ \d{1,2}/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', options => { @@ -350,9 +351,9 @@ ddg_goodie_test( } ), 'roll 3d12 and 2d4' => test_zci( - qr/\d{1,2} \+ \d{1,2} \+ \d{1,2} = \d+[1-4]+ \+ [1-4]+ = \dTotal: \d+/, + re(qr/\d{1,2} \+ \d{1,2} \+ \d{1,2} = \d+[1-4]+ \+ [1-4]+ = \dTotal: \d+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -362,9 +363,9 @@ ddg_goodie_test( } ), 'roll 2 dice and 3d5' => test_zci( - qr/[1-5]+ \+ [1-5]+ \+ [1-5]+ = \d+Total: \d+/, + re(qr/[1-5]+ \+ [1-5]+ \+ [1-5]+ = \d+Total: \d+/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -375,4 +376,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/DuckDuckGo.t b/t/DuckDuckGo.t index 24937e376..03ba8dd74 100644 --- a/t/DuckDuckGo.t +++ b/t/DuckDuckGo.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'duckduckgo'; @@ -174,4 +175,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/EmToPx.t b/t/EmToPx.t index eeffc5b0b..4032ab02b 100644 --- a/t/EmToPx.t +++ b/t/EmToPx.t @@ -1,6 +1,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'conversion'; @@ -41,4 +42,4 @@ ddg_goodie_test( '11px to em at base-pixel size 23px' => build_test('0.478em', '11', 'px', '23'), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/EmailValidator.t b/t/EmailValidator.t index 814e7bed1..356c1d48e 100644 --- a/t/EmailValidator.t +++ b/t/EmailValidator.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'email_validation'; @@ -11,63 +12,63 @@ zci is_cached => 1; ddg_goodie_test( ['DDG::Goodie::EmailValidator'], 'validate my email foo@example.com' => test_zci( - qr/appears to be valid/, + re(qr/appears to be valid/), structured_answer => { input => ['foo@example.com'], operation => 'Email address validation', - result => qr/appears to be valid/ + result => re(qr/appears to be valid/) } ), 'validate my email foo+abc@example.com' => test_zci( - qr/appears to be valid/, + re(qr/appears to be valid/), structured_answer => { input => ['foo+abc@example.com'], operation => 'Email address validation', - result => qr/appears to be valid/ + result => re(qr/appears to be valid/) } ), 'validate my email foo.bar@example.com' => test_zci( - qr/appears to be valid/, + re(qr/appears to be valid/), structured_answer => { input => ['foo.bar@example.com'], operation => 'Email address validation', - result => qr/appears to be valid/ + result => re(qr/appears to be valid/) } ), 'validate user@exampleaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com' => test_zci( - qr/Please check the address/, + re(qr/Please check the address/), structured_answer => { - input => '-ANY-', + input => ignore(), operation => 'Email address validation', - result => qr/Please check the address/, + result => re(qr/Please check the address/), } ), 'validate foo@example.com' => test_zci( - qr/appears to be valid/, + re(qr/appears to be valid/), structured_answer => { input => ['foo@example.com'], operation => 'Email address validation', - result => qr/appears to be valid/ + result => re(qr/appears to be valid/) } ), 'validate foo@!!!.com' => test_zci( - qr/Please check the fully qualified domain name/, + re(qr/Please check the fully qualified domain name/), structured_answer => { input => ['foo@!!!.com'], operation => 'Email address validation', - result => qr/Please check the fully qualified domain name/, + result => re(qr/Please check the fully qualified domain name/), } ), 'validate foo@example.lmnop' => test_zci( - qr/Please check the top-level domain/, + re(qr/Please check the top-level domain/), structured_answer => { input => ['foo@example.lmnop'], operation => 'Email address validation', - result => qr/Please check the top-level domain/, + result => re(qr/Please check the top-level domain/), } ), 'validate foo' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/FIGlet.t b/t/FIGlet.t index 9969bc75e..edb5d6ee2 100644 --- a/t/FIGlet.t +++ b/t/FIGlet.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'figlet'; @@ -205,4 +206,4 @@ ddg_goodie_test( 'big text' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Factors.t b/t/Factors.t index 6d51457b0..99b375180 100755 --- a/t/Factors.t +++ b/t/Factors.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "factors"; @@ -30,4 +31,4 @@ ddg_goodie_test( '72 factors' => build_test('Factors of 72: 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72', '72', '1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72'), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/FedEx.t b/t/FedEx.t index bf55ceef7..084d707ad 100644 --- a/t/FedEx.t +++ b/t/FedEx.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'fedex'; @@ -33,4 +34,4 @@ ddg_goodie_test( ) ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/FenViewer.t b/t/FenViewer.t index 409ac0716..9564d77b8 100644 --- a/t/FenViewer.t +++ b/t/FenViewer.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "fen_viewer"; @@ -20,4 +21,4 @@ ddg_goodie_test( 'fen ' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Fibonacci.t b/t/Fibonacci.t index d20894bb4..9c2ef1df4 100644 --- a/t/Fibonacci.t +++ b/t/Fibonacci.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'fibonacci'; @@ -30,4 +31,4 @@ ddg_goodie_test( 'what are fibonacci numbers?' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/FirefoxOS.t b/t/FirefoxOS.t index 3f33b7c3b..78f52c599 100644 --- a/t/FirefoxOS.t +++ b/t/FirefoxOS.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "firefoxos"; @@ -10,7 +11,7 @@ zci is_cached => 1; #Structured answer template data my $templateData = { - data => '-ANY-', + data => ignore(), meta => { sourceName => "Mozilla Developer Network", sourceUrl => "https://developer.mozilla.org/en-US/Apps/Reference/Firefox_OS_device_APIs" @@ -39,4 +40,4 @@ ddg_goodie_test( 'firefox os api' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/FlipText.t b/t/FlipText.t index b072035aa..9f2eb296c 100644 --- a/t/FlipText.t +++ b/t/FlipText.t @@ -4,6 +4,7 @@ use strict; use warnings; use utf8; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'flip_text'; @@ -38,4 +39,4 @@ ddg_goodie_test( 'spin text <<"hello\' % & * () = + . #@!^(/world">>' => build_test('<<"hello\' % & * () = + . #@!^(/world">>','<<„pʃɹoʍ/)∨¡@# ˙ + = () ⁎ ⅋ % ,oʃʃǝɥ„>>'), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Fortune.t b/t/Fortune.t index 07ccd8613..11c3a6c06 100755 --- a/t/Fortune.t +++ b/t/Fortune.t @@ -34,4 +34,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/Frequency.t b/t/Frequency.t index 7b2e74462..c290115da 100644 --- a/t/Frequency.t +++ b/t/Frequency.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci is_cached => 1; @@ -26,4 +27,4 @@ ddg_goodie_test( 'frequency of B in battle' => test_zci('Frequency: b:1/6'), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/FrequencySpectrum.t b/t/FrequencySpectrum.t index 0ad605e6f..a7ca29c7e 100644 --- a/t/FrequencySpectrum.t +++ b/t/FrequencySpectrum.t @@ -8,6 +8,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'frequency_spectrum'; @@ -18,10 +19,10 @@ ddg_goodie_test( #Primary example '50 hz' => test_zci( - #qr/radio.+SLF.+audible.+double-bass.+piano.+tuba/, - qr/radio/, + #re(qr/radio.+SLF.+audible.+double-bass.+piano.+tuba/), + re(qr/radio/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -34,9 +35,9 @@ ddg_goodie_test( #Secondary example '400 thz' => test_zci( - qr/infrared/, + re(qr/infrared/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -49,10 +50,10 @@ ddg_goodie_test( #Misc '1,000 hz' => test_zci( - #qr/radio.+audible.+human.+voice.+viola.+violin.+guitar.+mandolin.+banjo.+piano.+saxophone.+flute.+clarinet.+oboe/, - qr/radio/, + #re(qr/radio.+audible.+human.+voice.+viola.+violin.+guitar.+mandolin.+banjo.+piano.+saxophone.+flute.+clarinet.+oboe/), + re(qr/radio/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -63,9 +64,9 @@ ddg_goodie_test( } ), '1000000.99 hz' => test_zci( - qr/radio.+MF/, + re(qr/radio.+MF/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -76,9 +77,9 @@ ddg_goodie_test( } ), '29.1 hz' => test_zci( - qr/radio.+ELF/, + re(qr/radio.+ELF/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -91,10 +92,10 @@ ddg_goodie_test( #No whitespace between number and unit '50hz' => test_zci( - #qr/radio.+SLF.+audible.+double-bass.+piano.+tuba/, - qr/radio/, + #re(qr/radio.+SLF.+audible.+double-bass.+piano.+tuba/), + re(qr/radio/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -105,9 +106,9 @@ ddg_goodie_test( } ), '400terahertz' => test_zci( - qr/infrared/, + re(qr/infrared/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -120,9 +121,9 @@ ddg_goodie_test( #Mixed case '400 THz' => test_zci( - qr/infrared/, + re(qr/infrared/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -134,10 +135,10 @@ ddg_goodie_test( ), '1000 HZ' => test_zci( - #qr/radio.+audible.+human.+voice.+viola.+violin.+guitar.+mandolin.+banjo.+piano.+saxophone.+flute.+clarinet.+oboe/, - qr/radio/, + #re(qr/radio.+audible.+human.+voice.+viola.+violin.+guitar.+mandolin.+banjo.+piano.+saxophone.+flute.+clarinet.+oboe/), + re(qr/radio/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -150,9 +151,9 @@ ddg_goodie_test( #Commas in number '1,000,000.99 hz' => test_zci( - qr/radio.+MF/, + re(qr/radio.+MF/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -165,9 +166,9 @@ ddg_goodie_test( #Can you test with all the colours of the wind? '650 nm' => test_zci( - qr/visible.+red/, + re(qr/visible.+red/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -178,9 +179,9 @@ ddg_goodie_test( } ), '610 nanometers' => test_zci( - qr/visible.+orange/, + re(qr/visible.+orange/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -191,9 +192,9 @@ ddg_goodie_test( } ), '580 nanometres' => test_zci( - qr/visible.+yellow/, + re(qr/visible.+yellow/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -204,9 +205,9 @@ ddg_goodie_test( } ), '536 nanometer' => test_zci( - qr/visible.+green/, + re(qr/visible.+green/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -217,9 +218,9 @@ ddg_goodie_test( } ), '478.1 nm' => test_zci( - qr/visible.+blue/, + re(qr/visible.+blue/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -230,9 +231,9 @@ ddg_goodie_test( } ), '380.000000000 nanometres' => test_zci( - qr/visible.+violet/, + re(qr/visible.+violet/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -258,4 +259,4 @@ ddg_goodie_test( '600 nmeters' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/GUID.t b/t/GUID.t index 2d3305887..e524ea9c1 100644 --- a/t/GUID.t +++ b/t/GUID.t @@ -3,12 +3,13 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'guid'; zci is_cached => 0; -my @answer = (qr/^([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}$/, structured_answer => { input =>[], operation => 'Random GUID', result =>qr/^([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}$/}); +my @answer = (re(qr/^([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}$/), structured_answer => { input =>[], operation => 'Random GUID', result =>re(qr/^([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}$/)}); ddg_goodie_test([qw( DDG::Goodie::GUID ) ], @@ -25,4 +26,4 @@ ddg_goodie_test([qw( DDG::Goodie::GUID ) ], 'what is a guid' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Game2048.t b/t/Game2048.t index 0c5cc0acd..b3bc9e359 100644 --- a/t/Game2048.t +++ b/t/Game2048.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 2048; @@ -16,7 +17,7 @@ ddg_goodie_test( 'Play 2048', structured_answer => { - data => '-ANY-', + data => ignore(), # data => [{ # dimension => 4, @@ -35,7 +36,7 @@ ddg_goodie_test( 'Play 256', structured_answer => { - data => '-ANY-', + data => ignore(), # data => [{ # dimension => 7, @@ -53,4 +54,4 @@ ddg_goodie_test( '2048 online' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/GenerateMAC.t b/t/GenerateMAC.t index 17c42c159..7c7c3f6ad 100755 --- a/t/GenerateMAC.t +++ b/t/GenerateMAC.t @@ -35,4 +35,4 @@ ddg_goodie_test( 'please generate mac address' => build_test(), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/GibberishGenerator.t b/t/GibberishGenerator.t index 6bef76272..d1e618cfe 100644 --- a/t/GibberishGenerator.t +++ b/t/GibberishGenerator.t @@ -1,6 +1,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -9,8 +10,8 @@ zci is_cached => 0; sub build_result { my $result = shift; - return $result, structured_answer => { - data => "-ANY-", + return re($result), structured_answer => { + data => ignore(), templates => { group => 'info', options => { @@ -75,4 +76,4 @@ ddg_goodie_test( '30 words of utter Shakespearean nonsense' => build_test(werds($shake_word, 30)), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/GoldenRatio.t b/t/GoldenRatio.t index aa7835357..b44103044 100644 --- a/t/GoldenRatio.t +++ b/t/GoldenRatio.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'golden_ratio'; @@ -29,4 +30,4 @@ ddg_goodie_test( 'golden ratio ?:123.345' => test_zci('Golden ratio: 76.2314023423558 : 123.345'), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/GreatestCommonFactor.t b/t/GreatestCommonFactor.t index 22c726c27..836b0d9f2 100644 --- a/t/GreatestCommonFactor.t +++ b/t/GreatestCommonFactor.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "greatest_common_factor"; @@ -46,4 +47,4 @@ ddg_goodie_test( 'gcd 0 0' => build_test('0 and 0', 0), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/GuitarChords.t b/t/GuitarChords.t index bfcf508aa..4dcc6e5ad 100644 --- a/t/GuitarChords.t +++ b/t/GuitarChords.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'guitarchord'; @@ -14,32 +15,32 @@ ddg_goodie_test( 'G#m6 guitar chord' => test_zci( 'G#m6', heading=>'G#m6', - html => qr#.*Guitar chord diagram for G\#m6.*#s + html => re(qr#.*Guitar chord diagram for G\#m6.*#s) ), 'Abaug7 guitar chord' => test_zci( 'Abaug7', heading=>'Abaug7', - html => qr#.*Guitar chord diagram for Abaug7.*#s + html => re(qr#.*Guitar chord diagram for Abaug7.*#s) ), 'A7/b9 guitar chord' => test_zci( 'A7(b9)', heading=>'A7(b9)', - html => qr#.*Guitar chord diagram for A7\(b9\).*#s + html => re(qr#.*Guitar chord diagram for A7\(b9\).*#s) ), 'guitar chord Cm7' => test_zci( 'Cm7', heading=>'Cm7', - html => qr#.*Guitar chord diagram for Cm7.*#s + html => re(qr#.*Guitar chord diagram for Cm7.*#s) ), 'guitar chord Db7sus4' => test_zci( 'Db7sus4', heading=>'Db7sus4', - html => qr#.*Guitar chord diagram for Db7sus4.*#s + html => re(qr#.*Guitar chord diagram for Db7sus4.*#s) ), 'guitar chord f min' => test_zci( 'Fm', heading=>'Fm', - html => qr#.*Guitar chord diagram for Fm.*#s + html => re(qr#.*Guitar chord diagram for Fm.*#s) ), # check that certain things don't trigger it: 'C# programming' => undef, @@ -50,4 +51,4 @@ ddg_goodie_test( 'G' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/HKDK.t b/t/HKDK.t index 0c73e99f5..0b59b18fa 100644 --- a/t/HKDK.t +++ b/t/HKDK.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'hkdk'; @@ -23,4 +24,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/HTMLEntitiesDecode.t b/t/HTMLEntitiesDecode.t index 681016276..d45f76797 100755 --- a/t/HTMLEntitiesDecode.t +++ b/t/HTMLEntitiesDecode.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'html_entity'; @@ -10,8 +11,8 @@ zci is_cached => 1; sub any_structured_answer { return { - input => '-ANY-', - result => '-ANY-', + input => ignore(), + result => ignore(), operation => "HTML Entity Decode" }; } @@ -36,9 +37,9 @@ ddg_goodie_test( 'htmlentity for #x3c' => test_zci("Decoded HTML Entity: <", structured_answer => any_structured_answer()), # "¢" succeeds - 'html decode ¢' => test_zci(qr/.*/, structured_answer => any_structured_answer()), + 'html decode ¢' => test_zci(re(qr/.*/), structured_answer => any_structured_answer()), # "¢" also succeeds (missing back ";" is OK) - 'html decode ¢' => test_zci(qr/.*/, structured_answer => any_structured_answer()), + 'html decode ¢' => test_zci(re(qr/.*/), structured_answer => any_structured_answer()), # "cent" fails during the regex match because of the missing front "&" (stricter for text to eliminate false positive encoding hits) 'html decode cent' => undef, # "cent;" fails during the regex match for the same reasons as above @@ -55,11 +56,11 @@ ddg_goodie_test( 'html decode apostrophe' => undef, # natural querying - 'What is the decoded html entity for π?' => test_zci(qr/.*/, structured_answer => any_structured_answer()), + 'What is the decoded html entity for π?' => test_zci(re(qr/.*/), structured_answer => any_structured_answer()), # natural querying - 'what is decoded html entity for #960 ?' => test_zci(qr/.*/, structured_answer => any_structured_answer()), + 'what is decoded html entity for #960 ?' => test_zci(re(qr/.*/), structured_answer => any_structured_answer()), # no "html" in query - 'the decoded entity for ō is?' => test_zci(qr/.*/, structured_answer => any_structured_answer()), + 'the decoded entity for ō is?' => test_zci(re(qr/.*/), structured_answer => any_structured_answer()), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/HTMLEntitiesEncode.t b/t/HTMLEntitiesEncode.t index 191f23f3f..5be90e191 100755 --- a/t/HTMLEntitiesEncode.t +++ b/t/HTMLEntitiesEncode.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -12,7 +13,7 @@ zci is_cached => 1; sub make_structured_answer { my ($qr) = @_; return { - input => '-ANY-', + input => ignore(), operation => "HTML Entity Encode", result => $qr, }; @@ -40,26 +41,26 @@ ddg_goodie_test( [qw(DDG::Goodie::HTMLEntitiesEncode)], # Simple tests - 'html code em dash' => test_zci("Encoded HTML Entity: —", structured_answer => make_structured_answer(qr/mdash/)), - 'html em dash' => test_zci("Encoded HTML Entity: —", structured_answer => make_structured_answer(qr/mdash/)), - 'em-dash html' => test_zci("Encoded HTML Entity: —", structured_answer => make_structured_answer(qr/mdash/)), # hyphens ignored - 'html encode "em-dash"' => test_zci("Encoded HTML Entity: —", structured_answer => make_structured_answer(qr/mdash/)), # quotes ignored - 'ApoSTrophe escapehtml' => test_zci("Encoded HTML Entity: '", structured_answer => make_structured_answer(qr/#39/)), # mixed cases in query + 'html code em dash' => test_zci("Encoded HTML Entity: —", structured_answer => make_structured_answer(re(qr/mdash/))), + 'html em dash' => test_zci("Encoded HTML Entity: —", structured_answer => make_structured_answer(re(qr/mdash/))), + 'em-dash html' => test_zci("Encoded HTML Entity: —", structured_answer => make_structured_answer(re(qr/mdash/))), # hyphens ignored + 'html encode "em-dash"' => test_zci("Encoded HTML Entity: —", structured_answer => make_structured_answer(re(qr/mdash/))), # quotes ignored + 'ApoSTrophe escapehtml' => test_zci("Encoded HTML Entity: '", structured_answer => make_structured_answer(re(qr/#39/))), # mixed cases in query # Basic varieties in querying accented chars - 'html entity A-acute' => test_zci("Encoded HTML Entity: Á",structured_answer => make_structured_answer(qr/Aacute/)), - 'html entity for E Grave' => test_zci("Encoded HTML Entity: È", structured_answer => make_structured_answer(qr/Egrave/)), - 'html Ograve' => test_zci("Encoded HTML Entity: Ò", structured_answer => make_structured_answer(qr/Ograve/)), + 'html entity A-acute' => test_zci("Encoded HTML Entity: Á",structured_answer => make_structured_answer(re(qr/Aacute/))), + 'html entity for E Grave' => test_zci("Encoded HTML Entity: È", structured_answer => make_structured_answer(re(qr/Egrave/))), + 'html Ograve' => test_zci("Encoded HTML Entity: Ò", structured_answer => make_structured_answer(re(qr/Ograve/))), # Single typed-in character queries - 'html escape &' => test_zci("Encoded HTML Entity: &", structured_answer => make_structured_answer(qr/amp/)), # & - 'html escape "' => test_zci("Encoded HTML Entity: "", structured_answer => make_structured_answer(qr/quot/)), # " - 'how to html escape &?' => test_zci("Encoded HTML Entity: &", structured_answer => make_structured_answer(qr/amp/)), # ? - 'how to html escape "&"?' => test_zci("Encoded HTML Entity: &", structured_answer => make_structured_answer(qr/amp/)), # & - 'how to html escape ??' => test_zci("Encoded HTML Entity: ?", structured_answer => make_structured_answer(qr/#63/)), # ? - 'how do you html escape a "?"?' => test_zci("Encoded HTML Entity: ?", structured_answer => make_structured_answer(qr/#63/)), # ? - 'html escape """' => test_zci("Encoded HTML Entity: "", structured_answer => make_structured_answer(qr/quot/)), # " - '$ sign htmlentity' => test_zci("Encoded HTML Entity: $", structured_answer => make_structured_answer(qr/#36/)), # $ + 'html escape &' => test_zci("Encoded HTML Entity: &", structured_answer => make_structured_answer(re(qr/amp/))), # & + 'html escape "' => test_zci("Encoded HTML Entity: "", structured_answer => make_structured_answer(re(qr/quot/))), # " + 'how to html escape &?' => test_zci("Encoded HTML Entity: &", structured_answer => make_structured_answer(re(qr/amp/))), # ? + 'how to html escape "&"?' => test_zci("Encoded HTML Entity: &", structured_answer => make_structured_answer(re(qr/amp/))), # & + 'how to html escape ??' => test_zci("Encoded HTML Entity: ?", structured_answer => make_structured_answer(re(qr/#63/))), # ? + 'how do you html escape a "?"?' => test_zci("Encoded HTML Entity: ?", structured_answer => make_structured_answer(re(qr/#63/))), # ? + 'html escape """' => test_zci("Encoded HTML Entity: "", structured_answer => make_structured_answer(re(qr/quot/))), # " + '$ sign htmlentity' => test_zci("Encoded HTML Entity: $", structured_answer => make_structured_answer(re(qr/#36/))), # $ # Return two matching entities for ambiguous query 'pound symbol html encode ' => test_zci( @@ -71,9 +72,9 @@ ddg_goodie_test( ), # Ignore words and whitespace - 'html code of pilcrow sign' => test_zci("Encoded HTML Entity: ¶", structured_answer => make_structured_answer(qr/#182/)), # of, sign - 'html escape greater than symbol' => test_zci("Encoded HTML Entity: >", structured_answer => make_structured_answer(qr/gt/)), # symbol - 'space html character code' => test_zci("Encoded HTML Entity:  ", structured_answer => make_structured_answer(qr/nbsp/)), # Ignore extra whitespace + 'html code of pilcrow sign' => test_zci("Encoded HTML Entity: ¶", structured_answer => make_structured_answer(re(qr/#182/))), # of, sign + 'html escape greater than symbol' => test_zci("Encoded HTML Entity: >", structured_answer => make_structured_answer(re(qr/gt/))), # symbol + 'space html character code' => test_zci("Encoded HTML Entity:  ", structured_answer => make_structured_answer(re(qr/nbsp/))), # Ignore extra whitespace # Better hash hits substitutions # 'right angle brackets' should work even though the defined key contains the singular 'bracket' @@ -85,7 +86,7 @@ ddg_goodie_test( }, ["Single right pointing angle quote (›)", "Double right pointing angle quote (»)"], "right angle brackets") ), # 'double quotes' should work even though the defined key contains the singular 'quote' - 'double quotes htmlescape' => test_zci("Encoded HTML Entity: "", structured_answer => make_structured_answer(qr/quot/)), + 'double quotes htmlescape' => test_zci("Encoded HTML Entity: "", structured_answer => make_structured_answer(re(qr/quot/))), # Should not work 'html encode +' => undef, @@ -93,24 +94,24 @@ ddg_goodie_test( 'html encode is it magic' => undef, # Natural querying - 'What is the html character code for pi' => test_zci("Encoded HTML Entity: π", structured_answer => make_structured_answer(qr/#960/)), - 'whatis html entity for en-dash' => test_zci("Encoded HTML Entity: –", structured_answer => make_structured_answer(qr/ndash/)), # whatis spelling - 'how do I escape the greater-than symbol html' => test_zci("Encoded HTML Entity: >", structured_answer => make_structured_answer(qr/gt/)), + 'What is the html character code for pi' => test_zci("Encoded HTML Entity: π", structured_answer => make_structured_answer(re(qr/#960/))), + 'whatis html entity for en-dash' => test_zci("Encoded HTML Entity: –", structured_answer => make_structured_answer(re(qr/ndash/))), # whatis spelling + 'how do I escape the greater-than symbol html' => test_zci("Encoded HTML Entity: >", structured_answer => make_structured_answer(re(qr/gt/))), # the "a/A" belonging to "acute" matters, but the "a" immediately after "character" is removed - 'How to get a a acute character in html code' => test_zci("Encoded HTML Entity: á", structured_answer => make_structured_answer(qr/aacute/)), - 'how to get a a-acute character in html code' => test_zci("Encoded HTML Entity: á", structured_answer => make_structured_answer(qr/aacute/)), - 'how to get a aacute character in html code' => test_zci("Encoded HTML Entity: á", structured_answer => make_structured_answer(qr/aacute/)), - 'how to get a A acute character in html code' => test_zci("Encoded HTML Entity: Á", structured_answer => make_structured_answer(qr/Aacute/)), - 'how to get a A-acute character in html code' => test_zci("Encoded HTML Entity: Á", structured_answer => make_structured_answer(qr/Aacute/)), - 'how to get a Aacute character in html code' => test_zci("Encoded HTML Entity: Á", structured_answer => make_structured_answer(qr/Aacute/)), + 'How to get a a acute character in html code' => test_zci("Encoded HTML Entity: á", structured_answer => make_structured_answer(re(qr/aacute/))), + 'how to get a a-acute character in html code' => test_zci("Encoded HTML Entity: á", structured_answer => make_structured_answer(re(qr/aacute/))), + 'how to get a aacute character in html code' => test_zci("Encoded HTML Entity: á", structured_answer => make_structured_answer(re(qr/aacute/))), + 'how to get a A acute character in html code' => test_zci("Encoded HTML Entity: Á", structured_answer => make_structured_answer(re(qr/Aacute/))), + 'how to get a A-acute character in html code' => test_zci("Encoded HTML Entity: Á", structured_answer => make_structured_answer(re(qr/Aacute/))), + 'how to get a Aacute character in html code' => test_zci("Encoded HTML Entity: Á", structured_answer => make_structured_answer(re(qr/Aacute/))), # Question marks ignored - 'the encoded html entity of apostrophe is?' => test_zci("Encoded HTML Entity: '", structured_answer => make_structured_answer(qr/#39/)), - 'how to encode an apostrophe in html ? ' => test_zci("Encoded HTML Entity: '", structured_answer => make_structured_answer(qr/#39/)), # spaces around the end + 'the encoded html entity of apostrophe is?' => test_zci("Encoded HTML Entity: '", structured_answer => make_structured_answer(re(qr/#39/))), + 'how to encode an apostrophe in html ? ' => test_zci("Encoded HTML Entity: '", structured_answer => make_structured_answer(re(qr/#39/))), # spaces around the end # Question mark matters - 'how to encode "?" in html' => test_zci("Encoded HTML Entity: ?", structured_answer => make_structured_answer(qr/#63/)), + 'how to encode "?" in html' => test_zci("Encoded HTML Entity: ?", structured_answer => make_structured_answer(re(qr/#63/))), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/HelpLine.t b/t/HelpLine.t index d0ff672db..45f00e113 100644 --- a/t/HelpLine.t +++ b/t/HelpLine.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use DDG::Test::Location; use DDG::Request; @@ -48,7 +49,7 @@ ddg_goodie_test( query_raw => "$query", location => test_location("$locations[$_]") ), - test_zci(qr/24 Hour Suicide Hotline/, structured_answer => { input => [], operation => qr/24 Hour Suicide Hotline/, result => qr/[0-9]{2}/}), + test_zci(re(qr/24 Hour Suicide Hotline/), structured_answer => { input => [], operation => re(qr/24 Hour Suicide Hotline/), result => re(qr/[0-9]{2}/)}), } 0 .. scalar @locations - 1 } 0 .. scalar @queries - 1), (map { @@ -63,4 +64,4 @@ ddg_goodie_test( } 0 .. scalar @ok_queries - 1), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/HexToASCII.t b/t/HexToASCII.t index ab1531e0c..ffab0cf03 100644 --- a/t/HexToASCII.t +++ b/t/HexToASCII.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'ascii'; @@ -35,4 +36,4 @@ ddg_goodie_test( 'ascii 0x466f7220736f6d6520726561736f6e2c2049206465636964656420746f2061736b20612073656172636820656e67696e6520746f20636f6e766572742068657820746f2041534349492e0d0a436f6f6c2c20746869732073656172636820656e67696e6520646f65732069742c20756e74696c20492072756e206f7574206f662073706163652e' => build_test('0x466f7220736f6d6520726561736f6e2c2049206465636964656420746f2061736b20612073656172636820656e67696e6520746f20636f6e766572742068657820746f2041534349492e0d0a436f6f6c2c20746869732073656172636820656e67696e6520646f65732069742c20756e74696c20492072756e206f7574206f662073706163652e', 'For some reason, I decided to ask a search engine to convert hex to ASCII.[CR][LF]Cool, this search engine does it, until I run out of …'), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/HexToDec.t b/t/HexToDec.t index cf430da76..4396a2570 100755 --- a/t/HexToDec.t +++ b/t/HexToDec.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'hex_to_dec'; @@ -62,4 +63,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/IDN.t b/t/IDN.t index 91468d836..c3c39914b 100644 --- a/t/IDN.t +++ b/t/IDN.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -27,4 +28,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/IPS.t b/t/IPS.t index af5d1d536..4d62ddf61 100644 --- a/t/IPS.t +++ b/t/IPS.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'ips'; @@ -28,4 +29,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/ISO639.t b/t/ISO639.t index e8da4eb80..defe46f81 100644 --- a/t/ISO639.t +++ b/t/ISO639.t @@ -5,6 +5,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "iso639"; @@ -55,4 +56,4 @@ ddg_goodie_test( "iso639 xyz" => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/IndependenceDay.t b/t/IndependenceDay.t index 4e7961c8e..9c4097a6e 100644 --- a/t/IndependenceDay.t +++ b/t/IndependenceDay.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use Locale::Country; @@ -50,4 +51,4 @@ ddg_goodie_test( "day of independence of bhutan" => answer("Bhutan", "December 17th, 1907") ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Jira.t b/t/Jira.t index c2c4789f8..fa3a63d4f 100644 --- a/t/Jira.t +++ b/t/Jira.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'jira'; @@ -61,4 +62,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/JohnCena.t b/t/JohnCena.t index d49d8134d..8cb531dae 100644 --- a/t/JohnCena.t +++ b/t/JohnCena.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "john_cena"; @@ -32,4 +33,4 @@ ddg_goodie_test( 'famous wrestler' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Kana.t b/t/Kana.t index 91e76311c..9d14d6e72 100755 --- a/t/Kana.t +++ b/t/Kana.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -179,4 +180,4 @@ ddg_goodie_test( 'ハ.ツha.tsu in romaji' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/KernelTaint.t b/t/KernelTaint.t index 3cb14d1ec..9a6192cfa 100644 --- a/t/KernelTaint.t +++ b/t/KernelTaint.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'kernel_taint'; @@ -19,4 +20,4 @@ ddg_goodie_test( '2 kernel taint description' => test_zci('- A module was force loaded by insmod -f. Set by modutils >= 2.4.9 and module-init-tools.', html => '
  • A module was force loaded by insmod -f. Set by modutils >= 2.4.9 and module-init-tools.
Read more') ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/LaserShip.t b/t/LaserShip.t index 11df69b33..5d417181d 100644 --- a/t/LaserShip.t +++ b/t/LaserShip.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'lasership'; @@ -24,4 +25,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/Latex.t b/t/Latex.t index e7b2b08b5..ef41a96b3 100644 --- a/t/Latex.t +++ b/t/Latex.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'Latex'; @@ -14,17 +15,17 @@ ddg_goodie_test( )], "latex integral" => test_zci('LaTeX command: \int_lowerbound^upperbound Example: $\int_a^b f(x)dx$', - html => qr/\\int_lowerbound\^upperbound/, + html => re(qr/\\int_lowerbound\^upperbound/), heading => 'Integral (LaTeX)'), "tex integral" => test_zci('LaTeX command: \int_lowerbound^upperbound Example: $\int_a^b f(x)dx$', - html => qr/\\int_lowerbound\^upperbound/, + html => re(qr/\\int_lowerbound\^upperbound/), heading => 'Integral (LaTeX)'), 'latex summation' => test_zci('LaTeX command: \sum_{lower}^{upper} Example: $\sum_{i=0}^{10} x^{2}$', - html => qr/\\sum_\{lower\}\^\{upper\}/, + html => re(qr/\\sum_\{lower\}\^\{upper\}/), heading => 'Summation (LaTeX)'), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/LeapYear.t b/t/LeapYear.t index a7eeece34..9bf07f3e2 100755 --- a/t/LeapYear.t +++ b/t/LeapYear.t @@ -5,6 +5,7 @@ use warnings; use Test::MockTime qw( :all ); use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'leap_year'; @@ -137,4 +138,4 @@ ddg_goodie_test( ); restore_time(); -done_testing(); +done_testing(); \ No newline at end of file diff --git a/t/LeetSpeak.t b/t/LeetSpeak.t index 322e140e1..000c5e0f4 100644 --- a/t/LeetSpeak.t +++ b/t/LeetSpeak.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -56,4 +57,4 @@ ddg_goodie_test( 'l33tsp34k' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Loan.t b/t/Loan.t index 8aca23365..cd5e9c581 100644 --- a/t/Loan.t +++ b/t/Loan.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use DDG::Test::Location; use DDG::Request; @@ -237,4 +238,4 @@ ddg_goodie_test ( ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/LoremIpsum.t b/t/LoremIpsum.t index 71e40b64a..b67300c96 100644 --- a/t/LoremIpsum.t +++ b/t/LoremIpsum.t @@ -1,6 +1,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -9,8 +10,8 @@ zci is_cached => 0; sub build_result { my $result = shift; - return $result, structured_answer => { - data => "-ANY-", + return re($result), structured_answer => { + data => ignore(), meta => { sourceName => "Lipsum", sourceUrl => "http://lipsum.com/" @@ -83,4 +84,4 @@ ddg_goodie_test( ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Lowercase.t b/t/Lowercase.t index 8b8894d64..c66172dfb 100755 --- a/t/Lowercase.t +++ b/t/Lowercase.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'lowercase'; @@ -38,4 +39,4 @@ ddg_goodie_test( 'how to lowercase text' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/MD4.t b/t/MD4.t index a6f29452a..68b81b136 100644 --- a/t/MD4.t +++ b/t/MD4.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "md4"; @@ -85,4 +86,4 @@ ddg_goodie_test( 'md5 this string' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/MD5.t b/t/MD5.t index 1d8ec8560..f73410474 100644 --- a/t/MD5.t +++ b/t/MD5.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'md5'; @@ -180,4 +181,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/MacAddress.t b/t/MacAddress.t index 92bd8f181..2d90d65c2 100644 --- a/t/MacAddress.t +++ b/t/MacAddress.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "mac_address"; @@ -57,4 +58,4 @@ ddg_goodie_test( 'mac address 1E:00:00:00:00:00' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/MagicEightBall.t b/t/MagicEightBall.t index 3794f532d..c63e556cc 100644 --- a/t/MagicEightBall.t +++ b/t/MagicEightBall.t @@ -3,14 +3,15 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "magic_eight_ball"; zci is_cached => 0; -my $possibleAnswers = qr/(It is certain|It is decidedly so|Without a doubt|Yes, definitely|You may rely on it|As I see it, yes|Most likely|Outlook good|Yes|Signs point to yes|Reply hazy try again|Ask again later|Better not tell you now|Cannot predict now|Concentrate and ask again|Don't count on it|My reply is no|My sources say no|Outlook not so good|Very doubtful)/; +my $possibleAnswers = re(qr/(It is certain|It is decidedly so|Without a doubt|Yes, definitely|You may rely on it|As I see it, yes|Most likely|Outlook good|Yes|Signs point to yes|Reply hazy try again|Ask again later|Better not tell you now|Cannot predict now|Concentrate and ask again|Don't count on it|My reply is no|My sources say no|Outlook not so good|Very doubtful)/); -my $possibleStructuredAnswer = qr/^(?:It is certain|It is decidedly so|Without a doubt|Yes, definitely|You may rely on it|As I see it, yes|Most likely|Outlook good|Yes|Signs point to yes|Reply hazy try again|Ask again later|Better not tell you now|Cannot predict now|Concentrate and ask again|Don't count on it|My reply is no|My sources say no|Outlook not so good|Very doubtful)$/; +my $possibleStructuredAnswer = re(qr/^(?:It is certain|It is decidedly so|Without a doubt|Yes, definitely|You may rely on it|As I see it, yes|Most likely|Outlook good|Yes|Signs point to yes|Reply hazy try again|Ask again later|Better not tell you now|Cannot predict now|Concentrate and ask again|Don't count on it|My reply is no|My sources say no|Outlook not so good|Very doubtful)$/); ddg_goodie_test( [qw( DDG::Goodie::MagicEightBall )], @@ -43,4 +44,4 @@ ddg_goodie_test( 'magic 8ball' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/MakeMeASandwich.t b/t/MakeMeASandwich.t index 1309c5d25..25609a966 100644 --- a/t/MakeMeASandwich.t +++ b/t/MakeMeASandwich.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'xkcd_sandwich'; @@ -34,4 +35,4 @@ ddg_goodie_test( '0 make me a sandwich' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/MarkdownReference.t b/t/MarkdownReference.t index f943822f3..724d84f79 100644 --- a/t/MarkdownReference.t +++ b/t/MarkdownReference.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'markdown_reference'; @@ -71,4 +72,4 @@ ddg_goodie_test( 'markdown cheat sheet list' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Minecraft.t b/t/Minecraft.t index 375019d5e..5694bfa78 100644 --- a/t/Minecraft.t +++ b/t/Minecraft.t @@ -4,6 +4,7 @@ use strict; use warnings; use utf8; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use URI::Escape; @@ -141,4 +142,4 @@ sub make_structured_answer { }; }; -done_testing; +done_testing; \ No newline at end of file diff --git a/t/MoonPhases.t b/t/MoonPhases.t index 0478d15fb..c9d972d43 100644 --- a/t/MoonPhases.t +++ b/t/MoonPhases.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'moon_phase'; @@ -14,8 +15,8 @@ my $quarter = qr/(?:First|Third)$space_plus(?:Quarter)/; my $named = qr/(?:New|Full)$space_plus(?:Moon)/; my $phases = qr/$wax_wane|$quarter|$named/; -my $ascii_answer = qr/^The current lunar phase is: $phases$/; -my $html_answer = qr%^The current lunar phase is: $phases$%; +my $ascii_answer = re(qr/^The current lunar phase is: $phases$/); +my $html_answer = re(qr%^The current lunar phase is: $phases$%); ddg_goodie_test( [qw( DDG::Goodie::MoonPhases)], @@ -24,7 +25,7 @@ ddg_goodie_test( structured_answer => { input => [], operation => 'Current lunar phase', - result => $phases, + result => re($phases), } ), 'lunar phase' => test_zci( @@ -32,7 +33,7 @@ ddg_goodie_test( structured_answer => { input => [], operation => 'Current lunar phase', - result => $phases, + result => re($phases), } ), 'phase of the moon' => test_zci( @@ -40,7 +41,7 @@ ddg_goodie_test( structured_answer => { input => [], operation => 'Current lunar phase', - result => $phases, + result => re($phases), } ), 'what is the current lunar phase' => test_zci( @@ -48,9 +49,9 @@ ddg_goodie_test( structured_answer => { input => [], operation => 'Current lunar phase', - result => $phases, + result => re($phases), } ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Morse.t b/t/Morse.t index 05fe2e18f..06f42cf3b 100644 --- a/t/Morse.t +++ b/t/Morse.t @@ -4,6 +4,7 @@ use strict; use warnings; use utf8; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'morse'; @@ -43,4 +44,4 @@ ddg_goodie_test([qw( 'morse code for cheat sheet' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/NLetterWords.t b/t/NLetterWords.t index f722f128e..5d4ecd252 100644 --- a/t/NLetterWords.t +++ b/t/NLetterWords.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'nletterwords'; @@ -16,8 +17,8 @@ ddg_goodie_test( '1 char words' => test_zci('Random 1 letter words: a, I.'), '1 character word' => test_zci('Random 1 letter words: a, I.'), 'one letter words' => test_zci('Random 1 letter words: a, I.'), - '5 letter words' => test_zci(qr/Random 5 letter words: ((\w){5},? ?){30}/), - '12 character word' => test_zci(qr/Random 12 letter words: ((\w){12},? ?){30}/), + '5 letter words' => test_zci(re(qr/Random 5 letter words: ((\w){5},? ?){30}/)), + '12 character word' => test_zci(re(qr/Random 12 letter words: ((\w){12},? ?){30}/)), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/NameDays.t b/t/NameDays.t index a7487c353..dc016506d 100644 --- a/t/NameDays.t +++ b/t/NameDays.t @@ -5,6 +5,7 @@ use strict; use warnings; use Locale::Country; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "name_days"; @@ -176,4 +177,4 @@ ddg_goodie_test( 'name day' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/NoteFrequency.t b/t/NoteFrequency.t index 37d353184..9b12aa319 100644 --- a/t/NoteFrequency.t +++ b/t/NoteFrequency.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "note_frequency"; @@ -37,4 +38,4 @@ ddg_goodie_test( "notefreq c9" => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/OnionAddress.t b/t/OnionAddress.t index e9fa03c8f..ad23093a7 100644 --- a/t/OnionAddress.t +++ b/t/OnionAddress.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use URI::Escape; @@ -165,4 +166,4 @@ sub make_structured_answer { }; }; -done_testing; +done_testing; \ No newline at end of file diff --git a/t/POTUS.t b/t/POTUS.t index 9b4ac77b5..f512a9b6b 100755 --- a/t/POTUS.t +++ b/t/POTUS.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'potus'; @@ -40,4 +41,4 @@ ddg_goodie_test( 'VPOTUS' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/PaleoIngredientCheck.t b/t/PaleoIngredientCheck.t index 87b4e560a..a87bf786b 100644 --- a/t/PaleoIngredientCheck.t +++ b/t/PaleoIngredientCheck.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "paleo_ingredient_check"; diff --git a/t/Palindrome.t b/t/Palindrome.t index 4f528d494..655e02a3d 100644 --- a/t/Palindrome.t +++ b/t/Palindrome.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'palindrome'; @@ -22,4 +23,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/Paper.t b/t/Paper.t index ab959e309..6e6bb8812 100644 --- a/t/Paper.t +++ b/t/Paper.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'paper'; @@ -76,4 +77,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Parcelforce.t b/t/Parcelforce.t index ce4255b48..dc0799eb9 100644 --- a/t/Parcelforce.t +++ b/t/Parcelforce.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'parcelforce'; @@ -31,4 +32,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/ParseCron.t b/t/ParseCron.t index 7d21d243e..713236a02 100644 --- a/t/ParseCron.t +++ b/t/ParseCron.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'parsecron'; @@ -368,4 +369,4 @@ ddg_goodie_test( }), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Passphrase.t b/t/Passphrase.t index 95ad3610c..9dd5189fc 100644 --- a/t/Passphrase.t +++ b/t/Passphrase.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'random_passphrase'; @@ -46,12 +47,12 @@ sub count_words { my $words_re = qr/(?:\s?\b[a-z]+\b){$count}/; return ( - qr/^random passphrase: $words_re$/, + re(qr/^random passphrase: $words_re$/), structured_answer => { input => [($count > 1) ? $count . ' words' : '1 word'], operation => 'Random passphrase', - result => qr/^$words_re$/, + result => re(qr/^$words_re$/), }); } -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Password.t b/t/Password.t index c1b1a0862..9f362589c 100644 --- a/t/Password.t +++ b/t/Password.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'pw'; @@ -11,157 +12,157 @@ zci is_cached => 0; ddg_goodie_test( [qw( DDG::Goodie::Password)], 'pw 15 average' => test_zci( - qr/.{15} \(random password\)/, + re(qr/.{15} \(random password\)/), structured_answer => { input => ['15 characters', 'average strength'], operation => 'Random password', - result => qr/^.{15}$/ + result => re(qr/^.{15}$/) } ), 'password normal 15' => test_zci( - qr/.{15} \(random password\)/, + re(qr/.{15} \(random password\)/), structured_answer => { input => ['15 characters', 'average strength'], operation => 'Random password', - result => qr/^.{15}$/ + result => re(qr/^.{15}$/) } ), 'random pw 15 AVG' => test_zci( - qr/.{15} \(random password\)/, + re(qr/.{15} \(random password\)/), structured_answer => { input => ['15 characters', 'average strength'], operation => 'Random password', - result => qr/^.{15}$/ + result => re(qr/^.{15}$/) } ), 'pwgen strong 25' => test_zci( - qr/.{25} \(random password\)/, + re(qr/.{25} \(random password\)/), structured_answer => { input => ['25 characters', 'high strength'], operation => 'Random password', - result => qr/^.{25}$/ + result => re(qr/^.{25}$/) } ), 'password 25 hard' => test_zci( - qr/.{25} \(random password\)/, + re(qr/.{25} \(random password\)/), structured_answer => { input => ['25 characters', 'high strength'], operation => 'Random password', - result => qr/^.{25}$/ + result => re(qr/^.{25}$/) } ), 'Password High 25' => test_zci( - qr/.{25} \(random password\)/, + re(qr/.{25} \(random password\)/), structured_answer => { input => ['25 characters', 'high strength'], operation => 'Random password', - result => qr/^.{25}$/ + result => re(qr/^.{25}$/) } ), # Example queries 'random password' => test_zci( - qr/.{8} \(random password\)/, + re(qr/.{8} \(random password\)/), structured_answer => { input => ['8 characters', 'average strength'], operation => 'Random password', - result => qr/^.{8}$/ + result => re(qr/^.{8}$/) } ), 'password strong 15' => test_zci( - qr/.{15} \(random password\)/, + re(qr/.{15} \(random password\)/), structured_answer => { input => ['15 characters', 'high strength'], operation => 'Random password', - result => qr/^.{15}$/ + result => re(qr/^.{15}$/) } ), 'pw' => test_zci( - qr/.{8} \(random password\)/, + re(qr/.{8} \(random password\)/), structured_answer => { input => ['8 characters', 'average strength'], operation => 'Random password', - result => qr/^.{8}$/ + result => re(qr/^.{8}$/) } ), # Add some triggers (issue #1565) 'generate password' => test_zci( - qr/.{8} \(random password\)/, + re(qr/.{8} \(random password\)/), structured_answer => { input => ['8 characters', 'average strength'], operation => 'Random password', - result => qr/^.{8}$/ + result => re(qr/^.{8}$/) } ), 'generate strong password' => test_zci( - qr/.{8} \(random password\)/, + re(qr/.{8} \(random password\)/), structured_answer => { input => ['8 characters', 'high strength'], operation => 'Random password', - result => qr/^.{8}$/ + result => re(qr/^.{8}$/) } ), 'generate random password' => test_zci( - qr/.{8} \(random password\)/, + re(qr/.{8} \(random password\)/), structured_answer => { input => ['8 characters', 'average strength'], operation => 'Random password', - result => qr/^.{8}$/ + result => re(qr/^.{8}$/) } ), 'password generator' => test_zci( - qr/.{8} \(random password\)/, + re(qr/.{8} \(random password\)/), structured_answer => { input => ['8 characters', 'average strength'], operation => 'Random password', - result => qr/^.{8}$/ + result => re(qr/^.{8}$/) } ), 'random password generator' => test_zci( - qr/.{8} \(random password\)/, + re(qr/.{8} \(random password\)/), structured_answer => { input => ['8 characters', 'average strength'], operation => 'Random password', - result => qr/^.{8}$/ + result => re(qr/^.{8}$/) } ), 'random strong password' => test_zci( - qr/.{8} \(random password\)/, + re(qr/.{8} \(random password\)/), structured_answer => { input => ['8 characters', 'high strength'], operation => 'Random password', - result => qr/^.{8}$/ + result => re(qr/^.{8}$/) } ), 'random password 16 characters' => test_zci( - qr/.{16} \(random password\)/, + re(qr/.{16} \(random password\)/), structured_answer => { input => ['16 characters', 'average strength'], operation => 'Random password', - result => qr/^.{16}$/ + result => re(qr/^.{16}$/) } ), 'create random password' => test_zci( - qr/.{8} \(random password\)/, + re(qr/.{8} \(random password\)/), structured_answer => { input => ['8 characters', 'average strength'], operation => 'Random password', - result => qr/^.{8}$/ + result => re(qr/^.{8}$/) } ), 'strong random password' => test_zci( - qr/.{8} \(random password\)/, + re(qr/.{8} \(random password\)/), structured_answer => { input => ['8 characters', 'high strength'], operation => 'Random password', - result => qr/^.{8}$/ + result => re(qr/^.{8}$/) } ), 'random password strong 15' => test_zci( - qr/.{15} \(random password\)/, + re(qr/.{15} \(random password\)/), structured_answer => { input => ['15 characters', 'high strength'], operation => 'Random password', - result => qr/^.{15}$/ + result => re(qr/^.{15}$/) } ), 'password 65' => undef, @@ -178,4 +179,4 @@ ddg_goodie_test( 'potatoe generator' => undef ); -done_testing +done_testing \ No newline at end of file diff --git a/t/PercentError.t b/t/PercentError.t index d57e942e6..bb15048aa 100644 --- a/t/PercentError.t +++ b/t/PercentError.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'percent_error'; @@ -86,4 +87,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/PercentOf.t b/t/PercentOf.t index 08360cefe..5701bc27f 100644 --- a/t/PercentOf.t +++ b/t/PercentOf.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "percent_of"; @@ -72,4 +73,4 @@ ddg_goodie_test( '12+5t%' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Perimeter.t b/t/Perimeter.t index dab532e7b..49d610fdc 100644 --- a/t/Perimeter.t +++ b/t/Perimeter.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'perimeter'; @@ -55,4 +56,4 @@ ddg_goodie_test( 'perimeter of square 3' => test_zci(build_answer(12, 'square', 3)), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/PeriodicTable.t b/t/PeriodicTable.t index dac26bcaa..b495f135c 100644 --- a/t/PeriodicTable.t +++ b/t/PeriodicTable.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "periodic_table"; @@ -437,4 +438,4 @@ sub make_structured_answer { }; }; -done_testing; +done_testing; \ No newline at end of file diff --git a/t/PhoneAlphabet.t b/t/PhoneAlphabet.t index 6371b3c0e..3ea09c83c 100644 --- a/t/PhoneAlphabet.t +++ b/t/PhoneAlphabet.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "phone_alphabet"; @@ -59,4 +60,4 @@ ddg_goodie_test( '0x0123 to digits' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Phonetic.t b/t/Phonetic.t index 7d90c0dae..1bd8db927 100644 --- a/t/Phonetic.t +++ b/t/Phonetic.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'phonetic'; @@ -18,4 +19,4 @@ ddg_goodie_test( 'phonetic Who are you?' => test_zci('Phonetic: Whiskey-Hotel-Oscar Alfa-Romeo-Echo Yankee-Oscar-Uniform') ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Pi.t b/t/Pi.t index 9b5ebbb1f..13d822bab 100644 --- a/t/Pi.t +++ b/t/Pi.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -54,4 +55,4 @@ ddg_goodie_test( ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/PigLatin.t b/t/PigLatin.t index 1712528a6..9a39fb6c1 100644 --- a/t/PigLatin.t +++ b/t/PigLatin.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'translation'; @@ -54,4 +55,4 @@ ddg_goodie_test( 'piglatin 0' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Poker.t b/t/Poker.t index 010876f6c..171420699 100644 --- a/t/Poker.t +++ b/t/Poker.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "poker"; @@ -34,4 +35,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/PrimeFactors.t b/t/PrimeFactors.t index 379c66f66..2620440c2 100644 --- a/t/PrimeFactors.t +++ b/t/PrimeFactors.t @@ -5,6 +5,7 @@ use warnings; use utf8; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "prime_factors"; @@ -44,4 +45,4 @@ ddg_goodie_test( 'optimus prime 45' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/PrimeNumber.t b/t/PrimeNumber.t index acfeabe15..d4af908a1 100644 --- a/t/PrimeNumber.t +++ b/t/PrimeNumber.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "prime"; @@ -75,4 +76,4 @@ sub make_structured_answer { }; }; -done_testing; +done_testing; \ No newline at end of file diff --git a/t/PrivateNetwork.t b/t/PrivateNetwork.t index bc079cbbb..ca02ede3c 100644 --- a/t/PrivateNetwork.t +++ b/t/PrivateNetwork.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'private_network'; @@ -30,8 +31,8 @@ Benchmarks: 198.18.0.1 - 198.19.255.255 | 198.18.0.0/15 Private network IPv6 addresses (rfc4193): Unique local addresses: fd00::/8 ', - html => qr#.*# + html => re(qr#.*#) )) } ( 'private network', 'private networks', 'private ips' ) ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/PublicDNS.t b/t/PublicDNS.t index 3ff625c27..b3380d49e 100644 --- a/t/PublicDNS.t +++ b/t/PublicDNS.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "public_dns"; @@ -11,13 +12,13 @@ zci is_cached => 1; # We don't want to test too specifically on the included data, so just confirm # we got an answer with something approaching the correct form. # Hopefully, some one has eyeballed the output to make sure its got the right data. -my $text_table = qr#^\+-+.*-+\+#m; +my $text_table = re(qr#^\+-+.*-+\+#m); ddg_goodie_test([qw( DDG::Goodie::PublicDNS)], 'public dns' => test_zci( $text_table, structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -29,7 +30,7 @@ ddg_goodie_test([qw( DDG::Goodie::PublicDNS)], 'dns servers' => test_zci( $text_table, structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -40,4 +41,4 @@ ddg_goodie_test([qw( DDG::Goodie::PublicDNS)], ) ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/RIPEMD.t b/t/RIPEMD.t index 7efd28f6d..eebae4665 100644 --- a/t/RIPEMD.t +++ b/t/RIPEMD.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "ripemd"; @@ -422,4 +423,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/Rafl.t b/t/Rafl.t index 1e4c83519..f8257b38a 100644 --- a/t/Rafl.t +++ b/t/Rafl.t @@ -3,12 +3,13 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'rafl'; zci is_cached => 1; -my $intro = qr/^rafl is so everywhere, /; +my $intro = re(qr/^rafl is so everywhere, /); my @rafl = ( $intro, structured_answer => { @@ -24,4 +25,4 @@ ddg_goodie_test( 'where is rafl?' => test_zci(@rafl), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Randagram.t b/t/Randagram.t index fecd224f5..4acca21af 100644 --- a/t/Randagram.t +++ b/t/Randagram.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'randagram'; @@ -10,8 +11,8 @@ zci is_cached => 0; ddg_goodie_test( [qw(DDG::Goodie::Randagram)], - 'randagram algorithm' => test_zci(qr/Randagram of "algorithm": [algorithm]/), - 'randagram jazz hands' => test_zci(qr/Randagram of "jazz hands": [jazz hands]/), + 'randagram algorithm' => test_zci(re(qr/Randagram of "algorithm": [algorithm]/)), + 'randagram jazz hands' => test_zci(re(qr/Randagram of "jazz hands": [jazz hands]/)), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/RandomName.t b/t/RandomName.t index 8301b6a28..2db649b8d 100644 --- a/t/RandomName.t +++ b/t/RandomName.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci is_cached => 0; @@ -12,14 +13,14 @@ ddg_goodie_test( [ 'DDG::Goodie::RandomName' ], - 'random Name' => test_zci (qr/\w\w \(random\)/), - 'random name' => test_zci (qr/\w\w \(random\)/), + 'random Name' => test_zci (re(qr/\w\w \(random\)/)), + 'random name' => test_zci (re(qr/\w\w \(random\)/)), 'random person' => - test_zci (qr/Name: [\w\s]+\nGender: (?:Male|Female)\nDate of birth: \d{4}\-\d{2}\-\d{2}\nAge: \d+/, + test_zci (re(qr/Name: [\w\s]+\nGender: (?:Male|Female)\nDate of birth: \d{4}\-\d{2}\-\d{2}\nAge: \d+/), heading => 'Random Person'), 'random domain name' => undef, 'random city name' => undef, 'names of random people' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/RandomNumber.t b/t/RandomNumber.t index 8fe555c9f..0d6bf944a 100644 --- a/t/RandomNumber.t +++ b/t/RandomNumber.t @@ -40,4 +40,4 @@ ddg_goodie_test( 'random access' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Rc4.t b/t/Rc4.t index 62e1f0fcf..58f112b42 100644 --- a/t/Rc4.t +++ b/t/Rc4.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "rc4"; @@ -29,4 +30,4 @@ ddg_goodie_test( 'rc4 no operation' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Regexp.t b/t/Regexp.t index 633cfaa6f..7e4f5026d 100644 --- a/t/Regexp.t +++ b/t/Regexp.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'regexp'; @@ -84,4 +85,4 @@ ddg_goodie_test([qw( DDG::Goodie::Regexp )], #'regexp /(?h)/ h' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/ResistorColors.t b/t/ResistorColors.t index 62a84bba6..ebfc38e99 100644 --- a/t/ResistorColors.t +++ b/t/ResistorColors.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "resistor_colors"; @@ -35,7 +36,7 @@ sub get_structured_answer { sourceName => "resisto.rs", sourceUrl => "http://resisto.rs/#" . $_[0] }, - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -142,4 +143,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/Reverse.t b/t/Reverse.t index e6aceda4c..00ff2845f 100644 --- a/t/Reverse.t +++ b/t/Reverse.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'reverse'; @@ -44,4 +45,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/ReverseComplement.t b/t/ReverseComplement.t index cb3b58587..330b167ce 100644 --- a/t/ReverseComplement.t +++ b/t/ReverseComplement.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'reverse_complement'; @@ -97,4 +98,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/ReverseResistorColours.t b/t/ReverseResistorColours.t index 517d7c62b..8abc7d005 100644 --- a/t/ReverseResistorColours.t +++ b/t/ReverseResistorColours.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -115,4 +116,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Roman.t b/t/Roman.t index 4ce2a1616..3d9c839ef 100644 --- a/t/Roman.t +++ b/t/Roman.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'roman_numeral_conversion'; @@ -76,4 +77,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Rot13.t b/t/Rot13.t index 2519c5d59..157191259 100644 --- a/t/Rot13.t +++ b/t/Rot13.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'rot13'; @@ -36,4 +37,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/RouterPasswords.t b/t/RouterPasswords.t index 31c34b181..63a5b1e4a 100644 --- a/t/RouterPasswords.t +++ b/t/RouterPasswords.t @@ -5,6 +5,7 @@ use warnings; # These modules are necessary for the functions we'll be running. use Test::More; +use Test::Deep; use DDG::Test::Goodie; # These zci attributes aren't necessary, but if you specify them inside your @@ -59,4 +60,4 @@ ddg_goodie_test( # This function call is expected by Test::More. It makes sure the program # doesn't exit before all the tests have been run. -done_testing; +done_testing; \ No newline at end of file diff --git a/t/RubiksCubePatterns.t b/t/RubiksCubePatterns.t index 48f7601f3..e90a54ae2 100644 --- a/t/RubiksCubePatterns.t +++ b/t/RubiksCubePatterns.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'rubiks_cube'; @@ -162,4 +163,4 @@ ddg_goodie_test( 'rubics cube' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/SHA3.t b/t/SHA3.t index 82555e4f9..04438a7dd 100644 --- a/t/SHA3.t +++ b/t/SHA3.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "sha3"; @@ -349,4 +350,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/Scramble.t b/t/Scramble.t index a489c8c13..38ba82d77 100644 --- a/t/Scramble.t +++ b/t/Scramble.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "scramble"; @@ -15,7 +16,7 @@ ddg_goodie_test( structured_answer => { input => ['filter'], operation => 'Scramble of', - result => '-ANY-', + result => ignore(), } ), 'scramble of' => undef, @@ -24,4 +25,4 @@ ddg_goodie_test( 'Scrambles for "867-5309"' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/ScreenResolution.t b/t/ScreenResolution.t index 99e2dd852..2ab3e1ee6 100644 --- a/t/ScreenResolution.t +++ b/t/ScreenResolution.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "screen_resolution"; @@ -35,4 +36,4 @@ ddg_goodie_test( 'blah blah screen resolution' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/SecurityAddons.t b/t/SecurityAddons.t index 822dd4c24..35e8885b3 100644 --- a/t/SecurityAddons.t +++ b/t/SecurityAddons.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "security_addons"; @@ -56,4 +57,4 @@ ddg_goodie_test( 'internet explorer privacy addons' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Sha.t b/t/Sha.t index a9d07f922..5a17c48c9 100644 --- a/t/Sha.t +++ b/t/Sha.t @@ -4,6 +4,7 @@ use utf8; use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'sha'; @@ -217,4 +218,4 @@ ddg_goodie_test( 'shadow' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Shruggie.t b/t/Shruggie.t index 6cc35fd51..7d00865e8 100644 --- a/t/Shruggie.t +++ b/t/Shruggie.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; # needed to properly use the various unicode characters in the emoticons @@ -86,4 +87,4 @@ ddg_goodie_test( 'shruggie andover' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/SigFigs.t b/t/SigFigs.t index 228eb4550..cbc48f732 100644 --- a/t/SigFigs.t +++ b/t/SigFigs.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'sig_figs'; @@ -50,4 +51,4 @@ ddg_goodie_test( 'How many sig figs are there in 11.3' => build_test('3', '11.3'), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/SolarSystem.t b/t/SolarSystem.t index 5aa629cf8..0bb2a8644 100644 --- a/t/SolarSystem.t +++ b/t/SolarSystem.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use DDG::Test::Location; @@ -11,7 +12,7 @@ zci is_cached => 1; #Structured answer template data my $templateData = { - data => '-ANY-', + data => ignore(), meta => { sourceUrl => "https://solarsystem.nasa.gov/planets/index.cfm", sourceName => "NASA" diff --git a/t/Sort.t b/t/Sort.t index 043e6546e..10592a24d 100644 --- a/t/Sort.t +++ b/t/Sort.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'sort'; @@ -79,4 +80,4 @@ ddg_goodie_test( 'sort' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Stardate.t b/t/Stardate.t index 9628640bb..2a7a8ae4b 100644 --- a/t/Stardate.t +++ b/t/Stardate.t @@ -3,15 +3,16 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "stardate"; zci is_cached => 0; sub build_structured_answer { - return qr/[0-9]{8}\.[0-9]{1,5}/, + return re(qr/[0-9]{8}\.[0-9]{1,5}/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', }, @@ -29,4 +30,4 @@ ddg_goodie_test( 'stardate 29 feb 2015' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/SubnetCalc.t b/t/SubnetCalc.t index cf12eea1b..f11e0bbf3 100755 --- a/t/SubnetCalc.t +++ b/t/SubnetCalc.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'subnet_calc'; @@ -96,4 +97,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Sudoku.t b/t/Sudoku.t index 054bf8782..9eb1f6f49 100644 --- a/t/Sudoku.t +++ b/t/Sudoku.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'sudoku'; @@ -14,31 +15,31 @@ ddg_goodie_test( 'DDG::Goodie::Sudoku' ], "sudoku" => test_zci( - qr/^[0-9_].*[0-9_]$/s, - html => qr/.*\.*/s, + re(qr/^[0-9_].*[0-9_]$/s), + html => re(qr/.*\.*/s), ), "play sudoku" => test_zci( - qr/^[0-9_].*[0-9_]$/s, - html => qr/.*\.*/s, + re(qr/^[0-9_].*[0-9_]$/s), + html => re(qr/.*\.*/s), ), "easy sudoku" => test_zci( - qr/^[0-9_].*[0-9_]$/s, - html => qr/.*\.*/s, + re(qr/^[0-9_].*[0-9_]$/s), + html => re(qr/.*\.*/s), ), "sudoku hard" => test_zci( - qr/^[0-9_].*[0-9_]$/s, - html => qr/.*\.*/s, + re(qr/^[0-9_].*[0-9_]$/s), + html => re(qr/.*\.*/s), ), "generate sudoku" => test_zci( - qr/^[0-9_].*[0-9_]$/s, - html => qr/.*\.*/s, + re(qr/^[0-9_].*[0-9_]$/s), + html => re(qr/.*\.*/s), ), "sudoku party" => undef, "sudoku toys" => undef, 'sudoku easy' => test_zci( - qr/[0-9_].*[0-9_]$/s, - html => qr/.*\.*/s, + re(qr/[0-9_].*[0-9_]$/s), + html => re(qr/.*\.*/s), ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/SumOfNaturalNumbers.t b/t/SumOfNaturalNumbers.t index 29db10daf..aa9aa54d3 100644 --- a/t/SumOfNaturalNumbers.t +++ b/t/SumOfNaturalNumbers.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci is_cached => 1; @@ -26,4 +27,4 @@ ddg_goodie_test( 'add ten to twenty' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/SunInfo.t b/t/SunInfo.t index f558ca850..c86941c07 100755 --- a/t/SunInfo.t +++ b/t/SunInfo.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; use Test::MockTime qw(set_fixed_time); @@ -12,9 +13,9 @@ zci is_cached => 0; set_fixed_time('2014-08-01T00:00:00Z'); # Presume sun will rise in the morning and set at night year round in PA. -my @now = (qr/^On.*Phoenixville, Pennsylvania.*AM.*PM\.$/, +my @now = (re(qr/^On.*Phoenixville, Pennsylvania.*AM.*PM\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -25,9 +26,9 @@ my @now = (qr/^On.*Phoenixville, Pennsylvania.*AM.*PM\.$/, } } ); -my @aug = (qr/^On 30 Aug.*AM.*PM\.$/, +my @aug = (re(qr/^On 30 Aug.*AM.*PM\.$/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -73,9 +74,9 @@ ddg_goodie_test( 'sunset on 2015-01-01' => test_zci(@exact), 'what time is sunrise on 2015-01-01?' => test_zci(@exact), 'January 1st, 2015 sunrise' => test_zci(@exact), - q{sunrise at 39°57'N 5°10'W} => test_zci(qr"On.*Coordinates .*AM.*PM", + q{sunrise at 39°57'N 5°10'W} => test_zci(re(qr"On.*Coordinates .*AM.*PM"), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -86,9 +87,9 @@ ddg_goodie_test( } } ), - 'sunset at 1S 1W' => test_zci(qr"On .*, sunrise in Coordinates -1°N -1°E is at .*AM; sunset at .*PM.", + 'sunset at 1S 1W' => test_zci(re(qr"On .*, sunrise in Coordinates -1°N -1°E is at .*AM; sunset at .*PM."), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -101,7 +102,7 @@ ddg_goodie_test( ), 'sunset at 53N 2E on 2014-01-01' => test_zci("On 01 Jan 2014, sunrise in Coordinates 53°N 2°E is at 3:05 AM; sunset at 10:46 AM.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -114,7 +115,7 @@ ddg_goodie_test( ), 'sunset at 53N 2W on 2014-01-08' => test_zci("On 08 Jan 2014, sunrise in Coordinates 53°N -2°E is at 3:18 AM; sunset at 11:11 AM.", structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'text', item => 0, @@ -133,4 +134,4 @@ ddg_goodie_test( 'after the sunset' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Teredo.t b/t/Teredo.t index a423b3152..f2794fc83 100644 --- a/t/Teredo.t +++ b/t/Teredo.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'teredo'; @@ -80,4 +81,4 @@ ddg_goodie_test( ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/TimezoneConverter.t b/t/TimezoneConverter.t index 8a3cc6111..d359510da 100644 --- a/t/TimezoneConverter.t +++ b/t/TimezoneConverter.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use Test::MockTime qw( :all ); @@ -210,35 +211,35 @@ ddg_goodie_test( }, ), '11:22am cest in my timezone' => - test_zci(qr/5:22 AM EDT/, + test_zci(re(qr/5:22 AM EDT/), structured_answer => { input => [qq/11:22 AM CEST (UTC+2) to $test_location_tz/], operation => 'Convert Timezone', - result => qr/5:22 AM EDT/, + result => re(qr/5:22 AM EDT/), }, ), '11:22am cest in localtime' => - test_zci(qr/5:22 AM EDT/, + test_zci(re(qr/5:22 AM EDT/), structured_answer => { input => [qq/11:22 AM CEST (UTC+2) to $test_location_tz/], operation => 'Convert Timezone', - result => qr/5:22 AM EDT/, + result => re(qr/5:22 AM EDT/), }, ), '11:22am cest in my local timezone' => - test_zci(qr/5:22 AM EDT/, + test_zci(re(qr/5:22 AM EDT/), structured_answer => { input => [qq/11:22 AM CEST (UTC+2) to $test_location_tz/], operation => 'Convert Timezone', - result => qr/5:22 AM EDT/, + result => re(qr/5:22 AM EDT/), }, ), '11:22am cest' => - test_zci(qr/5:22 AM EDT/, + test_zci(re(qr/5:22 AM EDT/), structured_answer => { input => [qq/11:22 AM CEST (UTC+2) to $test_location_tz/], operation => 'Convert Timezone', - result => qr/5:22 AM EDT/, + result => re(qr/5:22 AM EDT/), }, ), '12pm my time in CEST' => @@ -314,19 +315,19 @@ ddg_goodie_test( }, ), '11:22am cest in my timezone' => - test_zci(qr/4:22 AM EST/, + test_zci(re(qr/4:22 AM EST/), structured_answer => { input => [qq/11:22 AM CEST (UTC+2) to $test_location_tz/], operation => 'Convert Timezone', - result => qr/4:22 AM EST/, + result => re(qr/4:22 AM EST/), }, ), '11:22am cest in localtime' => - test_zci(qr/4:22 AM EST/, + test_zci(re(qr/4:22 AM EST/), structured_answer => { input => [qq/11:22 AM CEST (UTC+2) to $test_location_tz/], operation => 'Convert Timezone', - result => qr/4:22 AM EST/, + result => re(qr/4:22 AM EST/), }, ), '11:22am cest in my local timezone' => @@ -370,7 +371,7 @@ ddg_goodie_test( }, ), '12am my timezone in UTC' => - test_zci(qr/5:00 AM UTC/, + test_zci(re(qr/5:00 AM UTC/), structured_answer => { input => [qq/Midnight $test_location_tz to UTC/], operation => 'Convert Timezone', @@ -378,7 +379,7 @@ ddg_goodie_test( }, ), '12am local time in UTC' => - test_zci(qr/5:00 AM UTC/, + test_zci(re(qr/5:00 AM UTC/), structured_answer => { input => [qq/Midnight $test_location_tz to UTC/], operation => 'Convert Timezone', @@ -386,7 +387,7 @@ ddg_goodie_test( }, ), '12am in UTC' => - test_zci(qr/5:00 AM UTC/, + test_zci(re(qr/5:00 AM UTC/), structured_answer => { input => [qq/Midnight $test_location_tz to UTC/], operation => 'Convert Timezone', @@ -396,4 +397,4 @@ ddg_goodie_test( ); restore_time(); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Tips.t b/t/Tips.t index 7169359e5..433cda2ad 100644 --- a/t/Tips.t +++ b/t/Tips.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'tip'; @@ -25,4 +26,4 @@ ddg_goodie_test( '4 of 5 dentists' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/TitleCase.t b/t/TitleCase.t index 6de5bd04f..ad44cb0fd 100755 --- a/t/TitleCase.t +++ b/t/TitleCase.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'title_case'; @@ -34,4 +35,4 @@ ddg_goodie_test( 'how do i make something titlecase' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/TwelveOclock.t b/t/TwelveOclock.t index 89ccb971e..caf297043 100644 --- a/t/TwelveOclock.t +++ b/t/TwelveOclock.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "twelve_oclock"; @@ -72,4 +73,4 @@ ddg_goodie_test( 'when is noon in Jakarta?' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/UN.t b/t/UN.t index 81ebd0737..96ff83ab2 100644 --- a/t/UN.t +++ b/t/UN.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'united_nations'; @@ -64,4 +65,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/UPS.t b/t/UPS.t index f958ec6ce..d61211811 100644 --- a/t/UPS.t +++ b/t/UPS.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'ups'; @@ -31,4 +32,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/URLDecode.t b/t/URLDecode.t index 996fdbe33..2de98a3eb 100755 --- a/t/URLDecode.t +++ b/t/URLDecode.t @@ -4,6 +4,7 @@ use strict; use warnings; use utf8; use Test::More; +use Test::Deep; use HTML::Entities; use DDG::Test::Goodie; @@ -63,4 +64,4 @@ ddg_goodie_test( 'url decode online' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/URLEncode.t b/t/URLEncode.t index 38940744b..2e76e9c12 100644 --- a/t/URLEncode.t +++ b/t/URLEncode.t @@ -4,6 +4,7 @@ use strict; use warnings; use utf8; use Test::More; +use Test::Deep; use HTML::Entities; use DDG::Test::Goodie; @@ -52,4 +53,4 @@ ddg_goodie_test( 'hello there escapeurl' => test_zci(build_answer('hello%20there', 'hello there')), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/USPS.t b/t/USPS.t index bf36bce60..6858c7951 100644 --- a/t/USPS.t +++ b/t/USPS.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'usps'; @@ -40,4 +41,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/UltimateAnswer.t b/t/UltimateAnswer.t index 6e48663b9..d4ae98093 100644 --- a/t/UltimateAnswer.t +++ b/t/UltimateAnswer.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "ultimate_answer"; @@ -106,4 +107,4 @@ ddg_goodie_test( 'why?' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Unicode.t b/t/Unicode.t index 9ffb77e90..b4a98da91 100644 --- a/t/Unicode.t +++ b/t/Unicode.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'unicode_conversion'; @@ -47,4 +48,4 @@ ddg_goodie_test( 'utf-15 bullet' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/UnicodeFuzzySearch.t b/t/UnicodeFuzzySearch.t index f778ec541..b372b6315 100644 --- a/t/UnicodeFuzzySearch.t +++ b/t/UnicodeFuzzySearch.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci is_cached => 1; @@ -65,4 +66,4 @@ ROTATED HEAVY BLACK HEART BULLET: \x{2765} (U+2765)", ) ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Unicornify.t b/t/Unicornify.t index 4ad143135..921dd33e3 100644 --- a/t/Unicornify.t +++ b/t/Unicornify.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use Unicornify::URL; @@ -37,4 +38,4 @@ ddg_goodie_test( } })); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Unidecode.t b/t/Unidecode.t index 45c3a0945..0a263c615 100644 --- a/t/Unidecode.t +++ b/t/Unidecode.t @@ -3,6 +3,7 @@ use utf8; use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'convert_to_ascii'; @@ -19,4 +20,3 @@ ddg_goodie_test( ); done_testing; - diff --git a/t/UnixPermissions.t b/t/UnixPermissions.t index b5f51028e..f2bea418c 100644 --- a/t/UnixPermissions.t +++ b/t/UnixPermissions.t @@ -1,6 +1,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'unix_permissions'; @@ -97,4 +98,4 @@ Others: read, write and execute 'permission 9644' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/UnixTime.t b/t/UnixTime.t index dfe24379a..e1d8d04f7 100644 --- a/t/UnixTime.t +++ b/t/UnixTime.t @@ -3,12 +3,13 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'time_conversion'; zci is_cached => 0; -my @zero = (qr/Thu Jan 01 00:00:00 1970 UTC/, +my @zero = (re(qr/Thu Jan 01 00:00:00 1970 UTC/), structured_answer => { data => { record_data => { @@ -26,7 +27,7 @@ my @zero = (qr/Thu Jan 01 00:00:00 1970 UTC/, } } ); -my @zeroi = (qr/Thu Jan 01 00:00:00 1970 UTC/, +my @zeroi = (re(qr/Thu Jan 01 00:00:00 1970 UTC/), structured_answer => { data => { record_data => { @@ -45,9 +46,9 @@ my @zeroi = (qr/Thu Jan 01 00:00:00 1970 UTC/, } ); -my @now = (qr/Unix Epoch./, +my @now = (re(qr/Unix Epoch./), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -56,9 +57,9 @@ my @now = (qr/Unix Epoch./, } } ); -my @then = (qr/Tue Nov 18 00:28:30 1930 UTC/, +my @then = (re(qr/Tue Nov 18 00:28:30 1930 UTC/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -67,9 +68,9 @@ my @then = (qr/Tue Nov 18 00:28:30 1930 UTC/, } } ); -my @later = (qr/Tue Jan 19 03:14:07 2038 UTC/, +my @later = (re(qr/Tue Jan 19 03:14:07 2038 UTC/), structured_answer => { - data => '-ANY-', + data => ignore(), templates => { group => 'list', options => { @@ -108,4 +109,4 @@ ddg_goodie_test([qw( 'unix time info' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Uppercase.t b/t/Uppercase.t index 114e04777..750f05f0c 100755 --- a/t/Uppercase.t +++ b/t/Uppercase.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'uppercase'; @@ -33,4 +34,4 @@ ddg_goodie_test( 'uppercase 123' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Uptime.t b/t/Uptime.t index 54fc5f407..a45bc2a18 100644 --- a/t/Uptime.t +++ b/t/Uptime.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "uptime"; @@ -172,4 +173,4 @@ ddg_goodie_test( 'up time 99%%' => undef ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/VIN.t b/t/VIN.t index 7733280d5..f3d9b98b1 100644 --- a/t/VIN.t +++ b/t/VIN.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'vin'; @@ -72,4 +73,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/ValarMorghulis.t b/t/ValarMorghulis.t index b36e35436..32db4adbd 100644 --- a/t/ValarMorghulis.t +++ b/t/ValarMorghulis.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'valar_morghulis'; diff --git a/t/Wavelength.t b/t/Wavelength.t index 6c80c045c..71e0674f1 100644 --- a/t/Wavelength.t +++ b/t/Wavelength.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use utf8; @@ -41,4 +42,4 @@ sub mk_test { result => $expect, } ); -} +} \ No newline at end of file diff --git a/t/Week.t b/t/Week.t index a020ab139..b79f49368 100755 --- a/t/Week.t +++ b/t/Week.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use Test::MockTime qw( :all ); @@ -10,11 +11,11 @@ zci answer_type => "week"; zci is_cached => 1; my @current_week = ( - qr/We are currently in the \d{1,2}\w{2} week of \d{4}./, + re(qr/We are currently in the \d{1,2}\w{2} week of \d{4}./), structured_answer => { input => [], operation => 'Assuming the week starts on Monday', - result => qr/We are currently in the \d{1,2}\w{2} week of \d{4}./, + result => re(qr/We are currently in the \d{1,2}\w{2} week of \d{4}./), }); @@ -95,11 +96,11 @@ ddg_goodie_test( ), # Nth Week Queries "what was the 5th week of this year" => test_zci( - qr/The \d{1,2}\w{2} week of \d{4} (begins|began) on January \d{1,2}\w{2}\./, + re(qr/The \d{1,2}\w{2} week of \d{4} (begins|began) on January \d{1,2}\w{2}\./), structured_answer => { input => [], operation => "Assuming the week starts on Monday", - result => qr/The \d{1,2}\w{2} week of \d{4} (begins|began) on January \d{1,2}\w{2}\./, + result => re(qr/The \d{1,2}\w{2} week of \d{4} (begins|began) on January \d{1,2}\w{2}\./), } ) ); diff --git a/t/WeekdaysBetween.t b/t/WeekdaysBetween.t index 12ddca463..38194ca23 100755 --- a/t/WeekdaysBetween.t +++ b/t/WeekdaysBetween.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'weekdays_between'; @@ -130,4 +131,4 @@ ddg_goodie_test( 'Weekdays between 18/17/2013 and 21/23/2015 inclusive' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Weight.t b/t/Weight.t index 82824e090..41c593d22 100644 --- a/t/Weight.t +++ b/t/Weight.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => "weight"; @@ -21,4 +22,4 @@ ddg_goodie_test( 'weight 5' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/WhereAmI.t b/t/WhereAmI.t index ee5d3db0a..8878216eb 100644 --- a/t/WhereAmI.t +++ b/t/WhereAmI.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; zci answer_type => 'where_am_i'; @@ -31,4 +32,4 @@ ddg_goodie_test( 'my location is nowhere!' => undef, ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/WorkdaysBetween.t b/t/WorkdaysBetween.t index 9e077a407..914d83fc6 100755 --- a/t/WorkdaysBetween.t +++ b/t/WorkdaysBetween.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use Test::MockTime qw( :all ); @@ -213,22 +214,22 @@ ddg_goodie_test( DDG::Goodie::WorkdaysBetween )], 'business days between jan 10 and jan 20' => test_zci( - qr"There are [1-9] Workdays between 10 Jan [0-9]{4} and 20 Jan [0-9]{4}\.", + re(qr"There are [1-9] Workdays between 10 Jan [0-9]{4} and 20 Jan [0-9]{4}\."), structured_answer => { - input => '-ANY-', + input => ignore(), operation => 'Workdays between', - result => qr/[1-9]/, + result => re(qr/[1-9]/), } ), 'business days between january and february' => test_zci( - qr"There are [1-9][0-9] Workdays between 01 Jan [0-9]{4} and 01 Feb [0-9]{4}\.", + re(qr"There are [1-9][0-9] Workdays between 01 Jan [0-9]{4} and 01 Feb [0-9]{4}\."), structured_answer => { - input => '-ANY-', + input => ignore(), operation => 'Workdays between', - result => qr/[1-9][0-9]/, + result => re(qr/[1-9][0-9]/), } ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/ZappBrannigan.t b/t/ZappBrannigan.t index 90c70b034..0895f24c6 100644 --- a/t/ZappBrannigan.t +++ b/t/ZappBrannigan.t @@ -28,4 +28,4 @@ ddg_goodie_test( ), ); -done_testing; +done_testing; \ No newline at end of file diff --git a/t/Zodiac.t b/t/Zodiac.t index a4e5ad8ac..0df9923db 100644 --- a/t/Zodiac.t +++ b/t/Zodiac.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use DDG::Test::Goodie; use Test::MockTime qw( :all ); @@ -110,4 +111,4 @@ ddg_goodie_test([ qw( DDG::Goodie::Zodiac ) ], restore_time(); -done_testing; +done_testing; \ No newline at end of file From 83b9bbd6b739d1a8576b68acfa2288c1805c41e3 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Mon, 16 May 2016 14:18:04 +0100 Subject: [PATCH 91/91] Fix newline at end of file --- t/AltCalendars.t | 2 +- t/Anagram.t | 2 +- t/AspectRatio.t | 2 +- t/Atbash.t | 2 +- t/BPMToMs.t | 2 +- t/BRT.t | 2 +- t/Base64.t | 2 +- t/BashPrimaryExpressions.t | 2 +- t/BeamMeUpScotty.t | 2 +- t/Bin2Unicode.t | 2 +- t/Binary.t | 2 +- t/BinaryLogic.t | 2 +- t/BirthStone.t | 2 +- t/Bitsum.t | 2 +- t/BloodDonor.t | 2 +- t/Braille.t | 2 +- t/CaesarCipher.t | 2 +- t/CalcRoots.t | 2 +- t/Calculator.t | 2 +- t/CalendarConversion.t | 2 +- t/CallingCodes.t | 2 +- t/CamelCase.t | 2 +- t/CoffeeToWaterRatio.t | 2 +- t/Coin.t | 2 +- t/ColorCodes.t | 2 +- t/Combination.t | 2 +- t/Constants.t | 2 +- t/Conversions.t | 2 +- t/CountryCodes.t | 2 +- t/CurrencyIn.t | 2 +- t/DateMath.t | 2 +- t/DayOfWeek.t | 2 +- t/DaysBetween.t | 2 +- t/Dessert.t | 2 +- t/Dewey.t | 4 ++-- t/Dice.t | 2 +- t/EmToPx.t | 2 +- t/EmailValidator.t | 2 +- t/FIGlet.t | 2 +- t/Factors.t | 2 +- t/FedEx.t | 2 +- t/FenViewer.t | 2 +- t/Fibonacci.t | 2 +- t/FirefoxOS.t | 2 +- t/FlipText.t | 2 +- t/Frequency.t | 2 +- t/FrequencySpectrum.t | 2 +- t/GUID.t | 2 +- t/Game2048.t | 2 +- t/GenerateMAC.t | 2 +- t/GibberishGenerator.t | 2 +- t/GoldenRatio.t | 2 +- t/GreatestCommonFactor.t | 2 +- t/GuitarChords.t | 2 +- t/HTMLEntitiesDecode.t | 2 +- t/HTMLEntitiesEncode.t | 2 +- t/HelpLine.t | 2 +- t/HexToASCII.t | 2 +- t/ISO639.t | 2 +- t/IndependenceDay.t | 2 +- t/Jira.t | 2 +- t/JohnCena.t | 2 +- t/Kana.t | 2 +- t/KernelTaint.t | 2 +- t/Latex.t | 2 +- t/LeapYear.t | 2 +- t/LeetSpeak.t | 2 +- t/Loan.t | 2 +- t/LoremIpsum.t | 2 +- t/Lowercase.t | 2 +- t/MD4.t | 2 +- t/MD5.t | 2 +- t/MacAddress.t | 2 +- t/MagicEightBall.t | 2 +- t/MakeMeASandwich.t | 2 +- t/MarkdownReference.t | 2 +- t/Minecraft.t | 2 +- t/MoonPhases.t | 2 +- t/Morse.t | 2 +- t/NLetterWords.t | 2 +- t/NameDays.t | 2 +- t/NoteFrequency.t | 2 +- t/OnionAddress.t | 2 +- t/POTUS.t | 2 +- t/PaleoIngredientCheck.t | 2 +- t/Paper.t | 2 +- t/ParseCron.t | 2 +- t/Passphrase.t | 2 +- t/Password.t | 2 +- t/PercentOf.t | 2 +- t/Perimeter.t | 2 +- t/PeriodicTable.t | 2 +- t/PhoneAlphabet.t | 2 +- t/Phonetic.t | 2 +- t/Pi.t | 2 +- t/PigLatin.t | 2 +- t/Poker.t | 2 +- t/PrimeFactors.t | 2 +- t/PrimeNumber.t | 2 +- t/PrivateNetwork.t | 2 +- t/PublicDNS.t | 2 +- t/Rafl.t | 2 +- t/Randagram.t | 2 +- t/RandomName.t | 2 +- t/RandomNumber.t | 2 +- t/Rc4.t | 2 +- t/Regexp.t | 2 +- t/ReverseResistorColours.t | 2 +- t/Roman.t | 2 +- t/Rot13.t | 2 +- t/RouterPasswords.t | 2 +- t/RubiksCubePatterns.t | 2 +- t/Scramble.t | 2 +- t/ScreenResolution.t | 2 +- t/SecurityAddons.t | 2 +- t/Sha.t | 2 +- t/Shruggie.t | 2 +- t/SigFigs.t | 2 +- t/SolarSystem.t | 2 +- t/Sort.t | 2 +- t/Stardate.t | 2 +- t/SubnetCalc.t | 2 +- t/Sudoku.t | 2 +- t/SumOfNaturalNumbers.t | 2 +- t/SunInfo.t | 2 +- t/Teredo.t | 2 +- t/TimezoneConverter.t | 2 +- t/Tips.t | 2 +- t/TitleCase.t | 2 +- t/TwelveOclock.t | 2 +- t/URLDecode.t | 2 +- t/URLEncode.t | 2 +- t/UltimateAnswer.t | 2 +- t/Unicode.t | 2 +- t/UnicodeFuzzySearch.t | 2 +- t/Unicornify.t | 2 +- t/UnixPermissions.t | 2 +- t/UnixTime.t | 2 +- t/Uppercase.t | 2 +- t/Uptime.t | 2 +- t/VIN.t | 2 +- t/ValarMorghulis.t | 2 +- t/Wavelength.t | 2 +- t/Week.t | 2 +- t/WeekdaysBetween.t | 2 +- t/Weight.t | 2 +- t/WhereAmI.t | 2 +- t/WorkdaysBetween.t | 2 +- t/ZappBrannigan.t | 2 +- t/Zodiac.t | 2 +- 150 files changed, 151 insertions(+), 151 deletions(-) diff --git a/t/AltCalendars.t b/t/AltCalendars.t index 203ab74a2..876e33b15 100644 --- a/t/AltCalendars.t +++ b/t/AltCalendars.t @@ -85,4 +85,4 @@ sub make_structured_answer { }; }; -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Anagram.t b/t/Anagram.t index 345aed433..562a55ccc 100644 --- a/t/Anagram.t +++ b/t/Anagram.t @@ -43,4 +43,4 @@ ddg_goodie_test( 'anagrams of "Mixing it up"' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/AspectRatio.t b/t/AspectRatio.t index a83801717..c4f2a466a 100644 --- a/t/AspectRatio.t +++ b/t/AspectRatio.t @@ -34,4 +34,4 @@ ddg_goodie_test( 'aspect ratio 1:1.5 ?:15' => build_test('1:1.5', '10:15') ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Atbash.t b/t/Atbash.t index 1b08554c3..b84b9a7ac 100755 --- a/t/Atbash.t +++ b/t/Atbash.t @@ -93,4 +93,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/BPMToMs.t b/t/BPMToMs.t index d31d558a7..3314f1a51 100644 --- a/t/BPMToMs.t +++ b/t/BPMToMs.t @@ -157,4 +157,4 @@ ddg_goodie_test( 'bpm' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/BRT.t b/t/BRT.t index 5fae6b456..47557da8e 100644 --- a/t/BRT.t +++ b/t/BRT.t @@ -31,4 +31,4 @@ ddg_goodie_test( "brt 12345678901234567890" => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Base64.t b/t/Base64.t index e0b6bc729..3e580a208 100644 --- a/t/Base64.t +++ b/t/Base64.t @@ -46,4 +46,4 @@ ddg_goodie_test( "base64 decode" => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/BashPrimaryExpressions.t b/t/BashPrimaryExpressions.t index bd366d116..b03598adb 100644 --- a/t/BashPrimaryExpressions.t +++ b/t/BashPrimaryExpressions.t @@ -121,4 +121,4 @@ ddg_goodie_test( 'bash if [ ![ 1 -lt 2 ] ]' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/BeamMeUpScotty.t b/t/BeamMeUpScotty.t index 389b850ea..022b10c03 100644 --- a/t/BeamMeUpScotty.t +++ b/t/BeamMeUpScotty.t @@ -33,4 +33,4 @@ ddg_goodie_test( 'scotty beam us up' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Bin2Unicode.t b/t/Bin2Unicode.t index 4a70adb71..da9f4c2e1 100644 --- a/t/Bin2Unicode.t +++ b/t/Bin2Unicode.t @@ -78,4 +78,4 @@ ddg_goodie_test( %ctrl_tests ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Binary.t b/t/Binary.t index 2257ccb80..625a38cc2 100644 --- a/t/Binary.t +++ b/t/Binary.t @@ -57,4 +57,4 @@ ddg_goodie_test( 'to binary' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/BinaryLogic.t b/t/BinaryLogic.t index 3b39d60f0..9a9e89b58 100755 --- a/t/BinaryLogic.t +++ b/t/BinaryLogic.t @@ -66,4 +66,4 @@ ddg_goodie_test( 'what do number and letter codes in a lens name mean' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/BirthStone.t b/t/BirthStone.t index add7946d8..758fc3d00 100644 --- a/t/BirthStone.t +++ b/t/BirthStone.t @@ -36,4 +36,4 @@ ddg_goodie_test( 'may birth stone' => build_test('May', 'Emerald') ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Bitsum.t b/t/Bitsum.t index bc107b31f..17e61b97b 100644 --- a/t/Bitsum.t +++ b/t/Bitsum.t @@ -47,4 +47,4 @@ ddg_goodie_test( 'bitsum 0b' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/BloodDonor.t b/t/BloodDonor.t index 22a0ddc69..cc75b7df7 100755 --- a/t/BloodDonor.t +++ b/t/BloodDonor.t @@ -90,4 +90,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Braille.t b/t/Braille.t index 3175b23e8..7c2d7163a 100644 --- a/t/Braille.t +++ b/t/Braille.t @@ -44,4 +44,4 @@ ddg_goodie_test( 'braille to braille is good' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/CaesarCipher.t b/t/CaesarCipher.t index e5e79b1f8..129e0b2e8 100644 --- a/t/CaesarCipher.t +++ b/t/CaesarCipher.t @@ -71,4 +71,4 @@ ddg_goodie_test( 'how to decode caesar' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/CalcRoots.t b/t/CalcRoots.t index e0086a5a2..974cc745f 100644 --- a/t/CalcRoots.t +++ b/t/CalcRoots.t @@ -50,4 +50,4 @@ ddg_goodie_test( } ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Calculator.t b/t/Calculator.t index a2bb88991..78c66a25b 100644 --- a/t/Calculator.t +++ b/t/Calculator.t @@ -861,4 +861,4 @@ ddg_goodie_test( '(01780) 111 111' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/CalendarConversion.t b/t/CalendarConversion.t index 84e840deb..be92dd615 100644 --- a/t/CalendarConversion.t +++ b/t/CalendarConversion.t @@ -49,4 +49,4 @@ ddg_goodie_test( '22nd Aug 2003 in gregorian time' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/CallingCodes.t b/t/CallingCodes.t index f1df2bf93..ba16a1aba 100644 --- a/t/CallingCodes.t +++ b/t/CallingCodes.t @@ -94,4 +94,4 @@ ddg_goodie_test( "calling code 599" => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/CamelCase.t b/t/CamelCase.t index adb7a5230..3151f19a0 100644 --- a/t/CamelCase.t +++ b/t/CamelCase.t @@ -45,4 +45,4 @@ ddg_goodie_test( 'camelcase this' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/CoffeeToWaterRatio.t b/t/CoffeeToWaterRatio.t index fa429874e..8eb165c35 100644 --- a/t/CoffeeToWaterRatio.t +++ b/t/CoffeeToWaterRatio.t @@ -80,4 +80,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Coin.t b/t/Coin.t index ffc23504d..e3f5baccb 100644 --- a/t/Coin.t +++ b/t/Coin.t @@ -93,4 +93,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/ColorCodes.t b/t/ColorCodes.t index 613aea0e9..f5fc64b89 100755 --- a/t/ColorCodes.t +++ b/t/ColorCodes.t @@ -111,4 +111,4 @@ ddg_goodie_test( 'wield color' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Combination.t b/t/Combination.t index e1ad450b5..b90bace60 100755 --- a/t/Combination.t +++ b/t/Combination.t @@ -39,4 +39,4 @@ ddg_goodie_test( '1000000000000 choose 2000' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Constants.t b/t/Constants.t index fae5315e8..95ceb80be 100644 --- a/t/Constants.t +++ b/t/Constants.t @@ -55,4 +55,4 @@ ddg_goodie_test( "why?" => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Conversions.t b/t/Conversions.t index 6cac584f1..39acabdae 100755 --- a/t/Conversions.t +++ b/t/Conversions.t @@ -2816,4 +2816,4 @@ ddg_goodie_test( '1E300 miles in metres' => undef, '5 pas.i to atm' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/CountryCodes.t b/t/CountryCodes.t index f2708625f..43ec72e8a 100644 --- a/t/CountryCodes.t +++ b/t/CountryCodes.t @@ -45,4 +45,4 @@ ddg_goodie_test( 'iso code for english' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/CurrencyIn.t b/t/CurrencyIn.t index 8509db17f..6a78eafda 100644 --- a/t/CurrencyIn.t +++ b/t/CurrencyIn.t @@ -85,4 +85,4 @@ ddg_goodie_test( ) ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/DateMath.t b/t/DateMath.t index 88b75d3e8..70ce47974 100755 --- a/t/DateMath.t +++ b/t/DateMath.t @@ -126,4 +126,4 @@ location_test([ qw( DDG::Goodie::DateMath ) ], 'time ago' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/DayOfWeek.t b/t/DayOfWeek.t index c2e292529..90253b3d3 100644 --- a/t/DayOfWeek.t +++ b/t/DayOfWeek.t @@ -71,4 +71,4 @@ ddg_goodie_test( restore_time(); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/DaysBetween.t b/t/DaysBetween.t index 454e626f2..db0d664ed 100755 --- a/t/DaysBetween.t +++ b/t/DaysBetween.t @@ -150,4 +150,4 @@ ddg_goodie_test( ); restore_time(); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Dessert.t b/t/Dessert.t index 94b14b270..165bb40ad 100644 --- a/t/Dessert.t +++ b/t/Dessert.t @@ -96,4 +96,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Dewey.t b/t/Dewey.t index 1fcb7050a..b20a7bea9 100644 --- a/t/Dewey.t +++ b/t/Dewey.t @@ -18,8 +18,8 @@ ddg_goodie_test( 'dewey decimal system 640s' => test_zci("", html => '
641 Food & drink
642 Meals & table service
643 Housing & household equipment
644 Household utilities
645 Household furnishings
646 Sewing, clothing, personal living
647 Management of public households
648 Housekeeping
649 Child rearing & home care of sick
'), '#1 in the dewey decimal system' => test_zci("001 is knowledge in the Dewey Decimal System.", html => '001 is knowledge in the Dewey Decimal System.'), 'dewey decimal system naturalism' => test_zci("146 is naturalism and related systems in the Dewey Decimal System.", html => '146 is naturalism and related systems in the Dewey Decimal System.'), - 'etymology in the dewey decimal system' => test_zci("", html => qr{^.*
$}), + 'etymology in the dewey decimal system' => test_zci("", html => re(qr{^.*
$})), 'dewey 644' => test_zci('644 is household utilities in the Dewey Decimal System.', html => '644 is household utilities in the Dewey Decimal System.'), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Dice.t b/t/Dice.t index dee3abfc3..5e2c12789 100644 --- a/t/Dice.t +++ b/t/Dice.t @@ -376,4 +376,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/EmToPx.t b/t/EmToPx.t index 4032ab02b..ab89961b1 100644 --- a/t/EmToPx.t +++ b/t/EmToPx.t @@ -42,4 +42,4 @@ ddg_goodie_test( '11px to em at base-pixel size 23px' => build_test('0.478em', '11', 'px', '23'), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/EmailValidator.t b/t/EmailValidator.t index 356c1d48e..c491fda5c 100644 --- a/t/EmailValidator.t +++ b/t/EmailValidator.t @@ -71,4 +71,4 @@ ddg_goodie_test( 'validate foo' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/FIGlet.t b/t/FIGlet.t index edb5d6ee2..ff5d66351 100644 --- a/t/FIGlet.t +++ b/t/FIGlet.t @@ -206,4 +206,4 @@ ddg_goodie_test( 'big text' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Factors.t b/t/Factors.t index 99b375180..289df363f 100755 --- a/t/Factors.t +++ b/t/Factors.t @@ -31,4 +31,4 @@ ddg_goodie_test( '72 factors' => build_test('Factors of 72: 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72', '72', '1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72'), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/FedEx.t b/t/FedEx.t index 084d707ad..5f9cefad4 100644 --- a/t/FedEx.t +++ b/t/FedEx.t @@ -34,4 +34,4 @@ ddg_goodie_test( ) ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/FenViewer.t b/t/FenViewer.t index 9564d77b8..0f27dbf5c 100644 --- a/t/FenViewer.t +++ b/t/FenViewer.t @@ -21,4 +21,4 @@ ddg_goodie_test( 'fen ' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Fibonacci.t b/t/Fibonacci.t index 9c2ef1df4..f1cc398ce 100644 --- a/t/Fibonacci.t +++ b/t/Fibonacci.t @@ -31,4 +31,4 @@ ddg_goodie_test( 'what are fibonacci numbers?' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/FirefoxOS.t b/t/FirefoxOS.t index 78f52c599..fce49ffdf 100644 --- a/t/FirefoxOS.t +++ b/t/FirefoxOS.t @@ -40,4 +40,4 @@ ddg_goodie_test( 'firefox os api' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/FlipText.t b/t/FlipText.t index 9f2eb296c..56941e3f5 100644 --- a/t/FlipText.t +++ b/t/FlipText.t @@ -39,4 +39,4 @@ ddg_goodie_test( 'spin text <<"hello\' % & * () = + . #@!^(/world">>' => build_test('<<"hello\' % & * () = + . #@!^(/world">>','<<„pʃɹoʍ/)∨¡@# ˙ + = () ⁎ ⅋ % ,oʃʃǝɥ„>>'), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Frequency.t b/t/Frequency.t index c290115da..d3bd56535 100644 --- a/t/Frequency.t +++ b/t/Frequency.t @@ -27,4 +27,4 @@ ddg_goodie_test( 'frequency of B in battle' => test_zci('Frequency: b:1/6'), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/FrequencySpectrum.t b/t/FrequencySpectrum.t index a7ca29c7e..b299a6e74 100644 --- a/t/FrequencySpectrum.t +++ b/t/FrequencySpectrum.t @@ -259,4 +259,4 @@ ddg_goodie_test( '600 nmeters' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/GUID.t b/t/GUID.t index e524ea9c1..d57e39f33 100644 --- a/t/GUID.t +++ b/t/GUID.t @@ -26,4 +26,4 @@ ddg_goodie_test([qw( DDG::Goodie::GUID ) ], 'what is a guid' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Game2048.t b/t/Game2048.t index b3bc9e359..a299b4f0b 100644 --- a/t/Game2048.t +++ b/t/Game2048.t @@ -54,4 +54,4 @@ ddg_goodie_test( '2048 online' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/GenerateMAC.t b/t/GenerateMAC.t index 7c7c3f6ad..17c42c159 100755 --- a/t/GenerateMAC.t +++ b/t/GenerateMAC.t @@ -35,4 +35,4 @@ ddg_goodie_test( 'please generate mac address' => build_test(), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/GibberishGenerator.t b/t/GibberishGenerator.t index d1e618cfe..8239f86ea 100644 --- a/t/GibberishGenerator.t +++ b/t/GibberishGenerator.t @@ -76,4 +76,4 @@ ddg_goodie_test( '30 words of utter Shakespearean nonsense' => build_test(werds($shake_word, 30)), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/GoldenRatio.t b/t/GoldenRatio.t index b44103044..b5f11dd16 100644 --- a/t/GoldenRatio.t +++ b/t/GoldenRatio.t @@ -30,4 +30,4 @@ ddg_goodie_test( 'golden ratio ?:123.345' => test_zci('Golden ratio: 76.2314023423558 : 123.345'), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/GreatestCommonFactor.t b/t/GreatestCommonFactor.t index 836b0d9f2..cbf160c2f 100644 --- a/t/GreatestCommonFactor.t +++ b/t/GreatestCommonFactor.t @@ -47,4 +47,4 @@ ddg_goodie_test( 'gcd 0 0' => build_test('0 and 0', 0), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/GuitarChords.t b/t/GuitarChords.t index 4dcc6e5ad..9149be520 100644 --- a/t/GuitarChords.t +++ b/t/GuitarChords.t @@ -51,4 +51,4 @@ ddg_goodie_test( 'G' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/HTMLEntitiesDecode.t b/t/HTMLEntitiesDecode.t index d45f76797..4017eaf49 100755 --- a/t/HTMLEntitiesDecode.t +++ b/t/HTMLEntitiesDecode.t @@ -63,4 +63,4 @@ ddg_goodie_test( 'the decoded entity for ō is?' => test_zci(re(qr/.*/), structured_answer => any_structured_answer()), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/HTMLEntitiesEncode.t b/t/HTMLEntitiesEncode.t index 5be90e191..9fb709679 100755 --- a/t/HTMLEntitiesEncode.t +++ b/t/HTMLEntitiesEncode.t @@ -114,4 +114,4 @@ ddg_goodie_test( 'how to encode "?" in html' => test_zci("Encoded HTML Entity: ?", structured_answer => make_structured_answer(re(qr/#63/))), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/HelpLine.t b/t/HelpLine.t index 45f00e113..bd58893ad 100644 --- a/t/HelpLine.t +++ b/t/HelpLine.t @@ -64,4 +64,4 @@ ddg_goodie_test( } 0 .. scalar @ok_queries - 1), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/HexToASCII.t b/t/HexToASCII.t index ffab0cf03..ed67fed7e 100644 --- a/t/HexToASCII.t +++ b/t/HexToASCII.t @@ -36,4 +36,4 @@ ddg_goodie_test( 'ascii 0x466f7220736f6d6520726561736f6e2c2049206465636964656420746f2061736b20612073656172636820656e67696e6520746f20636f6e766572742068657820746f2041534349492e0d0a436f6f6c2c20746869732073656172636820656e67696e6520646f65732069742c20756e74696c20492072756e206f7574206f662073706163652e' => build_test('0x466f7220736f6d6520726561736f6e2c2049206465636964656420746f2061736b20612073656172636820656e67696e6520746f20636f6e766572742068657820746f2041534349492e0d0a436f6f6c2c20746869732073656172636820656e67696e6520646f65732069742c20756e74696c20492072756e206f7574206f662073706163652e', 'For some reason, I decided to ask a search engine to convert hex to ASCII.[CR][LF]Cool, this search engine does it, until I run out of …'), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/ISO639.t b/t/ISO639.t index defe46f81..2db1a1197 100644 --- a/t/ISO639.t +++ b/t/ISO639.t @@ -56,4 +56,4 @@ ddg_goodie_test( "iso639 xyz" => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/IndependenceDay.t b/t/IndependenceDay.t index 9c4097a6e..eb7a6d3b4 100644 --- a/t/IndependenceDay.t +++ b/t/IndependenceDay.t @@ -51,4 +51,4 @@ ddg_goodie_test( "day of independence of bhutan" => answer("Bhutan", "December 17th, 1907") ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Jira.t b/t/Jira.t index fa3a63d4f..3f36256ca 100644 --- a/t/Jira.t +++ b/t/Jira.t @@ -62,4 +62,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/JohnCena.t b/t/JohnCena.t index 8cb531dae..a758ddd82 100644 --- a/t/JohnCena.t +++ b/t/JohnCena.t @@ -33,4 +33,4 @@ ddg_goodie_test( 'famous wrestler' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Kana.t b/t/Kana.t index 9d14d6e72..c02acb238 100755 --- a/t/Kana.t +++ b/t/Kana.t @@ -180,4 +180,4 @@ ddg_goodie_test( 'ハ.ツha.tsu in romaji' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/KernelTaint.t b/t/KernelTaint.t index 9a6192cfa..ad7ebd709 100644 --- a/t/KernelTaint.t +++ b/t/KernelTaint.t @@ -20,4 +20,4 @@ ddg_goodie_test( '2 kernel taint description' => test_zci('- A module was force loaded by insmod -f. Set by modutils >= 2.4.9 and module-init-tools.', html => '
  • A module was force loaded by insmod -f. Set by modutils >= 2.4.9 and module-init-tools.
Read more') ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Latex.t b/t/Latex.t index ef41a96b3..93705e2f5 100644 --- a/t/Latex.t +++ b/t/Latex.t @@ -28,4 +28,4 @@ Example: $\sum_{i=0}^{10} x^{2}$', heading => 'Summation (LaTeX)'), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/LeapYear.t b/t/LeapYear.t index 9bf07f3e2..03e60198a 100755 --- a/t/LeapYear.t +++ b/t/LeapYear.t @@ -138,4 +138,4 @@ ddg_goodie_test( ); restore_time(); -done_testing(); \ No newline at end of file +done_testing(); diff --git a/t/LeetSpeak.t b/t/LeetSpeak.t index 000c5e0f4..98fdee537 100644 --- a/t/LeetSpeak.t +++ b/t/LeetSpeak.t @@ -57,4 +57,4 @@ ddg_goodie_test( 'l33tsp34k' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Loan.t b/t/Loan.t index cd5e9c581..c2ee8a17e 100644 --- a/t/Loan.t +++ b/t/Loan.t @@ -238,4 +238,4 @@ ddg_goodie_test ( ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/LoremIpsum.t b/t/LoremIpsum.t index b67300c96..f9939adff 100644 --- a/t/LoremIpsum.t +++ b/t/LoremIpsum.t @@ -84,4 +84,4 @@ ddg_goodie_test( ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Lowercase.t b/t/Lowercase.t index c66172dfb..7a2fbd736 100755 --- a/t/Lowercase.t +++ b/t/Lowercase.t @@ -39,4 +39,4 @@ ddg_goodie_test( 'how to lowercase text' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/MD4.t b/t/MD4.t index 68b81b136..09d52e564 100644 --- a/t/MD4.t +++ b/t/MD4.t @@ -86,4 +86,4 @@ ddg_goodie_test( 'md5 this string' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/MD5.t b/t/MD5.t index f73410474..4815fdd27 100644 --- a/t/MD5.t +++ b/t/MD5.t @@ -181,4 +181,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/MacAddress.t b/t/MacAddress.t index 2d90d65c2..3d005d149 100644 --- a/t/MacAddress.t +++ b/t/MacAddress.t @@ -58,4 +58,4 @@ ddg_goodie_test( 'mac address 1E:00:00:00:00:00' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/MagicEightBall.t b/t/MagicEightBall.t index c63e556cc..c91b67515 100644 --- a/t/MagicEightBall.t +++ b/t/MagicEightBall.t @@ -44,4 +44,4 @@ ddg_goodie_test( 'magic 8ball' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/MakeMeASandwich.t b/t/MakeMeASandwich.t index 25609a966..a0ae7ef5d 100644 --- a/t/MakeMeASandwich.t +++ b/t/MakeMeASandwich.t @@ -35,4 +35,4 @@ ddg_goodie_test( '0 make me a sandwich' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/MarkdownReference.t b/t/MarkdownReference.t index 724d84f79..8cc4fb4f1 100644 --- a/t/MarkdownReference.t +++ b/t/MarkdownReference.t @@ -72,4 +72,4 @@ ddg_goodie_test( 'markdown cheat sheet list' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Minecraft.t b/t/Minecraft.t index 5694bfa78..701a68454 100644 --- a/t/Minecraft.t +++ b/t/Minecraft.t @@ -142,4 +142,4 @@ sub make_structured_answer { }; }; -done_testing; \ No newline at end of file +done_testing; diff --git a/t/MoonPhases.t b/t/MoonPhases.t index c9d972d43..35a0dfd6b 100644 --- a/t/MoonPhases.t +++ b/t/MoonPhases.t @@ -54,4 +54,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Morse.t b/t/Morse.t index 06f42cf3b..a2088eee6 100644 --- a/t/Morse.t +++ b/t/Morse.t @@ -44,4 +44,4 @@ ddg_goodie_test([qw( 'morse code for cheat sheet' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/NLetterWords.t b/t/NLetterWords.t index 5d4ecd252..391c4be72 100644 --- a/t/NLetterWords.t +++ b/t/NLetterWords.t @@ -21,4 +21,4 @@ ddg_goodie_test( '12 character word' => test_zci(re(qr/Random 12 letter words: ((\w){12},? ?){30}/)), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/NameDays.t b/t/NameDays.t index dc016506d..9283e4646 100644 --- a/t/NameDays.t +++ b/t/NameDays.t @@ -177,4 +177,4 @@ ddg_goodie_test( 'name day' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/NoteFrequency.t b/t/NoteFrequency.t index 9b12aa319..ac77cb4f9 100644 --- a/t/NoteFrequency.t +++ b/t/NoteFrequency.t @@ -38,4 +38,4 @@ ddg_goodie_test( "notefreq c9" => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/OnionAddress.t b/t/OnionAddress.t index ad23093a7..605f06af7 100644 --- a/t/OnionAddress.t +++ b/t/OnionAddress.t @@ -166,4 +166,4 @@ sub make_structured_answer { }; }; -done_testing; \ No newline at end of file +done_testing; diff --git a/t/POTUS.t b/t/POTUS.t index f512a9b6b..bc6720bde 100755 --- a/t/POTUS.t +++ b/t/POTUS.t @@ -41,4 +41,4 @@ ddg_goodie_test( 'VPOTUS' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/PaleoIngredientCheck.t b/t/PaleoIngredientCheck.t index a87bf786b..a06a4921b 100644 --- a/t/PaleoIngredientCheck.t +++ b/t/PaleoIngredientCheck.t @@ -57,4 +57,4 @@ ddg_goodie_test( 'paleo recipes' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Paper.t b/t/Paper.t index 6e6bb8812..7410bcee3 100644 --- a/t/Paper.t +++ b/t/Paper.t @@ -77,4 +77,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/ParseCron.t b/t/ParseCron.t index 713236a02..83fcaebc3 100644 --- a/t/ParseCron.t +++ b/t/ParseCron.t @@ -369,4 +369,4 @@ ddg_goodie_test( }), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Passphrase.t b/t/Passphrase.t index 9dd5189fc..a25aa6446 100644 --- a/t/Passphrase.t +++ b/t/Passphrase.t @@ -55,4 +55,4 @@ sub count_words { }); } -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Password.t b/t/Password.t index 9f362589c..3391cfb2d 100644 --- a/t/Password.t +++ b/t/Password.t @@ -179,4 +179,4 @@ ddg_goodie_test( 'potatoe generator' => undef ); -done_testing \ No newline at end of file +done_testing diff --git a/t/PercentOf.t b/t/PercentOf.t index 5701bc27f..563daead1 100644 --- a/t/PercentOf.t +++ b/t/PercentOf.t @@ -73,4 +73,4 @@ ddg_goodie_test( '12+5t%' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Perimeter.t b/t/Perimeter.t index 49d610fdc..efc2d8d44 100644 --- a/t/Perimeter.t +++ b/t/Perimeter.t @@ -56,4 +56,4 @@ ddg_goodie_test( 'perimeter of square 3' => test_zci(build_answer(12, 'square', 3)), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/PeriodicTable.t b/t/PeriodicTable.t index b495f135c..d2df81173 100644 --- a/t/PeriodicTable.t +++ b/t/PeriodicTable.t @@ -438,4 +438,4 @@ sub make_structured_answer { }; }; -done_testing; \ No newline at end of file +done_testing; diff --git a/t/PhoneAlphabet.t b/t/PhoneAlphabet.t index 3ea09c83c..aa9c9f790 100644 --- a/t/PhoneAlphabet.t +++ b/t/PhoneAlphabet.t @@ -60,4 +60,4 @@ ddg_goodie_test( '0x0123 to digits' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Phonetic.t b/t/Phonetic.t index 1bd8db927..b74536249 100644 --- a/t/Phonetic.t +++ b/t/Phonetic.t @@ -19,4 +19,4 @@ ddg_goodie_test( 'phonetic Who are you?' => test_zci('Phonetic: Whiskey-Hotel-Oscar Alfa-Romeo-Echo Yankee-Oscar-Uniform') ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Pi.t b/t/Pi.t index 13d822bab..7fe3f9ead 100644 --- a/t/Pi.t +++ b/t/Pi.t @@ -55,4 +55,4 @@ ddg_goodie_test( ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/PigLatin.t b/t/PigLatin.t index 9a39fb6c1..aec622a6f 100644 --- a/t/PigLatin.t +++ b/t/PigLatin.t @@ -55,4 +55,4 @@ ddg_goodie_test( 'piglatin 0' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Poker.t b/t/Poker.t index 171420699..0069b0d1a 100644 --- a/t/Poker.t +++ b/t/Poker.t @@ -35,4 +35,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/PrimeFactors.t b/t/PrimeFactors.t index 2620440c2..08bd5ae26 100644 --- a/t/PrimeFactors.t +++ b/t/PrimeFactors.t @@ -45,4 +45,4 @@ ddg_goodie_test( 'optimus prime 45' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/PrimeNumber.t b/t/PrimeNumber.t index d4af908a1..b643bb400 100644 --- a/t/PrimeNumber.t +++ b/t/PrimeNumber.t @@ -76,4 +76,4 @@ sub make_structured_answer { }; }; -done_testing; \ No newline at end of file +done_testing; diff --git a/t/PrivateNetwork.t b/t/PrivateNetwork.t index ca02ede3c..78e8be4a8 100644 --- a/t/PrivateNetwork.t +++ b/t/PrivateNetwork.t @@ -35,4 +35,4 @@ Unique local addresses: fd00::/8 )) } ( 'private network', 'private networks', 'private ips' ) ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/PublicDNS.t b/t/PublicDNS.t index b3380d49e..03b341320 100644 --- a/t/PublicDNS.t +++ b/t/PublicDNS.t @@ -41,4 +41,4 @@ ddg_goodie_test([qw( DDG::Goodie::PublicDNS)], ) ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Rafl.t b/t/Rafl.t index f8257b38a..3f3f619f1 100644 --- a/t/Rafl.t +++ b/t/Rafl.t @@ -25,4 +25,4 @@ ddg_goodie_test( 'where is rafl?' => test_zci(@rafl), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Randagram.t b/t/Randagram.t index 4acca21af..b32ffdbe4 100644 --- a/t/Randagram.t +++ b/t/Randagram.t @@ -15,4 +15,4 @@ ddg_goodie_test( 'randagram jazz hands' => test_zci(re(qr/Randagram of "jazz hands": [jazz hands]/)), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/RandomName.t b/t/RandomName.t index 2db649b8d..5c4e71c1f 100644 --- a/t/RandomName.t +++ b/t/RandomName.t @@ -23,4 +23,4 @@ ddg_goodie_test( 'names of random people' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/RandomNumber.t b/t/RandomNumber.t index 0d6bf944a..8fe555c9f 100644 --- a/t/RandomNumber.t +++ b/t/RandomNumber.t @@ -40,4 +40,4 @@ ddg_goodie_test( 'random access' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Rc4.t b/t/Rc4.t index 58f112b42..f84a141c1 100644 --- a/t/Rc4.t +++ b/t/Rc4.t @@ -30,4 +30,4 @@ ddg_goodie_test( 'rc4 no operation' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Regexp.t b/t/Regexp.t index 7e4f5026d..1096f3614 100644 --- a/t/Regexp.t +++ b/t/Regexp.t @@ -85,4 +85,4 @@ ddg_goodie_test([qw( DDG::Goodie::Regexp )], #'regexp /(?h)/ h' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/ReverseResistorColours.t b/t/ReverseResistorColours.t index 8abc7d005..1942270d7 100644 --- a/t/ReverseResistorColours.t +++ b/t/ReverseResistorColours.t @@ -116,4 +116,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Roman.t b/t/Roman.t index 3d9c839ef..dad59be6b 100644 --- a/t/Roman.t +++ b/t/Roman.t @@ -77,4 +77,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Rot13.t b/t/Rot13.t index 157191259..69b4c2c6c 100644 --- a/t/Rot13.t +++ b/t/Rot13.t @@ -37,4 +37,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/RouterPasswords.t b/t/RouterPasswords.t index 63a5b1e4a..7b6b3a1e4 100644 --- a/t/RouterPasswords.t +++ b/t/RouterPasswords.t @@ -60,4 +60,4 @@ ddg_goodie_test( # This function call is expected by Test::More. It makes sure the program # doesn't exit before all the tests have been run. -done_testing; \ No newline at end of file +done_testing; diff --git a/t/RubiksCubePatterns.t b/t/RubiksCubePatterns.t index e90a54ae2..882a64181 100644 --- a/t/RubiksCubePatterns.t +++ b/t/RubiksCubePatterns.t @@ -163,4 +163,4 @@ ddg_goodie_test( 'rubics cube' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Scramble.t b/t/Scramble.t index 38ba82d77..beb99062e 100644 --- a/t/Scramble.t +++ b/t/Scramble.t @@ -25,4 +25,4 @@ ddg_goodie_test( 'Scrambles for "867-5309"' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/ScreenResolution.t b/t/ScreenResolution.t index 2ab3e1ee6..0f97f217d 100644 --- a/t/ScreenResolution.t +++ b/t/ScreenResolution.t @@ -36,4 +36,4 @@ ddg_goodie_test( 'blah blah screen resolution' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/SecurityAddons.t b/t/SecurityAddons.t index 35e8885b3..5bc34b0c9 100644 --- a/t/SecurityAddons.t +++ b/t/SecurityAddons.t @@ -57,4 +57,4 @@ ddg_goodie_test( 'internet explorer privacy addons' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Sha.t b/t/Sha.t index 5a17c48c9..b32da27ca 100644 --- a/t/Sha.t +++ b/t/Sha.t @@ -218,4 +218,4 @@ ddg_goodie_test( 'shadow' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Shruggie.t b/t/Shruggie.t index 7d00865e8..95c2c5b53 100644 --- a/t/Shruggie.t +++ b/t/Shruggie.t @@ -87,4 +87,4 @@ ddg_goodie_test( 'shruggie andover' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/SigFigs.t b/t/SigFigs.t index cbc48f732..46de3f9d1 100644 --- a/t/SigFigs.t +++ b/t/SigFigs.t @@ -51,4 +51,4 @@ ddg_goodie_test( 'How many sig figs are there in 11.3' => build_test('3', '11.3'), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/SolarSystem.t b/t/SolarSystem.t index 0bb2a8644..21f4da127 100644 --- a/t/SolarSystem.t +++ b/t/SolarSystem.t @@ -111,4 +111,4 @@ ddg_goodie_test( 'radius of orange' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Sort.t b/t/Sort.t index 10592a24d..89a246977 100644 --- a/t/Sort.t +++ b/t/Sort.t @@ -80,4 +80,4 @@ ddg_goodie_test( 'sort' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Stardate.t b/t/Stardate.t index 2a7a8ae4b..8b458e4ea 100644 --- a/t/Stardate.t +++ b/t/Stardate.t @@ -30,4 +30,4 @@ ddg_goodie_test( 'stardate 29 feb 2015' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/SubnetCalc.t b/t/SubnetCalc.t index f11e0bbf3..3be44a0ce 100755 --- a/t/SubnetCalc.t +++ b/t/SubnetCalc.t @@ -97,4 +97,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Sudoku.t b/t/Sudoku.t index 9eb1f6f49..8aebe0630 100644 --- a/t/Sudoku.t +++ b/t/Sudoku.t @@ -42,4 +42,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/SumOfNaturalNumbers.t b/t/SumOfNaturalNumbers.t index aa9aa54d3..e65c1f48d 100644 --- a/t/SumOfNaturalNumbers.t +++ b/t/SumOfNaturalNumbers.t @@ -27,4 +27,4 @@ ddg_goodie_test( 'add ten to twenty' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/SunInfo.t b/t/SunInfo.t index c86941c07..a47849e96 100755 --- a/t/SunInfo.t +++ b/t/SunInfo.t @@ -134,4 +134,4 @@ ddg_goodie_test( 'after the sunset' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Teredo.t b/t/Teredo.t index f2794fc83..4f2b99600 100644 --- a/t/Teredo.t +++ b/t/Teredo.t @@ -81,4 +81,4 @@ ddg_goodie_test( ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/TimezoneConverter.t b/t/TimezoneConverter.t index d359510da..abff5945c 100644 --- a/t/TimezoneConverter.t +++ b/t/TimezoneConverter.t @@ -397,4 +397,4 @@ ddg_goodie_test( ); restore_time(); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Tips.t b/t/Tips.t index 433cda2ad..8f8eb1cd7 100644 --- a/t/Tips.t +++ b/t/Tips.t @@ -26,4 +26,4 @@ ddg_goodie_test( '4 of 5 dentists' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/TitleCase.t b/t/TitleCase.t index ad44cb0fd..54078e0aa 100755 --- a/t/TitleCase.t +++ b/t/TitleCase.t @@ -35,4 +35,4 @@ ddg_goodie_test( 'how do i make something titlecase' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/TwelveOclock.t b/t/TwelveOclock.t index caf297043..2d7a0255f 100644 --- a/t/TwelveOclock.t +++ b/t/TwelveOclock.t @@ -73,4 +73,4 @@ ddg_goodie_test( 'when is noon in Jakarta?' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/URLDecode.t b/t/URLDecode.t index 2de98a3eb..b10bc549d 100755 --- a/t/URLDecode.t +++ b/t/URLDecode.t @@ -64,4 +64,4 @@ ddg_goodie_test( 'url decode online' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/URLEncode.t b/t/URLEncode.t index 2e76e9c12..f0526c984 100644 --- a/t/URLEncode.t +++ b/t/URLEncode.t @@ -53,4 +53,4 @@ ddg_goodie_test( 'hello there escapeurl' => test_zci(build_answer('hello%20there', 'hello there')), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/UltimateAnswer.t b/t/UltimateAnswer.t index d4ae98093..3000c2f81 100644 --- a/t/UltimateAnswer.t +++ b/t/UltimateAnswer.t @@ -107,4 +107,4 @@ ddg_goodie_test( 'why?' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Unicode.t b/t/Unicode.t index b4a98da91..dc1b28c55 100644 --- a/t/Unicode.t +++ b/t/Unicode.t @@ -48,4 +48,4 @@ ddg_goodie_test( 'utf-15 bullet' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/UnicodeFuzzySearch.t b/t/UnicodeFuzzySearch.t index b372b6315..0c72eb7b4 100644 --- a/t/UnicodeFuzzySearch.t +++ b/t/UnicodeFuzzySearch.t @@ -66,4 +66,4 @@ ROTATED HEAVY BLACK HEART BULLET: \x{2765} (U+2765)", ) ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Unicornify.t b/t/Unicornify.t index 921dd33e3..24dcd4494 100644 --- a/t/Unicornify.t +++ b/t/Unicornify.t @@ -38,4 +38,4 @@ ddg_goodie_test( } })); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/UnixPermissions.t b/t/UnixPermissions.t index f2bea418c..e14d051f3 100644 --- a/t/UnixPermissions.t +++ b/t/UnixPermissions.t @@ -98,4 +98,4 @@ Others: read, write and execute 'permission 9644' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/UnixTime.t b/t/UnixTime.t index e1d8d04f7..ff8609993 100644 --- a/t/UnixTime.t +++ b/t/UnixTime.t @@ -109,4 +109,4 @@ ddg_goodie_test([qw( 'unix time info' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Uppercase.t b/t/Uppercase.t index 750f05f0c..4e8177ed3 100755 --- a/t/Uppercase.t +++ b/t/Uppercase.t @@ -34,4 +34,4 @@ ddg_goodie_test( 'uppercase 123' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Uptime.t b/t/Uptime.t index a45bc2a18..15235ae82 100644 --- a/t/Uptime.t +++ b/t/Uptime.t @@ -173,4 +173,4 @@ ddg_goodie_test( 'up time 99%%' => undef ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/VIN.t b/t/VIN.t index f3d9b98b1..da7a178ac 100644 --- a/t/VIN.t +++ b/t/VIN.t @@ -73,4 +73,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/ValarMorghulis.t b/t/ValarMorghulis.t index 32db4adbd..5ef5e1e67 100644 --- a/t/ValarMorghulis.t +++ b/t/ValarMorghulis.t @@ -28,4 +28,4 @@ ddg_goodie_test( 'valar morghulis meaning' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Wavelength.t b/t/Wavelength.t index 71e0674f1..c52230ffd 100644 --- a/t/Wavelength.t +++ b/t/Wavelength.t @@ -42,4 +42,4 @@ sub mk_test { result => $expect, } ); -} \ No newline at end of file +} diff --git a/t/Week.t b/t/Week.t index b79f49368..d01aba334 100755 --- a/t/Week.t +++ b/t/Week.t @@ -106,4 +106,4 @@ ddg_goodie_test( ); restore_time(); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/WeekdaysBetween.t b/t/WeekdaysBetween.t index 38194ca23..42fd71129 100755 --- a/t/WeekdaysBetween.t +++ b/t/WeekdaysBetween.t @@ -131,4 +131,4 @@ ddg_goodie_test( 'Weekdays between 18/17/2013 and 21/23/2015 inclusive' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Weight.t b/t/Weight.t index 41c593d22..2965f613c 100644 --- a/t/Weight.t +++ b/t/Weight.t @@ -22,4 +22,4 @@ ddg_goodie_test( 'weight 5' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/WhereAmI.t b/t/WhereAmI.t index 8878216eb..f9b30626e 100644 --- a/t/WhereAmI.t +++ b/t/WhereAmI.t @@ -32,4 +32,4 @@ ddg_goodie_test( 'my location is nowhere!' => undef, ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/WorkdaysBetween.t b/t/WorkdaysBetween.t index 914d83fc6..0110502ab 100755 --- a/t/WorkdaysBetween.t +++ b/t/WorkdaysBetween.t @@ -232,4 +232,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/ZappBrannigan.t b/t/ZappBrannigan.t index 0895f24c6..90c70b034 100644 --- a/t/ZappBrannigan.t +++ b/t/ZappBrannigan.t @@ -28,4 +28,4 @@ ddg_goodie_test( ), ); -done_testing; \ No newline at end of file +done_testing; diff --git a/t/Zodiac.t b/t/Zodiac.t index 0df9923db..699ccc056 100644 --- a/t/Zodiac.t +++ b/t/Zodiac.t @@ -111,4 +111,4 @@ ddg_goodie_test([ qw( DDG::Goodie::Zodiac ) ], restore_time(); -done_testing; \ No newline at end of file +done_testing;