2012-08-10 08:21:47 -07:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
2016-05-16 06:07:57 -07:00
|
|
|
use Test::Deep;
|
2012-08-10 08:21:47 -07:00
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
2014-09-26 12:21:38 -07:00
|
|
|
zci answer_type => 'moon_phase';
|
2014-02-15 10:41:47 -08:00
|
|
|
zci is_cached => 0;
|
2012-08-10 08:21:47 -07:00
|
|
|
|
2014-02-15 10:41:47 -08: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/;
|
|
|
|
|
2016-05-16 06:07:57 -07:00
|
|
|
my $ascii_answer = re(qr/^The current lunar phase is: $phases$/);
|
2014-02-15 10:41:47 -08:00
|
|
|
|
2016-05-17 13:01:01 -07:00
|
|
|
sub build_test {
|
2016-05-17 12:32:42 -07:00
|
|
|
return test_zci($ascii_answer, structured_answer => {
|
|
|
|
data => {
|
2016-05-17 12:33:57 -07:00
|
|
|
title => re($phases),
|
|
|
|
subtitle => 'Current lunar phase'
|
2016-05-17 12:32:42 -07:00
|
|
|
},
|
|
|
|
templates => {
|
|
|
|
group => 'text'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-08-10 08:21:47 -07:00
|
|
|
ddg_goodie_test(
|
2014-02-15 10:41:47 -08:00
|
|
|
[qw( DDG::Goodie::MoonPhases)],
|
2016-05-17 12:32:42 -07:00
|
|
|
'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;
|