Frequency: Fix tests
parent
8c9ac65ed0
commit
16b295c974
|
@ -9,6 +9,7 @@ triggers start => 'frequency', 'freq';
|
|||
handle remainder => sub {
|
||||
if ($_ =~ /^of ([a-z]|(?:all ?|)(?:letters|characters|chars|)) in (.+)/i) {
|
||||
|
||||
my $collect_exact = $1;
|
||||
my $collect = lc $1;
|
||||
my $query_str = $2;
|
||||
my $target_str = lc $2;
|
||||
|
@ -45,7 +46,7 @@ handle remainder => sub {
|
|||
$subtitle = "Frequency of all characters";
|
||||
}
|
||||
else {
|
||||
$subtitle = "Frequency of '$collect'";
|
||||
$subtitle = "Frequency of '$collect_exact'";
|
||||
}
|
||||
|
||||
@record_data = \%freq;
|
||||
|
|
|
@ -9,15 +9,16 @@ use DDG::Test::Goodie;
|
|||
zci is_cached => 1;
|
||||
zci answer_type => 'frequency';
|
||||
|
||||
my $general_title_prefix = "Frequency of each character in";
|
||||
my $all_chars_subtitle = "Frequency of all characters";
|
||||
|
||||
sub build_structured_test {
|
||||
my ($plaintext, $title, $record_data, $record_keys) = @_;
|
||||
my ($plaintext, $title, $subtitle, $record_data, $record_keys) = @_;
|
||||
|
||||
return $plaintext,
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => $title,
|
||||
subtitle => $subtitle,
|
||||
record_data => $record_data,
|
||||
record_keys => $record_keys
|
||||
},
|
||||
|
@ -39,37 +40,37 @@ ddg_goodie_test(
|
|||
DDG::Goodie::Frequency
|
||||
)],
|
||||
|
||||
"frequency of all in test" => build_test('e:1/4 s:1/4 t:2/4', "$general_title_prefix test", {
|
||||
"frequency of all in test" => build_test('e:1/4 s:1/4 t:2/4', "test", "$all_chars_subtitle", {
|
||||
'e' => 1,
|
||||
's' => 1,
|
||||
't' => 2
|
||||
}, ['e', 's', 't']),
|
||||
|
||||
'frequency of all letters in test' => build_test('e:1/4 s:1/4 t:2/4', "$general_title_prefix test", {
|
||||
'frequency of all letters in test' => build_test('e:1/4 s:1/4 t:2/4', "test", "$all_chars_subtitle", {
|
||||
'e' => 1,
|
||||
's' => 1,
|
||||
't' => 2
|
||||
}, ['e', 's', 't']),
|
||||
|
||||
'frequency of letters in test' => build_test('e:1/4 s:1/4 t:2/4', "$general_title_prefix test", {
|
||||
'frequency of letters in test' => build_test('e:1/4 s:1/4 t:2/4', "test", "$all_chars_subtitle", {
|
||||
'e' => 1,
|
||||
's' => 1,
|
||||
't' => 2
|
||||
}, ['e', 's', 't']),
|
||||
|
||||
'frequency of all characters in test' => build_test('e:1/4 s:1/4 t:2/4', "$general_title_prefix test", {
|
||||
'frequency of all characters in test' => build_test('e:1/4 s:1/4 t:2/4', "test", "$all_chars_subtitle", {
|
||||
'e' => 1,
|
||||
's' => 1,
|
||||
't' => 2
|
||||
}, ['e', 's', 't']),
|
||||
|
||||
'frequency of all chars in test' => build_test('e:1/4 s:1/4 t:2/4', "$general_title_prefix test", {
|
||||
'frequency of all chars in test' => build_test('e:1/4 s:1/4 t:2/4', "test", "$all_chars_subtitle", {
|
||||
'e' => 1,
|
||||
's' => 1,
|
||||
't' => 2
|
||||
}, ['e', 's', 't']),
|
||||
|
||||
'frequency of all in testing 1234 ABC!' => build_test('a:1/10 b:1/10 c:1/10 e:1/10 g:1/10 i:1/10 n:1/10 s:1/10 t:2/10', "$general_title_prefix testing 1234 ABC!", {
|
||||
'frequency of all in testing 1234 ABC!' => build_test('a:1/10 b:1/10 c:1/10 e:1/10 g:1/10 i:1/10 n:1/10 s:1/10 t:2/10', "testing 1234 ABC!", "$all_chars_subtitle", {
|
||||
'a' => 1,
|
||||
'b' => 1,
|
||||
'c' => 1,
|
||||
|
@ -81,15 +82,15 @@ ddg_goodie_test(
|
|||
't' => 2
|
||||
}, ['a', 'b', 'c', 'e', 'g', 'i', 'n', 's', 't']),
|
||||
|
||||
'frequency of a in Atlantic Ocean' => build_test('a:3/13', "Frequency of a in Atlantic Ocean", {
|
||||
'frequency of a in Atlantic Ocean' => build_test('a:3/13', "Atlantic Ocean", "Frequency of 'a'", {
|
||||
"a" => 3
|
||||
}, ["a"]),
|
||||
|
||||
'freq of B in battle' => build_test('b:1/6', "Frequency of B in battle", {
|
||||
'freq of B in battle' => build_test('b:1/6', "battle", "Frequency of 'B'", {
|
||||
'b' => 1
|
||||
}, ['b']),
|
||||
|
||||
'freq of s in Spoons' => build_test('s:2/6', "Frequency of s in Spoons", {
|
||||
'freq of s in Spoons' => build_test('s:2/6', "Spoons", "Frequency of 's'", {
|
||||
's' => 2
|
||||
}, ['s']),
|
||||
|
||||
|
|
Loading…
Reference in New Issue