Skip to content

Commit

Permalink
Merge pull request #4778 from line-o/xqsuite/safe-ebv
Browse files Browse the repository at this point in the history
[refactor] XQSuite for readability
  • Loading branch information
dizzzz committed Mar 6, 2023
2 parents 493c65b + e8dbc7a commit ece817f
Showing 1 changed file with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -905,31 +905,26 @@ declare %private function test:assertTrue($result as item()*) as element(report)
</report>
};

declare %private function test:safe-effective-boolean-value ($result as item()*) as xs:boolean {
try {
boolean($result)
} catch err:FORG0006 {
false()
}
};

(:~
: Check if the function caused an error.
:)
declare %private function test:assertError($value as xs:string, $result as item()*) as element(report)? {
let $ebv :=
try {
if ($result)
then
fn:true()
else
fn:false()
} catch err:FORG0006 {
fn:false()
}
return

if ($ebv)
then
()
else
<report>
<failure message="assertError failed. Expected error {$value}"
type="failure-error-code-1"/>
<output>{ $result }</output>
</report>
if (test:safe-effective-boolean-value($result))
then ()
else
<report>
<failure message="assertError failed. Expected error {$value}"
type="failure-error-code-1"/>
<output>{ $result }</output>
</report>
};

(:~
Expand Down

0 comments on commit ece817f

Please sign in to comment.