Skip to content

fix: implement missing utilities and fix edge-case bugs - #265

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2423-1785004143
Open

fix: implement missing utilities and fix edge-case bugs#265
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2423-1785004143

Conversation

@stooit

@stooit stooit commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the utility library. Suite now passes 60/60 with no test files modified and no new dependencies.

Changes

  • src/calculator.tsdivide now throws Division by zero when the divisor is 0 instead of returning Infinity.
  • src/date-utils.ts — day-difference now uses Math.round instead of Math.floor, so 36 hours correctly reports "2 days ago" (fixes the off-by-one).
  • src/string-utils.ts — implemented truncate: truncates at a word boundary with "..." counting toward maxLength, returns the string unchanged when str.length <= maxLength.
  • src/task-manager.ts — completed the missing/incomplete TaskManager methods without mutating internal state on read.
  • src/validator.ts — relaxed the isEmail TLD regex to accept long TLDs (e.g. .museum); reworked isUrl to use the platform URL parser with an http/https protocol guard (accepts ports like http://localhost:3000).

Verification

  • bun test60 pass, 0 fail (70 assertions).
  • Reviewed for correctness (not test-gaming) by the review agent.

Assumptions / Notes

  • Only files under src/ were changed; no test files touched, no dependencies added.
  • Reviewer flagged a pre-existing cosmetic quirk in date-utils.ts (23h30m–23h59m rounds to "24 hours ago" rather than "1 day ago"). It predates this change, is untested, and is out of scope — noted for a possible follow-up.

- calculator: guard divide against division by zero
- date-utils: use Math.round for day diff (36h -> '2 days ago')
- string-utils: implement truncate at word boundary with ellipsis
- task-manager: complete missing/incomplete TaskManager methods
- validator: relax email TLD regex, use URL parser for isUrl

All 60 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.

1 participant