Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2408-1784046934
Open

fix: implement missing utilities and fix edge-case bugs#248
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2408-1784046934

Conversation

@stooit

@stooit stooit commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the utility library. The full suite now passes: 60 pass / 0 fail. No test files were modified and no dependencies were added.

Changes

  • src/calculator.tsdivide now throws Error("Division by zero") on a zero divisor instead of returning Infinity.
  • src/date-utils.tsformatRelative now rounds the day count (Math.round) so an exact 36-hour delta reads as "2 days ago", matching the test's expectation.
  • src/string-utils.ts — implemented wordCount handling of multiple consecutive spaces; implemented truncate word-boundary logic (returns unchanged within limit, truncates at word boundary, ellipsis counts toward maxLength, handles strings shorter than the ellipsis).
  • src/task-manager.ts — implemented remove (returns false for unknown ids), update (title/priority, false for unknown ids), and sortBy (priority high>medium>low, and createdAt oldest-first).
  • src/validator.tsisEmail now accepts long TLDs; isUrl now accepts URLs with a port (e.g. http://localhost:3000). Removed a stale BUG: JSDoc note that no longer applied.

Verification

  • bun test → 60 pass, 0 fail, 70 expect() calls.
  • Diff scoped to the 5 source files only; no test files touched.

Assumptions

  • The 36-hour "2 days ago" result is intentional per the test, so Math.round (not Math.floor) is the correct rounding for formatRelative.
  • update mutates the task in place (it holds the same reference stored in the Map), which is consistent with the existing add/get semantics.

🤖 Generated with QuantCode Agent

- calculator.divide: throw on division by zero instead of returning Infinity
- date-utils.formatRelative: round day count so 36h reads as 2 days ago
- string-utils: implement wordCount multi-space handling and truncate word-boundary logic
- task-manager: implement remove, update, and sortBy methods
- validator: allow long TLDs in isEmail and ports in isUrl
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