fix: repair failing utility tests and implement missing functions - #336
Open
stooit wants to merge 1 commit into
Open
fix: repair failing utility tests and implement missing functions#336stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- calculator: divide throws on zero divisor instead of returning Infinity - string-utils: wordCount splits on whitespace runs; implement truncate at word boundary with ellipsis counting toward maxLength (clamp negative len) - task-manager: implement remove/update/sortBy semantics - date-utils: round day bucket (abs before round) fixing off-by-one - validator: isEmail accepts multi-label domains; isUrl drops spurious port check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all 16 previously-failing tests (60/60 pass,
tsc --noEmitclean). Changes are confined tosrc/; no test files were modified and no dependencies added.Changes
dividenow throws on a zero divisor (b === 0, catches-0) instead of returningInfinity.wordCountsplits the trimmed string on/\s+/(fixes consecutive spaces, tabs, newlines).truncateimplemented: returns unchanged whenstr.length <= maxLength; otherwise reserves 3 chars for"...", cuts at the last word boundary within budget, trims trailing whitespace, and clamps negativemaxLengthto"".removedelegates toMap.delete;updatereturnsfalsefor unknown ids and applies only supplied keys;sortByranks priority (high>medium>low) and status, numeric compare oncreatedAt(stable sort preserves insertion order).Math.round(Math.abs(diffHours)/24)(abs before round), fixing the off-by-one so 36h reads "2 days ago" and future dates are symmetric.isEmailaccepts arbitrarily many dot-separated domain labels with 2+ char TLDs (still rejects empty labels, trailing dots, bare domains);isUrldrops the spuriousport === ""condition while keeping the protocol allowlist.Testing
`bun test` → 60 pass / 0 fail. Independent review pass confirmed no logical/coincidental-pass issues (verdict: no blockers).
Assumptions & notes