2015-01-09 09:32:40 -08:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
2016-05-16 06:07:57 -07:00
|
|
|
use Test::Deep;
|
2015-01-09 09:32:40 -08:00
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => "percent_of";
|
|
|
|
zci is_cached => 1;
|
|
|
|
|
|
|
|
ddg_goodie_test(
|
|
|
|
[qw( DDG::Goodie::PercentOf )],
|
|
|
|
|
|
|
|
'4+50%' => test_zci('Result: 6',
|
|
|
|
structured_answer => {
|
2015-04-24 02:17:01 -07:00
|
|
|
input => ['4+50%'],
|
2015-01-09 09:32:40 -08:00
|
|
|
operation => "Calculate",
|
|
|
|
result => 6
|
|
|
|
}),
|
2015-04-24 04:04:23 -07:00
|
|
|
|
2015-01-09 09:32:40 -08:00
|
|
|
'456+120%' => test_zci('Result: 1003.2',
|
|
|
|
structured_answer => {
|
2015-04-24 02:17:01 -07:00
|
|
|
input => ['456+120%'],
|
2015-01-09 09:32:40 -08:00
|
|
|
operation => "Calculate",
|
|
|
|
result => 1003.2
|
|
|
|
}),
|
2015-04-24 04:04:23 -07:00
|
|
|
|
2015-01-14 11:28:02 -08:00
|
|
|
'3.4+6%' => test_zci('Result: 3.604',
|
|
|
|
structured_answer => {
|
2015-04-24 02:17:01 -07:00
|
|
|
input => ['3.4+6%'],
|
2015-01-14 11:28:02 -08:00
|
|
|
operation => "Calculate",
|
|
|
|
result => 3.604
|
|
|
|
}),
|
2015-04-24 04:04:23 -07:00
|
|
|
|
2015-04-24 05:59:06 -07:00
|
|
|
'323.7+ 55.3%' => test_zci('Result: 502.7061',
|
2015-01-14 11:28:02 -08:00
|
|
|
structured_answer => {
|
2015-04-24 02:17:01 -07:00
|
|
|
input => ['323.7+55.3%'],
|
2015-01-14 11:28:02 -08:00
|
|
|
operation => "Calculate",
|
|
|
|
result => 502.7061
|
|
|
|
}),
|
2015-04-24 04:04:23 -07:00
|
|
|
|
2015-04-24 01:57:46 -07:00
|
|
|
'577.40*5%' => test_zci('Result: 28.87',
|
|
|
|
structured_answer => {
|
2015-04-24 02:17:01 -07:00
|
|
|
input => ['577.40*5%'],
|
2015-04-24 01:57:46 -07:00
|
|
|
operation => "Calculate",
|
|
|
|
result => 28.87
|
|
|
|
}),
|
2015-04-24 04:04:23 -07:00
|
|
|
|
2015-04-24 05:59:06 -07:00
|
|
|
'$577.40 *0.5%' => test_zci('Result: 2.887',
|
2015-04-24 02:17:01 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['$577.40*0.5%'],
|
|
|
|
operation => "Calculate",
|
|
|
|
result => 2.887
|
|
|
|
}),
|
2015-04-24 04:04:23 -07:00
|
|
|
|
2015-04-24 05:59:06 -07:00
|
|
|
'200 - 50%' => test_zci('Result: 100',
|
2015-04-24 02:17:01 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['200-50%'],
|
|
|
|
operation => "Calculate",
|
|
|
|
result => 100
|
|
|
|
}),
|
2015-04-24 06:15:08 -07:00
|
|
|
'234 / 25%' => test_zci('Result: 936',
|
2015-04-24 05:59:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['234/25%'],
|
|
|
|
operation => "Calculate",
|
2015-04-24 06:15:08 -07:00
|
|
|
result => 936
|
2015-04-24 05:59:06 -07:00
|
|
|
}),
|
2015-01-09 09:32:40 -08:00
|
|
|
|
2015-04-24 04:04:23 -07:00
|
|
|
'200+50-10%' => undef,
|
2015-01-09 09:32:40 -08:00
|
|
|
'urldecode hello%20there' => undef,
|
|
|
|
'34$+16' => undef,
|
|
|
|
'12+5t%' => undef
|
|
|
|
);
|
|
|
|
|
2016-05-16 06:07:57 -07:00
|
|
|
done_testing;
|