2015-11-06 09:13:37 -08:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
2016-05-16 06:07:57 -07:00
|
|
|
use Test::Deep;
|
2015-11-06 09:13:37 -08:00
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => "note_frequency";
|
|
|
|
zci is_cached => 1;
|
|
|
|
|
2016-04-28 11:32:23 -07:00
|
|
|
sub build_structured_answer {
|
|
|
|
my ($input, $frequency) = @_;
|
|
|
|
return $frequency,
|
|
|
|
structured_answer => {
|
|
|
|
data => {
|
|
|
|
title => $frequency." Hz",
|
|
|
|
subtitle => "Note Frequency: " . $input,
|
|
|
|
},
|
|
|
|
templates => {
|
|
|
|
group => 'text',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
sub build_test { test_zci(build_structured_answer(@_)) }
|
|
|
|
|
2015-11-06 09:13:37 -08:00
|
|
|
ddg_goodie_test(
|
|
|
|
[qw( DDG::Goodie::NoteFrequency )],
|
2016-04-28 11:32:23 -07:00
|
|
|
"notefreq a4" => build_test("A4 in A440 tuning", "440"),
|
|
|
|
"notefreq gb5" => build_test("Gb5 in A440 tuning", "739.99"),
|
|
|
|
"notefreq c3 432" => build_test("C3 in A432 tuning", "128.43"),
|
|
|
|
"notefreq c3 432Hz" => build_test("C3 in A432 tuning", "128.43"),
|
2015-11-09 13:42:18 -08:00
|
|
|
"notefreq c3 432 Hz" => undef,
|
2016-04-28 11:32:23 -07:00
|
|
|
"notefreq a4 100000" => undef,
|
|
|
|
"notefreq b#8" => undef,
|
|
|
|
"notefreq cb0" => undef,
|
|
|
|
"notefreq c9" => undef,
|
2015-11-06 09:13:37 -08:00
|
|
|
);
|
|
|
|
|
2016-05-16 06:18:04 -07:00
|
|
|
done_testing;
|