From 8fbea4070f4a1c5c59d8a85d514f2ceead60ad98 Mon Sep 17 00:00:00 2001 From: puskin94 Date: Fri, 24 Apr 2015 14:59:06 +0200 Subject: [PATCH] fixed division calc and updated test file with whitespaced queries --- lib/DDG/Goodie/PercentOf.pm | 2 +- t/PercentOf.t | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/DDG/Goodie/PercentOf.pm b/lib/DDG/Goodie/PercentOf.pm index 0efa5c597..0fdcaf373 100644 --- a/lib/DDG/Goodie/PercentOf.pm +++ b/lib/DDG/Goodie/PercentOf.pm @@ -31,7 +31,7 @@ handle query_nowhitespace => sub { } elsif ($2 eq '*') { $result = ( $partRes ); } elsif ($2 eq '/') { - $result = ( $1 * 100 / ( $partRes ) ); + $result = ( $1 / ( $partRes ) ); } my $text = "Result: $result"; diff --git a/t/PercentOf.t b/t/PercentOf.t index a9b937797..2185f3e68 100644 --- a/t/PercentOf.t +++ b/t/PercentOf.t @@ -32,7 +32,7 @@ ddg_goodie_test( result => 3.604 }), - '323.7+55.3%' => test_zci('Result: 502.7061', + '323.7+ 55.3%' => test_zci('Result: 502.7061', structured_answer => { input => ['323.7+55.3%'], operation => "Calculate", @@ -46,19 +46,25 @@ ddg_goodie_test( result => 28.87 }), - '$577.40*0.5%' => test_zci('Result: 2.887', + '$577.40 *0.5%' => test_zci('Result: 2.887', structured_answer => { input => ['$577.40*0.5%'], operation => "Calculate", result => 2.887 }), - '200-50%' => test_zci('Result: 100', + '200 - 50%' => test_zci('Result: 100', structured_answer => { input => ['200-50%'], operation => "Calculate", result => 100 }), + '234 / 25%' => test_zci('Result: 4', + structured_answer => { + input => ['234/25%'], + operation => "Calculate", + result => 4 + }), '200+50-10%' => undef, 'urldecode hello%20there' => undef,