Skip to content

fix: handle division by zero in calculator#133

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

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

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Fixed the division-by-zero bug in src/calculator.ts: the divide function now throws Error("Division by zero is not allowed") when the divisor is zero, instead of silently returning Infinity.
  • Added a dedicated test in test/calculator.test.ts that verifies the error is thrown on division by zero.

Assumptions

  • Throwing an error is the appropriate behaviour (rather than returning null, NaN, or a result object) since the existing codebase uses simple return values and the test file already uses toThrow style assertions.

Test Results

All 5 tests pass (bun test).

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