Skip to content

Commit 4df1ef2

Browse files
committed
test: add semver build metadata and long prerelease chain tests
Verify build metadata is ignored per SemVer 2.0 spec section 10 and multi-segment prerelease chains compare correctly. Closes #40 Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent b194ce4 commit 4df1ef2

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/unit/binaryDiscovery.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,21 @@ test("comparePatchloomVersions compares prerelease identifiers correctly", () =>
168168
assert.ok(comparePatchloomVersions("0.1.0", "0.1.0-rc.1") > 0);
169169
});
170170

171+
test("comparePatchloomVersions ignores build metadata per SemVer 2.0", () => {
172+
// Build metadata MUST be ignored in precedence (SemVer 2.0 spec §10)
173+
assert.equal(comparePatchloomVersions("1.0.0+build1", "1.0.0+build2"), 0);
174+
assert.equal(comparePatchloomVersions("1.0.0-alpha+build", "1.0.0-alpha"), 0);
175+
assert.ok(comparePatchloomVersions("1.0.0+build", "1.0.0-alpha+build") > 0);
176+
});
177+
178+
test("comparePatchloomVersions handles long prerelease chains", () => {
179+
// Multi-segment prerelease with mixed numeric and string
180+
assert.ok(comparePatchloomVersions("1.0.0-alpha.beta.1", "1.0.0-alpha.beta.2") < 0);
181+
assert.ok(comparePatchloomVersions("1.0.0-alpha.beta.gamma", "1.0.0-alpha.beta.delta") > 0);
182+
// Shorter chain < longer chain when prefix matches
183+
assert.ok(comparePatchloomVersions("1.0.0-alpha.beta", "1.0.0-alpha.beta.1") < 0);
184+
});
185+
171186
test("assessPatchloomCompatibility correctly identifies supported versions", () => {
172187
const supported = assessPatchloomCompatibility("patchloom 0.1.0");
173188
assert.equal(supported.compatibility, "supported");

0 commit comments

Comments
 (0)