2015-04-06 07:07:54 -07:00
|
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
use warnings;
|
2015-10-20 02:17:24 -07:00
|
|
|
|
use utf8;
|
2015-04-06 07:07:54 -07:00
|
|
|
|
use Test::More;
|
2016-05-16 06:07:57 -07:00
|
|
|
|
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 => {
|
2016-05-14 12:30:39 -07:00
|
|
|
|
constant => $title,
|
2016-05-30 13:35:19 -07:00
|
|
|
|
subtitle => $subtitle,
|
2016-05-14 12:21:54 -07:00
|
|
|
|
},
|
|
|
|
|
templates => {
|
|
|
|
|
group => 'text',
|
2016-05-14 12:30:39 -07:00
|
|
|
|
options => {
|
2016-05-30 13:35:19 -07:00
|
|
|
|
title_content => 'DDH.constants.title_content'
|
2016-05-14 12:30:39 -07:00
|
|
|
|
}
|
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(
|
2016-05-14 12:26:09 -07:00
|
|
|
|
'1^3 + 12^3 = 9^3 + 10^3',
|
2016-05-14 12:21:54 -07:00
|
|
|
|
'Hardy Ramanujan Number 1729',
|
2016-05-30 13:35:19 -07:00
|
|
|
|
"1<sup>3</sup> + 12<sup>3</sup> = 9<sup>3</sup> + 10<sup>3</sup>",
|
2015-04-06 07:07:54 -07:00
|
|
|
|
),
|
2015-10-20 02:17:24 -07:00
|
|
|
|
#without apostrophe
|
2016-05-14 12:21:54 -07:00
|
|
|
|
"Avogadros number" => build_test(
|
2016-05-14 12:26:09 -07:00
|
|
|
|
'6.0221415 × 10^23 mol^-1',
|
2016-05-14 12:21:54 -07:00
|
|
|
|
'Avogadro\'s Number',
|
2015-10-20 02:17:24 -07:00
|
|
|
|
'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(
|
2016-05-14 12:26:09 -07:00
|
|
|
|
'6.0221415 × 10^23 mol^-1',
|
2016-05-14 12:21:54 -07:00
|
|
|
|
'Avogadro\'s Number',
|
2015-10-20 02:17:24 -07:00
|
|
|
|
'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",
|
2015-10-20 02:17:24 -07:00
|
|
|
|
'0.577215665',
|
|
|
|
|
),
|
2015-04-06 07:07:54 -07:00
|
|
|
|
"How old is my grandma?" => undef,
|
2016-05-30 13:35:19 -07:00
|
|
|
|
"why?" => undef,
|
2015-04-06 07:07:54 -07:00
|
|
|
|
);
|
|
|
|
|
|
2016-05-16 06:18:04 -07:00
|
|
|
|
done_testing;
|