Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2276-1785861738
Open

fix: implement missing utilities and fix edge-case bugs#277
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2276-1785861738

Conversation

@stooit

@stooit stooit commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the utility library. The suite now reports 60 pass / 0 fail (was 44 pass / 16 fail). No test files were modified and no dependencies were added.

Changes (src only)

  • calculator.tsdivide now throws on division by zero instead of returning Infinity (b === 0 also catches -0).
  • string-utils.tswordCount collapses consecutive whitespace (/\s+/); implemented truncate to cut at a word boundary with the ellipsis counting toward maxLength.
  • task-manager.ts — implemented remove, update, and sortBy. Priority sort orders high > medium > low; sort is stable so equal keys keep insertion order.
  • date-utils.tsformatRelative now uses Math.round(Math.abs(...)), fixing the off-by-one (36h → "2 days ago") symmetrically for past and future.
  • validator.tsisEmail accepts long TLDs (e.g. .museum); isUrl accepts host:port (e.g. http://localhost:3000). Added a JSDoc note that isUrl is a format check, not an SSRF control.

Verification

  • bun test → 60 pass, 0 fail
  • tsc --noEmit → clean
  • Reviewed via subagent: verdict COMMENT, no blocking issues.

Assumptions / scope notes

  • Constrained to "fix only what the tests require" — non-blocking review nits (negative maxLength guard, tab/newline word boundaries in truncate, patch-clear semantics in update) were left out as they have no test coverage and no in-repo callers.
  • sortBy("status") needed some ordering because "status" is in the type union; chose in_progress > pending > completed. No test constrains it.
  • Out-of-scope changes proposed by the implementation agent (lockfile generation, package.json/.gitignore edits, docs) were reverted to honour the "no new dependencies / fix only what's required" constraint.

- calculator: divide now throws on division by zero
- string-utils: wordCount collapses consecutive whitespace; implement truncate at word boundary with ellipsis
- task-manager: implement remove, update, and sortBy (priority/createdAt/status)
- date-utils: formatRelative uses rounding to fix off-by-one (36h -> 2 days ago)
- validator: isEmail accepts long TLDs; isUrl accepts host:port

All 60 tests pass. No test files or dependencies modified.
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