Skip to content

fix: handle division by zero in calculator#139

Open
quantcode-agent[bot] wants to merge 1 commit intomainfrom
quantcode/job-job-46169782
Open

fix: handle division by zero in calculator#139
quantcode-agent[bot] wants to merge 1 commit intomainfrom
quantcode/job-job-46169782

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Added a guard clause in src/calculator.ts divide() that throws an error when the divisor is zero, preventing JavaScript's default Infinity result
  • Added tests in test/calculator.test.ts for normal division and division-by-zero error handling

Assumptions

  • The appropriate behavior for division by zero is to throw an Error with message "Division by zero is not allowed"
  • All existing tests continue to pass (5/5 passing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants