Skip to content

fix: handle division by zero in divide()#129

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

fix: handle division by zero in divide()#129
quantcode-agent[bot] wants to merge 1 commit intomainfrom
quantcode/job-job-4ac3f7fe

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Fixed the division-by-zero bug in src/calculator.ts by throwing Error("Division by zero") when the divisor is 0
  • Added tests for divide() in test/calculator.test.ts covering normal division and the zero-divisor error case

Changes

  • src/calculator.ts: Added if (b === 0) throw new Error("Division by zero") guard in divide()
  • test/calculator.test.ts: Added divide to imports and a describe("divide") block with 2 tests

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