zeroclickinfo-goodies/t/LeapYear.t

142 lines
4.0 KiB
Perl
Raw Normal View History

2013-11-01 09:09:57 -07:00
#!/usr/bin/env perl
use strict;
use warnings;
2015-01-02 02:45:04 -08:00
use Test::MockTime qw( :all );
2013-11-01 09:09:57 -07:00
use Test::More;
use Test::Deep;
2013-11-01 09:09:57 -07:00
use DDG::Test::Goodie;
zci answer_type => 'leap_year';
2013-11-17 16:57:50 -08:00
zci is_cached => 1;
2015-01-02 02:45:04 -08:00
2013-11-01 09:09:57 -07:00
ddg_goodie_test(
[qw(
DDG::Goodie::LeapYear
)],
2015-07-17 04:53:37 -07:00
'was 2012 a leap year' => test_zci('Yes! 2012 was a leap year',
2015-07-14 23:55:22 -07:00
structured_answer => {
data => {
subtitle => undef,
2015-07-17 04:53:37 -07:00
title => "Yes! 2012 was a leap year"
2015-07-14 23:55:22 -07:00
},
templates => {
group => "text",
moreAt => 0
}
}),
2015-07-17 04:53:37 -07:00
'will 3012 be a leap year' => test_zci('Yes! 3012 will be a leap year',
2015-07-14 23:55:22 -07:00
structured_answer => {
data => {
subtitle => undef,
2015-07-17 04:53:37 -07:00
title => "Yes! 3012 will be a leap year"
2015-07-14 23:55:22 -07:00
},
templates => {
group => "text",
moreAt => 0
}
}),
'was 1 bce a leap year' => test_zci('No. 1 BCE was not a leap year',
structured_answer => {
data => {
subtitle => undef,
title => "No. 1 BCE was not a leap year"
},
templates => {
group => "text",
moreAt => 0
}
}),
2015-07-17 04:53:37 -07:00
'leap years after 2005' => test_zci('The 5 leap years after 2005 are 2008, 2012, 2016, 2020, 2024',
2015-07-14 23:55:22 -07:00
structured_answer => {
data => {
2015-07-17 04:53:37 -07:00
subtitle => "The 5 leap years after 2005",
title => "2008, 2012, 2016, 2020, 2024"
2015-07-14 23:55:22 -07:00
},
templates => {
group => "text",
moreAt => 0
}
}),
'leap years before 2 bc' => test_zci('The 5 leap years before 2 BCE are 4 BCE, 8 BCE, 12 BCE, 16 BCE, 20 BCE',
structured_answer => {
data => {
subtitle => "The 5 leap years before 2 BCE",
title => "4 BCE, 8 BCE, 12 BCE, 16 BCE, 20 BCE"
},
templates => {
group => "text",
moreAt => 0
}
})
2013-11-01 09:09:57 -07:00
);
2015-01-02 02:45:04 -08:00
set_fixed_time("2014-12-01T00:00:00");
ddg_goodie_test(
[qw(
DDG::Goodie::LeapYear
)],
2015-07-17 04:53:37 -07:00
'is it a leap year?' => test_zci('No. 2014 is not a leap year',
2015-07-14 23:55:22 -07:00
structured_answer => {
data => {
subtitle => undef,
2015-07-17 04:53:37 -07:00
title => "No. 2014 is not a leap year"
2015-07-14 23:55:22 -07:00
},
templates => {
group => "text",
moreAt => 0
}
}),
2015-07-17 04:53:37 -07:00
'when were the last 50 leap years' => test_zci('The last 50 leap years were 2012, 2008, 2004, 2000, 1996, 1992, 1988, 1984, 1980, 1976, 1972, 1968, 1964, 1960, 1956, 1952, 1948, 1944, 1940, 1936, 1932, 1928, 1924, 1920, 1916, 1912, 1908, 1904, 1896, 1892, 1888, 1884, 1880, 1876, 1872, 1868, 1864, 1860, 1856, 1852, 1848, 1844, 1840, 1836, 1832, 1828, 1824, 1820, 1816, 1812',
2015-07-14 23:55:22 -07:00
structured_answer => {
data => {
subtitle => "The last 50 leap years",
2015-07-17 04:53:37 -07:00
title => "2012, 2008, 2004, 2000, 1996, 1992, 1988, 1984, 1980, 1976, 1972, 1968, 1964, 1960, 1956, 1952, 1948, 1944, 1940, 1936, 1932, 1928, 1924, 1920, 1916, 1912, 1908, 1904, 1896, 1892, 1888, 1884, 1880, 1876, 1872, 1868, 1864, 1860, 1856, 1852, 1848, 1844, 1840, 1836, 1832, 1828, 1824, 1820, 1816, 1812",
2015-07-14 23:55:22 -07:00
},
templates => {
group => "text",
moreAt => 0
}
})
2015-01-02 02:45:04 -08:00
);
restore_time();
set_fixed_time("2015-12-01T00:00:00");
2015-01-02 02:45:04 -08:00
ddg_goodie_test(
[qw(
DDG::Goodie::LeapYear
)],
2015-07-17 04:53:37 -07:00
'is it a leap year?' => test_zci('No. 2015 is not a leap year',
2015-07-14 23:55:22 -07:00
structured_answer => {
data => {
2015-07-17 04:53:37 -07:00
title => 'No. 2015 is not a leap year',
2015-07-14 23:55:22 -07:00
subtitle => undef
},
templates => {
group => "text",
moreAt => 0
}
})
);
restore_time();
set_fixed_time("2012-12-01T00:00:00");
ddg_goodie_test(
[qw(
DDG::Goodie::LeapYear
)],
2015-07-17 04:53:37 -07:00
'is it a leap year?' => test_zci('Yes! 2012 is a leap year',
2015-07-14 23:55:22 -07:00
structured_answer => {
data => {
2015-07-17 04:53:37 -07:00
title => 'Yes! 2012 is a leap year',
2015-07-14 23:55:22 -07:00
subtitle => undef
},
templates => {
group => "text",
moreAt => 0
}
})
2015-01-02 02:45:04 -08:00
);
restore_time();
2016-05-16 06:18:04 -07:00
done_testing();