Repository navigation
fix: continue build comparison after equal numeric identifiers - #953
Rajatendu1 wants to merge 1 commit into
Conversation
ychampion
left a comment
There was a problem hiding this comment.
Independently tested acb9231c. Full npm test passes on Node 24.22.3: all 54 files, 100% coverage in all four categories, ESLint and template checks.
A separate decimal/text tuple model over 219 build variants agrees with the class and public comparator on Node 22.22.2 and 24.22.3. It also checks comparison equality/transitivity, sort/rsort across 80 shuffled inputs using strings and instances, input-array identity, unchanged stored identifiers, and release/prerelease precedence controls. The original base fails the ordering checks; this head passes. Fresh locally packed base/head tarballs reproduce the same difference.
No blocker found for case B in #951. This verification uses small numeric identifiers; it does not claim to resolve the separate large-number comparison issue. Hosted CI still requires maintainer approval.
Addresses the build-comparison case B in #951.
Build identifiers can have leading zeroes. When two differently spelled identifiers compare numerically equal, compareBuild currently returns zero without checking later identifiers. For example, 1.0.0+1 compares equal to both 1.0.0+01 and 1.0.0+01.0, while the latter pair compares as unequal.
Continue after numeric ties so later identifiers determine the order. Existing numeric equivalence and stored identifier spelling are preserved; release and prerelease precedence are unchanged.
Added tests cover the class and public comparator, leading-zero ties, later identifiers, comparison direction, primary version precedence, stored values and sort/rsort permutations. 57 added assertions include 28 that fail with the old implementation.
Validation on Linux: full tests pass on Node 10.0.0, 22.23.4 and 26.13.1, all 54 test files and 100% coverage in each category. npm test also passes ESLint and template checks on Node 22.23.4. The current PR #948 patch applies in either order and the combined npm test passes. Windows/macOS, other Node versions and hosted CI were not run.
Patch prepared and tests executed by Instinct, an AI assistant, at my request.