diff --git a/lib/DDG/Goodie/Calculator.pm b/lib/DDG/Goodie/Calculator.pm
index e64af703db7..b82fd8f8153 100644
--- a/lib/DDG/Goodie/Calculator.pm
+++ b/lib/DDG/Goodie/Calculator.pm
@@ -149,10 +149,10 @@ handle query_nowhitespace => sub {
my $results = prepare_for_display($query, $tmp_result, $style);
+ return unless $results && $results->{text};
return if $results->{text} =~ /^\s/;
return $results->{text},
- structured_answer => $results->{structured},
- heading => "Calculator";
+ structured_answer => $results->{structured};
};
sub prepare_for_display {
@@ -174,12 +174,19 @@ sub prepare_for_display {
$spaced_query =~ s/^ - /-/;
return +{
- text => $spaced_query . ' = ' . $result,
+ text => "$spaced_query = $result",
structured => {
- input => [$spaced_query],
- operation => 'Calculate',
- result => "" . $style->with_html($result) . ""
- },
+ data => {
+ title_html => $style->with_html($result),
+ subtitle => "Calculate: $spaced_query"
+ },
+ templates => {
+ group => 'text',
+ options => {
+ title_content => 'DDH.calculator.title_content'
+ }
+ }
+ }
};
}
diff --git a/share/goodie/calculator/title_content.handlebars b/share/goodie/calculator/title_content.handlebars
new file mode 100644
index 00000000000..0557d565c14
--- /dev/null
+++ b/share/goodie/calculator/title_content.handlebars
@@ -0,0 +1 @@
+
{{{title_html}}}
\ No newline at end of file
diff --git a/t/Calculator.t b/t/Calculator.t
index 771090d5770..a89ad5425f8 100644
--- a/t/Calculator.t
+++ b/t/Calculator.t
@@ -11,853 +11,494 @@ use utf8;
zci answer_type => 'calc';
zci is_cached => 1;
+sub build_test
+{
+ my ($text_result, $input, $html_result) = @_;
+ return test_zci($text_result, structured_answer => {
+ data => {
+ title_html => $html_result,
+ subtitle => "Calculate: $input"
+ },
+ templates => {
+ group => 'text',
+ options => {
+ title_content => 'DDH.calculator.title_content'
+ }
+ }
+ });
+}
+
ddg_goodie_test(
[qw( DDG::Goodie::Calculator )],
- 'what is 2-2' => test_zci(
+ 'what is 2-2' => build_test(
"2 - 2 = 0",
- heading => 'Calculator',
- structured_answer => {
- input => ['2 - 2'],
- operation => 'Calculate',
- result => re(qr/>0)
- }
+ '2 - 2',
+ '0'
),
- 'solve 2+2' => test_zci(
+ 'solve 2+2' => build_test(
"2 + 2 = 4",
- heading => 'Calculator',
- structured_answer => {
- input => ['2 + 2'],
- operation => 'Calculate',
- result => re(qr/>4)
- }
+ '2 + 2',
+ '4'
),
- '2^8' => test_zci(
+ '2^8' => build_test(
"2 ^ 8 = 256",
- heading => 'Calculator',
- structured_answer => {
- input => ['2 ^ 8'],
- operation => 'Calculate',
- result => re(qr/>256)
- }
+ '2 ^ 8',
+ '256'
),
- '2 *7' => test_zci(
+ '2 *7' => build_test(
"2 * 7 = 14",
- heading => 'Calculator',
- structured_answer => {
- input => ['2 * 7'],
- operation => 'Calculate',
- result => re(qr/>14)
- }
+ '2 * 7',
+ '14'
),
- '4 ∙ 5' => test_zci(
+ '4 ∙ 5' => build_test(
"4 * 5 = 20",
- heading => 'Calculator',
- structured_answer => {
- input => ['4 * 5'],
- operation => 'Calculate',
- result => re(qr/>20)
- }
+ '4 * 5',
+ '20'
),
- '6 ⋅ 7' => test_zci(
+ '6 ⋅ 7' => build_test(
"6 * 7 = 42",
- heading => 'Calculator',
- structured_answer => {
- input => ['6 * 7'],
- operation => 'Calculate',
- result => re(qr/>42)
- }
+ '6 * 7',
+ '42'
),
- '3 × dozen' => test_zci(
+ '3 × dozen' => build_test(
"3 * dozen = 36",
- heading => 'Calculator',
- structured_answer => {
- input => ['3 * dozen'],
- operation => 'Calculate',
- result => re(qr/>36)
- }
+ '3 * dozen',
+ '36'
),
- 'dozen ÷ 4' => test_zci(
+ 'dozen ÷ 4' => build_test(
"dozen / 4 = 3",
- heading => 'Calculator',
- structured_answer => {
- input => ['dozen / 4'],
- operation => 'Calculate',
- result => re(qr/>3)
- }
+ 'dozen / 4',
+ '3'
),
- '1 dozen * 2' => test_zci(
+ '1 dozen * 2' => build_test(
"1 dozen * 2 = 24",
- heading => 'Calculator',
- structured_answer => {
- input => ['1 dozen * 2'],
- operation => 'Calculate',
- result => re(qr/>24)
- }
+ '1 dozen * 2',
+ '24'
),
- 'dozen + dozen' => test_zci(
+ 'dozen + dozen' => build_test(
"dozen + dozen = 24",
- heading => 'Calculator',
- structured_answer => {
- input => ['dozen + dozen'],
- operation => 'Calculate',
- result => re(qr/>24)
- }
+ 'dozen + dozen',
+ '24'
),
- '2divided by 4' => test_zci(
+ '2divided by 4' => build_test(
"2 divided by 4 = 0.5",
- heading => 'Calculator',
- structured_answer => {
- input => ['2 divided by 4'],
- operation => 'Calculate',
- result => re(qr/>0.5)
- }
+ '2 divided by 4',
+ '0.5'
),
- '2^2' => test_zci(
+ '2^2' => build_test(
"2 ^ 2 = 4",
- heading => 'Calculator',
- structured_answer => {
- input => ['2 ^ 2'],
- operation => 'Calculate',
- result => re(qr/>4)
- }
+ '2 ^ 2',
+ '4'
),
- '2^0.2' => test_zci(
+ '2^0.2' => build_test(
"2 ^ 0.2 = 1.14869835499704",
- heading => 'Calculator',
- structured_answer => {
- input => ['2 ^ 0.2'],
- operation => 'Calculate',
- result => re(qr/>1\.14869835499704)
- }
+ '2 ^ 0.2',
+ '1.14869835499704'
),
- 'cos(0)' => test_zci(
+ 'cos(0)' => build_test(
"cos(0) = 1",
- heading => 'Calculator',
- structured_answer => {
- input => ['cos(0)'],
- operation => 'Calculate',
- result => re(qr/>1)
- }
+ 'cos(0)',
+ '1'
),
- 'tan(1)' => test_zci(
+ 'tan(1)' => build_test(
"tan(1) = 1.5574077246549",
- heading => 'Calculator',
- structured_answer => {
- input => ['tan(1)'],
- operation => 'Calculate',
- result => re(qr/>1\.5574077246549)
- }
+ 'tan(1)',
+ '1.5574077246549'
),
- 'tanh(1)' => test_zci(
+ 'tanh(1)' => build_test(
"tanh(1) = 0.761594155955765",
- heading => 'Calculator',
- structured_answer => {
- input => ['tanh(1)'],
- operation => 'Calculate',
- result => re(qr/>0\.761594155955765)
- }
+ 'tanh(1)',
+ '0.761594155955765'
),
- 'cotan(1)' => test_zci(
+ 'cotan(1)' => build_test(
"cotan(1) = 0.642092615934331",
- heading => 'Calculator',
- structured_answer => {
- input => ['cotan(1)'],
- operation => 'Calculate',
- result => re(qr/>0\.642092615934331)
- }
+ 'cotan(1)',
+ '0.642092615934331'
),
- 'sin(1)' => test_zci(
+ 'sin(1)' => build_test(
"sin(1) = 0.841470984807897",
- heading => 'Calculator',
- structured_answer => {
- input => ['sin(1)'],
- operation => 'Calculate',
- result => re(qr/>0\.841470984807897)
- }
+ 'sin(1)',
+ '0.841470984807897'
),
- 'csc(1)' => test_zci(
+ 'csc(1)' => build_test(
"csc(1) = 1.18839510577812",
- heading => 'Calculator',
- structured_answer => {
- input => ['csc(1)'],
- operation => 'Calculate',
- result => re(qr/>1\.18839510577812)
- }
+ 'csc(1)',
+ '1.18839510577812'
),
- 'sec(1)' => test_zci(
+ 'sec(1)' => build_test(
"sec(1) = 1.85081571768093",
- heading => 'Calculator',
- structured_answer => {
- input => ['sec(1)'],
- operation => 'Calculate',
- result => re(qr/>1\.85081571768093)
- }
+ 'sec(1)',
+ '1.85081571768093'
),
- 'log(3)' => test_zci(
+ 'log(3)' => build_test(
"log(3) = 1.09861228866811",
- heading => 'Calculator',
- structured_answer => {
- input => ['log(3)'],
- operation => 'Calculate',
- result => re(qr/>1\.09861228866811)
- }
+ 'log(3)',
+ '1.09861228866811'
),
- 'ln(3)' => test_zci(
+ 'ln(3)' => build_test(
"log(3) = 1.09861228866811",
- heading => 'Calculator',
- structured_answer => {
- input => ['log(3)'],
- operation => 'Calculate',
- result => re(qr/>1\.09861228866811)
- }
+ 'log(3)',
+ '1.09861228866811'
),
- 'log10(100.00)' => test_zci(
+ 'log10(100.00)' => build_test(
"log10(100.00) = 2",
- heading => 'Calculator',
- structured_answer => {
- input => ['log10(100.00)'],
- operation => 'Calculate',
- result => re(qr/>2)
- }
+ 'log10(100.00)',
+ '2'
),
- 'log_10(100.00)' => test_zci(
+ 'log_10(100.00)' => build_test(
"log_10(100.00) = 2",
- heading => 'Calculator',
- structured_answer => {
- input => ['log_10(100.00)'],
- operation => 'Calculate',
- result => re(qr/>2)
- }
+ 'log_10(100.00)',
+ '2'
),
- 'log_2(16)' => test_zci(
+ 'log_2(16)' => build_test(
"log_2(16) = 4",
- heading => 'Calculator',
- structured_answer => {
- input => ['log_2(16)'],
- operation => 'Calculate',
- result => re(qr/>4)
- }
+ 'log_2(16)',
+ '4'
),
- 'log_23(25)' => test_zci(
+ 'log_23(25)' => build_test(
"log_23(25) = 1.0265928122321",
- heading => 'Calculator',
- structured_answer => {
- input => ['log_23(25)'],
- operation => 'Calculate',
- result => re(qr/>1\.0265928122321)
- }
+ 'log_23(25)',
+ '1.0265928122321'
),
- 'log23(25)' => test_zci(
+ 'log23(25)' => build_test(
"log23(25) = 1.0265928122321",
- heading => 'Calculator',
- structured_answer => {
- input => ['log23(25)'],
- operation => 'Calculate',
- result => re(qr/>1\.0265928122321)
- }
+ 'log23(25)',
+ '1.0265928122321'
),
- '$3.43+$34.45' => test_zci(
+ '$3.43+$34.45' => build_test(
'$3.43 + $34.45 = $37.88',
- heading => 'Calculator',
- structured_answer => {
- input => ['$3.43 + $34.45'],
- operation => 'Calculate',
- result => re(qr/>\$37\.88)
- }
+ '$3.43 + $34.45',
+ '$37.88'
),
- '$3.45+$34.45' => test_zci(
+ '$3.45+$34.45' => build_test(
'$3.45 + $34.45 = $37.90',
- heading => 'Calculator',
- structured_answer => {
- input => ['$3.45 + $34.45'],
- operation => 'Calculate',
- result => re(qr/>\$37\.90)
- }
+ '$3.45 + $34.45',
+ '$37.90'
),
- '$3+$34' => test_zci(
+ '$3+$34' => build_test(
'$3 + $34 = $37.00',
- heading => 'Calculator',
- structured_answer => {
- input => ['$3 + $34'],
- operation => 'Calculate',
- result => re(qr/>\$37\.00)
- }
+ '$3 + $34',
+ '$37.00'
),
- '$3,4+$34,4' => test_zci(
+ '$3,4+$34,4' => build_test(
'$3,4 + $34,4 = $37,80',
- heading => 'Calculator',
- structured_answer => {
- input => ['$3,4 + $34,4'],
- operation => 'Calculate',
- result => re(qr/>\$37,80)
- }
+ '$3,4 + $34,4',
+ '$37,80'
),
- '64*343' => test_zci(
+ '64*343' => build_test(
'64 * 343 = 21,952',
- heading => 'Calculator',
- structured_answer => {
- input => ['64 * 343'],
- operation => 'Calculate',
- result => re(qr/>21,952)
- }
+ '64 * 343',
+ '21,952'
),
- '1E2 + 1' => test_zci(
+ '1E2 + 1' => build_test(
'(1 * 10 ^ 2) + 1 = 101',
- heading => 'Calculator',
- structured_answer => {
- input => ['(1 * 10 ^ 2) + 1'],
- operation => 'Calculate',
- result => re(qr/>101)
- }
+ '(1 * 10 ^ 2) + 1',
+ '101'
),
- '1 + 1E2' => test_zci(
+ '1 + 1E2' => build_test(
'1 + (1 * 10 ^ 2) = 101',
- heading => 'Calculator',
- structured_answer => {
- input => ['1 + (1 * 10 ^ 2)'],
- operation => 'Calculate',
- result => re(qr/>101)
- }
+ '1 + (1 * 10 ^ 2)',
+ '101'
),
- '2 * 3 + 1E2' => test_zci(
+ '2 * 3 + 1E2' => build_test(
'2 * 3 + (1 * 10 ^ 2) = 106',
- heading => 'Calculator',
- structured_answer => {
- input => ['2 * 3 + (1 * 10 ^ 2)'],
- operation => 'Calculate',
- result => re(qr/>106)
- }
+ '2 * 3 + (1 * 10 ^ 2)',
+ '106'
),
- '1E2 + 2 * 3' => test_zci(
+ '1E2 + 2 * 3' => build_test(
'(1 * 10 ^ 2) + 2 * 3 = 106',
- heading => 'Calculator',
- structured_answer => {
- input => ['(1 * 10 ^ 2) + 2 * 3'],
- operation => 'Calculate',
- result => re(qr/>106)
- }
+ '(1 * 10 ^ 2) + 2 * 3',
+ '106'
),
- '1E2 / 2' => test_zci(
+ '1E2 / 2' => build_test(
'(1 * 10 ^ 2) / 2 = 50',
- heading => 'Calculator',
- structured_answer => {
- input => ['(1 * 10 ^ 2) / 2'],
- operation => 'Calculate',
- result => re(qr/>50)
- }
+ '(1 * 10 ^ 2) / 2',
+ '50'
),
- '2 / 1E2' => test_zci(
+ '2 / 1E2' => build_test(
'2 / (1 * 10 ^ 2) = 0.02',
- heading => 'Calculator',
- structured_answer => {
- input => ['2 / (1 * 10 ^ 2)'],
- operation => 'Calculate',
- result => re(qr/>0\.02)
- }
+ '2 / (1 * 10 ^ 2)',
+ '0.02'
),
- '424334+2253828' => test_zci(
+ '424334+2253828' => build_test(
'424334 + 2253828 = 2,678,162',
- heading => 'Calculator',
- structured_answer => {
- input => ['424334 + 2253828'],
- operation => 'Calculate',
- result => re(qr/>2,678,162)
- }
+ '424334 + 2253828',
+ '2,678,162'
),
- '4.243,34+22.538,28' => test_zci(
+ '4.243,34+22.538,28' => build_test(
'4.243,34 + 22.538,28 = 26.781,62',
- heading => 'Calculator',
- structured_answer => {
- input => ['4.243,34 + 22.538,28'],
- operation => 'Calculate',
- result => re(qr/>26\.781,62)
- }
+ '4.243,34 + 22.538,28',
+ '26.781,62'
),
- 'sin(1,0) + 1,05' => test_zci(
+ 'sin(1,0) + 1,05' => build_test(
'sin(1,0) + 1,05 = 1,8914709848079',
- heading => 'Calculator',
- structured_answer => {
- input => ['sin(1,0) + 1,05'],
- operation => 'Calculate',
- result => re(qr/>1,8914709848079)
- }
+ 'sin(1,0) + 1,05',
+ '1,8914709848079'
),
- '21 + 15 x 0 + 5' => test_zci(
+ '21 + 15 x 0 + 5' => build_test(
'21 + 15 * 0 + 5 = 26',
- heading => 'Calculator',
- structured_answer => {
- input => ['21 + 15 * 0 + 5'],
- operation => 'Calculate',
- result => re(qr/>26)
- }
+ '21 + 15 * 0 + 5',
+ '26'
),
- '0.8158 - 0.8157' => test_zci(
+ '0.8158 - 0.8157' => build_test(
'0.8158 - 0.8157 = 0.0001',
- heading => 'Calculator',
- structured_answer => {
- input => ['0.8158 - 0.8157'],
- operation => 'Calculate',
- result => re(qr/>0\.0001)
- }
+ '0.8158 - 0.8157',
+ '0.0001'
),
- '2,90 + 4,6' => test_zci(
+ '2,90 + 4,6' => build_test(
'2,90 + 4,6 = 7,50',
- heading => 'Calculator',
- structured_answer => {
- input => ['2,90 + 4,6'],
- operation => 'Calculate',
- result => re(qr/>7,50)
- }
+ '2,90 + 4,6',
+ '7,50'
),
- '2,90 + sec(4,6)' => test_zci(
+ '2,90 + sec(4,6)' => build_test(
'2,90 + sec(4,6) = -6,01642861135959',
- heading => 'Calculator',
- structured_answer => {
- input => ['2,90 + sec(4,6)'],
- operation => 'Calculate',
- result => re(qr/>-6,01642861135959)
- }
+ '2,90 + sec(4,6)',
+ '-6,01642861135959'
),
- '100 - 96.54' => test_zci(
+ '100 - 96.54' => build_test(
'100 - 96.54 = 3.46',
- heading => 'Calculator',
- structured_answer => {
- input => ['100 - 96.54'],
- operation => 'Calculate',
- result => re(qr/>3\.46)
- }
+ '100 - 96.54',
+ '3.46'
),
- '1. + 1.' => test_zci(
+ '1. + 1.' => build_test(
'1. + 1. = 2',
- heading => 'Calculator',
- structured_answer => {
- input => ['1. + 1.'],
- operation => 'Calculate',
- result => re(qr/>2)
- }
+ '1. + 1.',
+ '2'
),
- '1 + sin(pi)' => test_zci(
+ '1 + sin(pi)' => build_test(
'1 + sin(pi) = 1',
- heading => 'Calculator',
- structured_answer => {
- input => ['1 + sin(pi)'],
- operation => 'Calculate',
- result => re(qr/>1)
- }
+ '1 + sin(pi)',
+ '1'
),
- '1 - 1' => test_zci(
+ '1 - 1' => build_test(
'1 - 1 = 0',
- heading => 'Calculator',
- structured_answer => {
- input => ['1 - 1'],
- operation => 'Calculate',
- result => re(qr/>0)
- }
+ '1 - 1',
+ '0'
),
- 'sin(pi/2)' => test_zci(
+ 'sin(pi/2)' => build_test(
'sin(pi / 2) = 1',
- heading => 'Calculator',
- structured_answer => {
- input => ['sin(pi / 2)'],
- operation => 'Calculate',
- result => re(qr/>1)
- }
+ 'sin(pi / 2)',
+ '1'
),
- 'sin(pi)' => test_zci(
+ 'sin(pi)' => build_test(
'sin(pi) = 0',
- heading => 'Calculator',
- structured_answer => {
- input => ['sin(pi)'],
- operation => 'Calculate',
- result => re(qr/>0)
- }
+ 'sin(pi)',
+ '0'
),
- 'cos(2pi)' => test_zci(
+ 'cos(2pi)' => build_test(
'cos(2 pi) = 1',
- heading => 'Calculator',
- structured_answer => {
- input => ['cos(2 pi)'],
- operation => 'Calculate',
- result => re(qr/>1)
- }
+ 'cos(2 pi)',
+ '1'
),
- '5 squared' => test_zci(
+ '5 squared' => build_test(
'5 ^ 2 = 25',
- heading => 'Calculator',
- structured_answer => {
- input => ['5 ^ 2'],
- operation => 'Calculate',
- result => re(qr/>25)
- }
+ '5 ^ 2',
+ '25'
),
- 'sqrt(4)' => test_zci(
+ 'sqrt(4)' => build_test(
'sqrt(4) = 2',
- heading => 'Calculator',
- structured_answer => {
- input => ['sqrt(4)'],
- operation => 'Calculate',
- result => re(qr/>2)
- }
+ 'sqrt(4)',
+ '2'
),
- '1.0 + 5 squared' => test_zci(
+ '1.0 + 5 squared' => build_test(
'1.0 + 5 ^ 2 = 26',
- heading => 'Calculator',
- structured_answer => {
- input => ['1.0 + 5 ^ 2'],
- operation => 'Calculate',
- result => re(qr/>26)
- }
+ '1.0 + 5 ^ 2',
+ '26'
),
- '3 squared + 4 squared' => test_zci(
+ '3 squared + 4 squared' => build_test(
'3 ^ 2 + 4 ^ 2 = 25',
- heading => 'Calculator',
- structured_answer => {
- input => ['3 ^ 2 + 4 ^ 2'],
- operation => 'Calculate',
- result => re(qr/>25)
- }
+ '3 ^ 2 + 4 ^ 2',
+ '25'
),
- '2,2 squared' => test_zci(
+ '2,2 squared' => build_test(
'2,2 ^ 2 = 4,84',
- heading => 'Calculator',
- structured_answer => {
- input => ['2,2 ^ 2'],
- operation => 'Calculate',
- result => re(qr/>4,84)
- }
+ '2,2 ^ 2',
+ '4,84'
),
- '0.8^2 + 0.6^2' => test_zci(
+ '0.8^2 + 0.6^2' => build_test(
'0.8 ^ 2 + 0.6 ^ 2 = 1',
- heading => 'Calculator',
- structured_answer => {
- input => ['0.8 ^ 2 + 0.6 ^ 2'],
- operation => 'Calculate',
- result => re(qr/>1),
- }
+ '0.8 ^ 2 + 0.6 ^ 2',
+ '1'
),
- '2 squared ^ 3' => test_zci(
+ '2 squared ^ 3' => build_test(
'2 ^ 2 ^ 3 = 256',
- heading => 'Calculator',
- structured_answer => {
- input => ['2 ^ 2 ^ 3'],
- operation => 'Calculate',
- result => re(qr/>256)
- }
+ '2 ^ 2 ^ 3',
+ '256'
),
- '2 squared ^ 3.06' => test_zci(
+ '2 squared ^ 3.06' => build_test(
'2 ^ 2 ^ 3.06 = 323.972172143725',
- heading => 'Calculator',
- structured_answer => {
- input => ['2 ^ 2 ^ 3.06'],
- operation => 'Calculate',
- result => re(qr/>323\.972172143725)
- }
+ '2 ^ 2 ^ 3.06',
+ '323.972172143725'
),
- '2^3 squared' => test_zci(
+ '2^3 squared' => build_test(
'2 ^ 3 ^ 2 = 512',
- heading => 'Calculator',
- structured_answer => {
- input => ['2 ^ 3 ^ 2'],
- operation => 'Calculate',
- result => re(qr/>512)
- }
+ '2 ^ 3 ^ 2',
+ '512'
),
- 'sqrt(2)' => test_zci(
+ 'sqrt(2)' => build_test(
'sqrt(2) = 1.4142135623731',
- heading => 'Calculator',
- structured_answer => {
- input => ['sqrt(2)'],
- operation => 'Calculate',
- result => re(qr/>1\.4142135623731)
- }
+ 'sqrt(2)',
+ '1.4142135623731'
),
- 'sqrt(3 pi / 4 + 1) + 1' => test_zci(
+ 'sqrt(3 pi / 4 + 1) + 1' => build_test(
'sqrt(3 pi / 4 + 1) + 1 = 2.83199194599549',
- heading => 'Calculator',
- structured_answer => {
- input => ['sqrt(3 pi / 4 + 1) + 1'],
- operation => 'Calculate',
- result => re(qr/>2\.83199194599549)
- }
+ 'sqrt(3 pi / 4 + 1) + 1',
+ '2.83199194599549'
),
- '4 score + 7' => test_zci(
+ '4 score + 7' => build_test(
'4 score + 7 = 87',
- heading => 'Calculator',
- structured_answer => {
- input => ['4 score + 7'],
- operation => 'Calculate',
- result => re(qr/>87)
- }
+ '4 score + 7',
+ '87'
),
- '418.1 / 2' => test_zci(
+ '418.1 / 2' => build_test(
'418.1 / 2 = 209.05',
- heading => 'Calculator',
- structured_answer => {
- input => ['418.1 / 2'],
- operation => 'Calculate',
- result => re(qr/>209\.05)
- }
+ '418.1 / 2',
+ '209.05'
),
- '418.005 / 8' => test_zci(
+ '418.005 / 8' => build_test(
'418.005 / 8 = 52.250625',
- heading => 'Calculator',
- structured_answer => {
- input => ['418.005 / 8'],
- operation => 'Calculate',
- result => re(qr/>52\.250625)
- }
+ '418.005 / 8',
+ '52.250625'
),
- '(pi^4+pi^5)^(1/6)' => test_zci(
+ '(pi^4+pi^5)^(1/6)' => build_test(
'(pi ^ 4 + pi ^ 5) ^ (1 / 6) = 2.71828180861191',
- heading => 'Calculator',
- structured_answer => {
- input => ['(pi ^ 4 + pi ^ 5) ^ (1 / 6)'],
- operation => 'Calculate',
- result => re(qr/>2\.71828180861191)
- }
+ '(pi ^ 4 + pi ^ 5) ^ (1 / 6)',
+ '2.71828180861191'
),
- '(pi^4+pi^5)^(1/6)+1' => test_zci(
+ '(pi^4+pi^5)^(1/6)+1' => build_test(
'(pi ^ 4 + pi ^ 5) ^ (1 / 6) + 1 = 3.71828180861191',
- heading => 'Calculator',
- structured_answer => {
- input => ['(pi ^ 4 + pi ^ 5) ^ (1 / 6) + 1'],
- operation => 'Calculate',
- result => re(qr/>3\.71828180861191)
- }
+ '(pi ^ 4 + pi ^ 5) ^ (1 / 6) + 1',
+ '3.71828180861191'
),
- '5^4^(3-2)^1' => test_zci(
+ '5^4^(3-2)^1' => build_test(
'5 ^ 4 ^ (3 - 2) ^ 1 = 625',
- heading => 'Calculator',
- structured_answer => {
- input => ['5 ^ 4 ^ (3 - 2) ^ 1'],
- operation => 'Calculate',
- result => re(qr/>625)
- }
+ '5 ^ 4 ^ (3 - 2) ^ 1',
+ '625'
),
- '(5-4)^(3-2)^1' => test_zci(
+ '(5-4)^(3-2)^1' => build_test(
'(5 - 4) ^ (3 - 2) ^ 1 = 1',
- heading => 'Calculator',
- structured_answer => {
- input => ['(5 - 4) ^ (3 - 2) ^ 1'],
- operation => 'Calculate',
- result => re(qr/>1)
- }
+ '(5 - 4) ^ (3 - 2) ^ 1',
+ '1'
),
- '(5+4-3)^(2-1)' => test_zci(
+ '(5+4-3)^(2-1)' => build_test(
'(5 + 4 - 3) ^ (2 - 1) = 6',
- heading => 'Calculator',
- structured_answer => {
- input => ['(5 + 4 - 3) ^ (2 - 1)'],
- operation => 'Calculate',
- result => re(qr/>6)
- }
+ '(5 + 4 - 3) ^ (2 - 1)',
+ '6'
),
- '5^((4-3)*(2+1))+6' => test_zci(
+ '5^((4-3)*(2+1))+6' => build_test(
'5 ^ ((4 - 3) * (2 + 1)) + 6 = 131',
- heading => 'Calculator',
- structured_answer => {
- input => ['5 ^ ((4 - 3) * (2 + 1)) + 6'],
- operation => 'Calculate',
- result => re(qr/>131)
- }
+ '5 ^ ((4 - 3) * (2 + 1)) + 6',
+ '131'
),
- '20x07' => test_zci(
+ '20x07' => build_test(
'20 * 07 = 140',
- heading => 'Calculator',
- structured_answer => {
- input => ['20 * 07'],
- operation => 'Calculate',
- result => re(qr/>140)
- }
+ '20 * 07',
+ '140'
),
- '83.166.167.160/33' => test_zci(
+ '83.166.167.160/33' => build_test(
'83.166.167.160 / 33 = 2.520.186.883,63636',
- heading => 'Calculator',
- structured_answer => {
- input => ['83.166.167.160 / 33'],
- operation => 'Calculate',
- result => re(qr/>2\.520\.186\.883,63636)
- }
+ '83.166.167.160 / 33',
+ '2.520.186.883,63636'
),
- '123.123.123.123/255.255.255.256' => test_zci(
+ '123.123.123.123/255.255.255.256' => build_test(
'123.123.123.123 / 255.255.255.256 = 0,482352941174581',
- heading => 'Calculator',
- structured_answer => {
- input => ['123.123.123.123 / 255.255.255.256'],
- operation => 'Calculate',
- result => re(qr/>0,482352941174581)
- }
+ '123.123.123.123 / 255.255.255.256',
+ '0,482352941174581'
),
- '4E5 +1 ' => test_zci(
+ '4E5 +1 ' => build_test(
'(4 * 10 ^ 5) + 1 = 400,001',
- heading => 'Calculator',
- structured_answer => {
- input => ['(4 * 10 ^ 5) + 1'],
- operation => 'Calculate',
- result => re(qr/>400,001)
- }
+ '(4 * 10 ^ 5) + 1',
+ '400,001'
),
- '4e5 +1 ' => test_zci(
+ '4e5 +1 ' => build_test(
'(4 * 10 ^ 5) + 1 = 400,001',
- heading => 'Calculator',
- structured_answer => {
- input => ['(4 * 10 ^ 5) + 1'],
- operation => 'Calculate',
- result => re(qr/>400,001)
- }
+ '(4 * 10 ^ 5) + 1',
+ '400,001'
),
- '3e-2* 9 ' => test_zci(
+ '3e-2* 9 ' => build_test(
'(3 * 10 ^- 2) * 9 = 0.27',
- heading => 'Calculator',
- structured_answer => {
- input => ['(3 * 10 ^- 2) * 9'],
- operation => 'Calculate',
- result => re(qr/>0.27)
- }
+ '(3 * 10 ^- 2) * 9',
+ '0.27'
),
- '7e-4 *8' => test_zci(
+ '7e-4 *8' => build_test(
'(7 * 10 ^- 4) * 8 = 0.0056',
- heading => 'Calculator',
- structured_answer => {
- input => ['(7 * 10 ^- 4) * 8'],
- operation => 'Calculate',
- result => re(qr/>0.0056)
- }
+ '(7 * 10 ^- 4) * 8',
+ '0.0056'
),
- '6 * 2e-11' => test_zci(
+ '6 * 2e-11' => build_test(
'6 * (2 * 10 ^- 11) = 1.2 * 10^-10',
- heading => 'Calculator',
- structured_answer => {
- input => ['6 * (2 * 10 ^- 11)'],
- operation => 'Calculate',
- result => re(qr/>1\.2 \* 10-10<\/sup>)
- }
+ '6 * (2 * 10 ^- 11)',
+ '1.2 * 10-10'
),
- '7 + 7e-7' => test_zci(
+ '7 + 7e-7' => build_test(
'7 + (7 * 10 ^- 7) = 7.0000007',
- heading => 'Calculator',
- structured_answer => {
- input => ['7 + (7 * 10 ^- 7)'],
- operation => 'Calculate',
- result => re(qr/>7.0000007)
- }
+ '7 + (7 * 10 ^- 7)',
+ '7.0000007'
),
- '1 * 7 + e-7' => test_zci(
+ '1 * 7 + e-7' => build_test(
'1 * 7 + e - 7 = 2.71828182845905',
- heading => 'Calculator',
- structured_answer => {
- input => ['1 * 7 + e - 7'],
- operation => 'Calculate',
- result => re(qr/>2.71828182845905)
- }
+ '1 * 7 + e - 7',
+ '2.71828182845905'
),
- '7 * e- 5' => test_zci(
+ '7 * e- 5' => build_test(
'7 * e - 5 = 14.0279727992134',
- heading => 'Calculator',
- structured_answer => {
- input => ['7 * e - 5'],
- operation => 'Calculate',
- result => re(qr/>14.0279727992134)
- }
+ '7 * e - 5',
+ '14.0279727992134'
),
- 'pi/1e9' => test_zci(
+ 'pi/1e9' => build_test(
'pi / (1 * 10 ^ 9) = 3.14159265358979 * 10^-9',
- heading => 'Calculator',
- structured_answer => {
- input => ['pi / (1 * 10 ^ 9)'],
- operation => 'Calculate',
- result => re(qr/>3\.14159265358979 \* 10-9<\/sup>)
- }
+ 'pi / (1 * 10 ^ 9)',
+ '3.14159265358979 * 10-9'
),
- 'pi*1e9' => test_zci(
+ 'pi*1e9' => build_test(
'pi * (1 * 10 ^ 9) = 3,141,592,653.58979',
- heading => 'Calculator',
- structured_answer => {
- input => ['pi * (1 * 10 ^ 9)'],
- operation => 'Calculate',
- result => re(qr/>3,141,592,653\.58979)
- }
+ 'pi * (1 * 10 ^ 9)',
+ '3,141,592,653.58979'
),
- '1 234 + 5 432' => test_zci(
+ '1 234 + 5 432' => build_test(
'1234 + 5432 = 6,666',
- heading => 'Calculator',
- structured_answer => {
- input => ['1234 + 5432'],
- operation => 'Calculate',
- result => re(qr/6,666/)
- }
+ '1234 + 5432',
+ '6,666'
),
- '1_234 + 5_432' => test_zci(
+ '1_234 + 5_432' => build_test(
'1234 + 5432 = 6,666',
- heading => 'Calculator',
- structured_answer => {
- input => ['1234 + 5432'],
- operation => 'Calculate',
- result => re(qr/6,666/)
- }
+ '1234 + 5432',
+ '6,666'
),
- '(0.4e^(0))*cos(0)' => test_zci(
+ '(0.4e^(0))*cos(0)' => build_test(
'(0.4e ^ (0)) * cos(0) = 0.4',
- heading => 'Calculator',
- structured_answer => {
- input => ['(0.4e ^ (0)) * cos(0)'],
- operation => 'Calculate',
- result => re(qr'0.4')
- }
+ '(0.4e ^ (0)) * cos(0)',
+ '0.4'
),
- '2pi' => test_zci(
+ '2pi' => build_test(
'2 pi = 6.28318530717958',
- heading => 'Calculator',
- structured_answer => {
- input => ['2 pi'],
- operation => 'Calculate',
- result => re(qr"6.28318530717958")
- }
+ '2 pi',
+ '6.28318530717958'
),
- 'fact(3)' => test_zci(
+ 'fact(3)' => build_test(
'fact(3) = 6',
- heading => 'Calculator',
- structured_answer => {
- input => ['fact(3)'],
- operation => 'Calculate',
- result => re(qr/>6)
- }
+ 'fact(3)',
+ '6'
),
- 'factorial(3)' => test_zci(
+ 'factorial(3)' => build_test(
'fact(3) = 6',
- heading => 'Calculator',
- structured_answer => {
- input => ['fact(3)'],
- operation => 'Calculate',
- result => re(qr/>6)
- }
+ 'fact(3)',
+ '6'
),
- '-10 * 3' => test_zci(
+ '-10 * 3' => build_test(
'-10 * 3 = -30',
- heading => 'Calculator',
- structured_answer => {
- input => ['-10 * 3'],
- operation => 'Calculate',
- result => re(qr/>-30)
- }
+ '-10 * 3',
+ '-30'
),
- '-10x3' => test_zci(
+ '-10x3' => build_test(
'-10 * 3 = -30',
- heading => 'Calculator',
- structured_answer => {
- input => ['-10 * 3'],
- operation => 'Calculate',
- result => re(qr/>-30)
- }
+ '-10 * 3',
+ '-30'
),
- '1e9' => test_zci(
+ '1e9' => build_test(
'(1 * 10 ^ 9) = 1,000,000,000',
- heading => 'Calculator',
- structured_answer => {
- input => ['(1 * 10 ^ 9)'],
- operation => 'Calculate',
- result => re(qr/>1,000,000,000)
- }
+ '(1 * 10 ^ 9)',
+ '1,000,000,000'
),
'123.123.123.123/255.255.255.255' => undef,
'83.166.167.160/27' => undef,