zeroclickinfo-goodies/t/MoonPhases.t

41 lines
983 B
Perl
Raw Permalink Normal View History

2012-08-10 08:21:47 -07:00
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
2012-08-10 08:21:47 -07:00
use DDG::Test::Goodie;
zci answer_type => 'moon_phase';
zci is_cached => 0;
2012-08-10 08:21:47 -07:00
my $space_plus = qr/(?:\s|\+)/;
my $wax_wane = qr/(?:Waxing|Waning)$space_plus(?:Gibbous|Crescent)/;
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 = re(qr/^The current lunar phase is: $phases$/);
2016-05-17 13:01:01 -07:00
sub build_test {
return test_zci($ascii_answer, structured_answer => {
data => {
title => re($phases),
subtitle => 'Current lunar phase'
},
templates => {
group => 'text'
}
});
}
2012-08-10 08:21:47 -07:00
ddg_goodie_test(
[qw( DDG::Goodie::MoonPhases)],
'moon phase' => build_test(),
'lunar phase' => build_test(),
'phase of the moon' => build_test(),
'what is the current lunar phase' => build_test()
2012-08-10 08:21:47 -07:00
);
2016-05-16 06:18:04 -07:00
done_testing;