You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above code the line:
passed = (assessment[:passed] == assessment[:count]) and (assessment[:score]).positive?
passed will always have the value returned from (assessment[:passed] == assessment[:count]) the evaluation of the second condition will not impact the value of passed variable. Although it works in all the cases but might be wrong for the case when the test files have their own error and are not executed properly. In that case assessment[:passed] = 0 and assessment[:count] = 0 therefore the condition assessment[:passed] == assessment[:count] is true whereas assessment[:score].positive? is 0.0 hence false. But passed will be set to true because the condition assessment[:passed] == assessment[:count] is true as precedence of "=" is more than "and" operator so the possible fixes could be
passed = ((assessment[:passed] == assessment[:count]) and (assessment[:score]).positive?)
In all other situations I dont think there can be a case where assessment[:passed] == assessment[:count] is false and assessment[:score]).positive? is true. I only found this bug when my test cases had syntax errors and where not executed.
Best Regards,
Seemant Singh
The text was updated successfully, but these errors were encountered:
Hello,
In the above code the line:
passed = (assessment[:passed] == assessment[:count]) and (assessment[:score]).positive?
passed will always have the value returned from (assessment[:passed] == assessment[:count]) the evaluation of the second condition will not impact the value of passed variable. Although it works in all the cases but might be wrong for the case when the test files have their own error and are not executed properly. In that case assessment[:passed] = 0 and assessment[:count] = 0 therefore the condition assessment[:passed] == assessment[:count] is true whereas assessment[:score].positive? is 0.0 hence false. But passed will be set to true because the condition assessment[:passed] == assessment[:count] is true as precedence of "=" is more than "and" operator so the possible fixes could be
or
In all other situations I dont think there can be a case where assessment[:passed] == assessment[:count] is false and assessment[:score]).positive? is true. I only found this bug when my test cases had syntax errors and where not executed.
Best Regards,
Seemant Singh
The text was updated successfully, but these errors were encountered: