Skip to content

fix: handle division by zero in calculator#147

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

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

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Added a guard in src/calculator.ts divide function that throws an error when the divisor is zero, preventing division-by-zero bugs
  • Added tests for the divide function: a happy-path test and a division-by-zero error test

Assumptions

  • Throwing an Error("Division by zero is not allowed") is the appropriate behavior (rather than returning Infinity or NaN)
  • All existing tests continue to pass (verified: 5 tests, 0 failures)

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