Skip to content

fix: handle division by zero in calculator#150

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

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

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Added a guard clause in src/calculator.ts divide function that throws an Error("Division by zero is not allowed") when the divisor is zero
  • Added test cases in test/calculator.test.ts for both normal division and division-by-zero error handling

Assumptions

  • Throwing an error is the appropriate behavior for division by zero (rather than returning Infinity, NaN, or a custom result type)
  • The error message "Division by zero is not allowed" is descriptive enough for consumers

Testing

All 5 tests pass (including the 2 new division-related tests).

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