|
xquery version "3.1";
|
|
|
|
(: the tested library module :)
|
|
import module "x-urn:test:do-nothing"
|
|
at "test/do-nothing.xqm";
|
|
|
|
(: XSpec library modules providing tools :)
|
|
import module "http://www.jenitennison.com/xslt/xspec"
|
|
at "src/common/common-utils.xqm";
|
|
import module "urn:x-xspec:common:deep-equal"
|
|
at "src/common/deep-equal.xqm";
|
|
import module "urn:x-xspec:common:report-sequence"
|
|
at "src/common/report-sequence.xqm";
|
|
|
|
declare namespace x = "http://www.jenitennison.com/xslt/xspec";
|
|
declare option Q{http://www.w3.org/2010/xslt-xquery-serialization}parameter-document "src/common/xml-report-serialization-parameters.xml";
|
|
declare variable $Q{http://www.jenitennison.com/xslt/xspec}xspec-uri as xs:anyURI := (
|
|
xs:anyURI("test/issue-423/test.xspec")
|
|
);
|
|
|
|
(: generated from the x:scenario element :)
|
|
declare function local:scenario1(
|
|
) as element(Q{http://www.jenitennison.com/xslt/xspec}scenario)
|
|
{
|
|
element { QName('http://www.jenitennison.com/xslt/xspec', 'scenario') } {
|
|
attribute { QName('', 'id') } { 'scenario1' },
|
|
attribute { QName('', 'xspec') } { 'test/issue-423/test.xspec' },
|
|
element { QName('http://www.jenitennison.com/xslt/xspec', 'label') } {
|
|
text { 'Suppose you''re testing count() function with child::element() selected but you
|
|
forget to provide the selection context (either inner XML or @href)' }
|
|
},
|
|
element { QName('', 'input-wrap') } {
|
|
element { QName('http://www.jenitennison.com/xslt/xspec', 'x:call') } {
|
|
attribute { QName('', 'function') } { 'count' },
|
|
element { QName('http://www.jenitennison.com/xslt/xspec', 'x:param') } {
|
|
attribute { QName('', 'select') } { 'child::element()' }
|
|
}
|
|
}},
|
|
let $Q{urn:x-xspec:compile:impl}param-d53e1 := (
|
|
child::element()
|
|
)
|
|
let $Q{http://www.jenitennison.com/xslt/xspec}result as item()* := (
|
|
count($Q{urn:x-xspec:compile:impl}param-d53e1)
|
|
)
|
|
let $local:actual-result-report := Q{urn:x-xspec:common:report-sequence}report-sequence($Q{http://www.jenitennison.com/xslt/xspec}result, 'result')
|
|
|
|
(: invoke each compiled x:expect :)
|
|
let $local:returned-from-scenario1-expect1 := local:scenario1-expect1(
|
|
$Q{http://www.jenitennison.com/xslt/xspec}result
|
|
)
|
|
return (
|
|
$local:actual-result-report,
|
|
$local:returned-from-scenario1-expect1
|
|
)
|
|
}
|
|
};
|
|
|
|
(: generated from the x:expect element :)
|
|
declare function local:scenario1-expect1(
|
|
$Q{http://www.jenitennison.com/xslt/xspec}result as item()*
|
|
) as element(Q{http://www.jenitennison.com/xslt/xspec}test)
|
|
{
|
|
let $Q{urn:x-xspec:compile:impl}expect-d50e6 (:expected result:) := (
|
|
1
|
|
)
|
|
let $local:successful as xs:boolean :=
|
|
Q{urn:x-xspec:common:deep-equal}deep-equal($Q{urn:x-xspec:compile:impl}expect-d50e6, $Q{http://www.jenitennison.com/xslt/xspec}result, '')
|
|
return
|
|
element { QName('http://www.jenitennison.com/xslt/xspec', 'test') } {
|
|
attribute { QName('', 'id') } { 'scenario1-expect1' },
|
|
attribute { QName('', 'successful') } { $local:successful },
|
|
element { QName('http://www.jenitennison.com/xslt/xspec', 'label') } {
|
|
text { 'and you happen to expect 1' }
|
|
},
|
|
Q{urn:x-xspec:common:report-sequence}report-sequence($Q{urn:x-xspec:compile:impl}expect-d50e6, 'expect')
|
|
}
|
|
};
|
|
|
|
(: the query body of this main module, to run the suite :)
|
|
(: set up the result document (the report) :)
|
|
document {
|
|
element { QName('http://www.jenitennison.com/xslt/xspec', 'report') } {
|
|
attribute { QName('', 'xspec') } { 'test/issue-423/test.xspec' },
|
|
attribute { QName('', 'query') } { 'x-urn:test:do-nothing' },
|
|
attribute { QName('', 'query-at') } { 'test/do-nothing.xqm' },
|
|
attribute { QName('', 'date') } { current-dateTime() },
|
|
(: invoke each compiled top-level x:scenario :)
|
|
let $local:returned-from-scenario1 := local:scenario1(
|
|
)
|
|
return (
|
|
$local:returned-from-scenario1
|
|
)
|
|
}
|
|
}
|