zeroclickinfo-goodies/t/FrequencySpectrum.t

118 lines
2.7 KiB
Perl
Raw Normal View History

#!/usr/bin/env perl
# NOTE: Audible frequency results are currently being suppressed,
# as the resulting IA is too long. This will be revisited when
# better stying is available.
use strict;
use warnings;
use Test::More;
use DDG::Test::Goodie;
zci answer_type => 'frequency_spectrum';
zci is_cached => 1;
ddg_goodie_test(
['DDG::Goodie::FrequencySpectrum'],
2014-07-05 01:05:03 -07:00
#Primary example
'50 hz' => test_zci(
#qr/radio.+SLF.+audible.+double-bass.+piano.+tuba/,
qr/radio/,
2014-07-05 01:05:03 -07:00
html => qr/radio/
),
2014-07-05 01:05:03 -07:00
#Secondary example
'400 thz' => test_zci(
2014-07-23 02:23:10 -07:00
qr/infrared/,
html => qr/infrared/
),
2014-07-05 01:05:03 -07:00
#Misc
2014-01-23 11:35:32 -08:00
'1,000 hz' => test_zci(
#qr/radio.+audible.+human.+voice.+viola.+violin.+guitar.+mandolin.+banjo.+piano.+saxophone.+flute.+clarinet.+oboe/,
qr/radio/,
2014-07-05 01:05:03 -07:00
html => qr/radio.+/
2014-01-23 11:35:32 -08:00
),
'1000000.99 hz' => test_zci(
2014-07-05 01:05:03 -07:00
qr/radio.+MF/,
html => qr/radio.+MF/
2014-01-23 11:35:32 -08:00
),
2014-07-23 02:23:10 -07:00
'29.1 hz' => test_zci(
qr/radio.+ELF/,
html => qr/radio.+ELF/
),
2014-01-23 11:35:32 -08:00
#No whitespace between number and unit
'50hz' => test_zci(
#qr/radio.+SLF.+audible.+double-bass.+piano.+tuba/,
qr/radio/,
html => qr/radio/
),
'400terahertz' => test_zci(
2014-07-23 02:23:10 -07:00
qr/infrared/,
html => qr/infrared/
),
2014-07-21 18:08:45 -07:00
#Mixed case
'400 THz' => test_zci(
2014-07-23 02:23:10 -07:00
qr/infrared/,
html => qr/infrared/
2014-07-21 18:08:45 -07:00
),
'1000 HZ' => test_zci(
#qr/radio.+audible.+human.+voice.+viola.+violin.+guitar.+mandolin.+banjo.+piano.+saxophone.+flute.+clarinet.+oboe/,
qr/radio/,
2014-07-21 18:08:45 -07:00
html => qr/radio.+/
),
#Commas in number
'1,000,000.99 hz' => test_zci(
qr/radio.+MF/,
html => qr/radio.+MF/
),
#Can you test with all the colours of the wind?
'650 nm' => test_zci(
qr/visible.+red/,
html => qr/visible.+red/
),
'610 nanometers' => test_zci(
qr/visible.+orange/,
html => qr/visible.+orange/
),
'580 nanometres' => test_zci(
qr/visible.+yellow/,
html => qr/visible.+yellow/
),
'536 nanometer' => test_zci(
qr/visible.+green/,
html => qr/visible.+green/
),
'478.1 nm' => test_zci(
qr/visible.+blue/,
html => qr/visible.+blue/
),
'380.000000000 nanometres' => test_zci(
qr/visible.+violet/,
html => qr/visible.+violet/
),
#Only visible light wavelengths should trigger
'0.1 nm' => undef,
'100 nm' => undef,
'800 nm' => undef,
2014-07-21 21:01:19 -07:00
'10000 nm' => undef,
#Malformed frequencies/wavelengths should not trigger
2014-01-23 11:35:32 -08:00
'1000.000..99 hz' => undef,
2014-07-18 00:06:17 -07:00
'15 kilo hertz' => undef,
'100,123 jiggahz' => undef,
'hertz' => undef,
'terahz' => undef,
'600 nmeters' => undef,
);
2014-01-22 10:12:02 -08:00
done_testing;