zeroclickinfo-goodies/t/Constants.t

63 lines
1.4 KiB
Perl
Raw Normal View History

2015-04-06 07:07:54 -07:00
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
2015-04-06 07:07:54 -07:00
use Test::More;
use Test::Deep;
2015-04-06 07:07:54 -07:00
use DDG::Test::Goodie;
zci answer_type => "constants";
zci is_cached => 1;
2016-05-14 12:21:54 -07:00
sub build_test
{
my ($text, $subtitle, $title) = @_;
return test_zci($text, structured_answer => {
data => {
constant => $title,
subtitle => $subtitle,
2016-05-14 12:21:54 -07:00
},
templates => {
group => 'text',
options => {
title_content => 'DDH.constants.title_content'
}
2016-05-14 12:21:54 -07:00
},
meta => {
signal => 'high'
}
});
}
2015-04-06 07:07:54 -07:00
ddg_goodie_test(
[qw( DDG::Goodie::Constants )],
2016-05-14 12:21:54 -07:00
"Hardy Ramanujan number" => build_test(
'1^3 + 12^3 = 9^3 + 10^3',
2016-05-14 12:21:54 -07:00
'Hardy Ramanujan Number 1729',
"1<sup>3</sup> + 12<sup>3</sup> = 9<sup>3</sup> + 10<sup>3</sup>",
2015-04-06 07:07:54 -07:00
),
#without apostrophe
2016-05-14 12:21:54 -07:00
"Avogadros number" => build_test(
'6.0221415 × 10^23 mol^-1',
2016-05-14 12:21:54 -07:00
'Avogadro\'s Number',
'6.0221415 × 10<sup>23</sup> mol<sup>-1</sup>',
),
#with apostrophe
2016-05-14 12:21:54 -07:00
"Avogadro's number" => build_test(
'6.0221415 × 10^23 mol^-1',
2016-05-14 12:21:54 -07:00
'Avogadro\'s Number',
'6.0221415 × 10<sup>23</sup> mol<sup>-1</sup>',
),
#constant without html (only plain)
2016-05-14 12:21:54 -07:00
"Eulers constant" => build_test(
'0.577215665',
"Euler's Constant",
'0.577215665',
),
2015-04-06 07:07:54 -07:00
"How old is my grandma?" => undef,
"why?" => undef,
2015-04-06 07:07:54 -07:00
);
2016-05-16 06:18:04 -07:00
done_testing;