Skip to content

fix: handle division-by-zero in calculator#142

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

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

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Adds a guard in src/calculator.ts divide() that throws an Error("Division by zero is not allowed") when the divisor is 0
  • Adds tests in test/calculator.test.ts for both normal division and the division-by-zero error case

Assumptions

  • Throwing an Error is the appropriate behavior for division by zero (rather than returning Infinity, NaN, or a result type)
  • The existing test file structure and test runner (bun test) are the correct conventions for this repo

All 5 tests pass.

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