commit
dd382be163
|
@ -11,9 +11,9 @@ triggers startend => "pi","π";
|
|||
|
||||
|
||||
my $PI = '3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679'.
|
||||
'8214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196'.
|
||||
'4428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273'.
|
||||
'724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609';
|
||||
'8214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196'.
|
||||
'4428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273'.
|
||||
'724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609';
|
||||
|
||||
my $PI_max_digits = length($PI);
|
||||
|
||||
|
@ -23,11 +23,14 @@ handle query_raw => sub {
|
|||
$+{decimal} > 0 && $+{decimal} < $PI_max_digits;
|
||||
|
||||
my $answer = substr $PI, 0, ( $1 + 2 );
|
||||
return $answer,
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => ["First ".$+{decimal}." digits of Pi"],
|
||||
result => $answer
|
||||
return $answer, structured_answer => {
|
||||
data => {
|
||||
title => $answer,
|
||||
subtitle => "First $+{decimal} digits of Pi"
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -10,49 +10,31 @@ use utf8;
|
|||
zci answer_type => "pi";
|
||||
zci is_cached => 1;
|
||||
|
||||
sub build_test {
|
||||
my ($answer, $input) = @_;
|
||||
return test_zci($answer, structured_answer => {
|
||||
data => {
|
||||
title => $answer,
|
||||
subtitle=> "First $input digits of Pi"
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw( DDG::Goodie::Pi )],
|
||||
|
||||
'pi 23' => test_zci("3.14159265358979323846264",
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => ["First 23 digits of Pi"],
|
||||
result => "3.14159265358979323846264"
|
||||
}),
|
||||
'π 8' => test_zci("3.14159265",
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => ["First 8 digits of Pi"],
|
||||
result => "3.14159265"
|
||||
}),
|
||||
'12 digits of pi' => test_zci("3.141592653589",
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => ["First 12 digits of Pi"],
|
||||
result => "3.141592653589"
|
||||
}),
|
||||
'12 digits of π' => test_zci("3.141592653589",
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => ["First 12 digits of Pi"],
|
||||
result => "3.141592653589"
|
||||
}),
|
||||
'pi to 6 digits' => test_zci("3.141592",
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => ["First 6 digits of Pi"],
|
||||
result => "3.141592"
|
||||
}),
|
||||
'π to 6 digits' => test_zci("3.141592",
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => ["First 6 digits of Pi"],
|
||||
result => "3.141592"
|
||||
}),
|
||||
|
||||
'pi ff' => undef,
|
||||
'pi 3f2' => undef
|
||||
'pi 23' => build_test("3.14159265358979323846264",23),
|
||||
'π 8' => build_test("3.14159265", 8),
|
||||
'12 digits of pi' => build_test("3.141592653589", 12),
|
||||
'12 digits of π' => build_test("3.141592653589", 12),
|
||||
'pi to 6 digits' => build_test("3.141592", 6),
|
||||
'π to 6 digits' => build_test("3.141592", 6),
|
||||
|
||||
'pi ff' => undef,
|
||||
'pi 3f2' => undef
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
|
Loading…
Reference in New Issue