Skip to content

Commit

Permalink
Issue #44: assert-equal-json inconsistent in comparisons (#85)
Browse files Browse the repository at this point in the history
Fixing issue where empty sequences were not being considered equal to one another when using assert-equal-json().
  • Loading branch information
cskeefer authored and jamesagardner committed Jul 22, 2019
1 parent ad810a0 commit 36a2d70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let $j3 := xdmp:to-json(xdmp:from-json-string(
'{"PersonNameType":{"PersonGivenName":"LINDSEY", "PersonSurName":"JONES"},"charges":[1,true,"a",null]}'
))/node()


let $j4 :=
let $o := json:object()
let $pnt := json:object()
Expand Down Expand Up @@ -46,6 +47,8 @@ let $j5 :=
let $_ := map:put($o, "charges", $a)
return $o

let $j6 := xdmp:to-json(xdmp:from-json-string('{ "objKeyWithNullValue": null}'))/node()

return xdmp:eager((
test:assert-equal-json($j1, $j2),
test:assert-equal-json($j1, $j3),
Expand All @@ -59,6 +62,6 @@ return xdmp:eager((
}, "ASSERT-EQUAL-JSON-FAILED"),
test:assert-throws-error(function() {
test:assert-equal-json($j0, $j5)
}, "ASSERT-EQUAL-JSON-FAILED")

}, "ASSERT-EQUAL-JSON-FAILED"),
test:assert-equal-json($j6, $j6)
))
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,10 @@ declare function test:assert-equal-json-recursive($object1, $object2) as xs:bool
test:assert-equal-json-recursive($v1, $v2)
return $counts-equal and fn:not($maps-equal = fn:false())
default return
$object1 = $object2
if(fn:empty($object1) and fn:empty($object2)) then
fn:true()
else
$object1 = $object2
};

declare function test:assert-true($conditions as xs:boolean*) {
Expand Down

0 comments on commit 36a2d70

Please sign in to comment.