Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/xquery/semver.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ declare function semver:ge-parsed($parsed-v1 as map(*), $parsed-v2 as map(*)) as
: @return true if v1 is equal to v2
:)
declare function semver:eq($v1 as xs:string, $v2 as xs:string) as xs:boolean {
semver:compare($v1, $v2) eq 0
semver:eq($v1, $v2, false())
};

(:~ Test if v1 is equal to v2 (with an option to coerce invalid SemVer strings)
Expand All @@ -575,7 +575,7 @@ declare function semver:eq($v1 as xs:string, $v2 as xs:string) as xs:boolean {
: @return true if v1 is equal to v2
:)
declare function semver:eq($v1 as xs:string, $v2 as xs:string, $coerce as xs:boolean) as xs:boolean {
semver:compare($v1, $v2) eq 0
semver:compare($v1, $v2, $coerce) eq 0
};

(:~ Test if a parsed v1 is equal to a parsed v2
Expand Down
15 changes: 15 additions & 0 deletions src/test/xquery/compare.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,18 @@ function stc:compare-lt-parsed() {
map{"major":2,"minor":0,"patch":0,"pre-release":[],"build-metadata":[],"identifiers":[2,0,0,[],[]]}
)
};

(: Regression tests for bug where semver:eq/3 ignored $coerce and called
semver:compare/2 instead of semver:compare/3 :)

declare
%test:assertTrue
function stc:eq-coerce-non-semver() {
semver:eq("1.0", "1.0.0", true())
};

declare
%test:assertFalse
function stc:eq-coerce-non-semver-not-equal() {
semver:eq("1.0", "2.0.0", true())
};