Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jan 12, 2014
@wolfgangmm wolfgangmm [testsuite] Copy namespaces occurring in test result before evaluatin…
…g %test:assertXPath annotation. Saves some time when writing tests.
69cb056
@shabanovd shabanovd Merge pull request #119 from wolfgangmm/develop
XQuery tests: namespaces fix
8b4ad79
View
23 src/org/exist/xquery/lib/xqsuite/xqsuite.xql
@@ -594,12 +594,31 @@ declare %private function test:assertXPath($annotation as element(annotation), $
util:expand($output)
else
$output
+ let $prolog :=
+ if ($result instance of element()*) then
+ let $namespaces := fold-left(function ($namespaces as map(*), $xml as element()) {
+ map:new(($namespaces,
+ for $prefix in in-scope-prefixes($xml)
+ where $prefix != "" and $prefix != "xml"
+ return
+ map:entry($prefix, namespace-uri-for-prefix($prefix, $xml))
+ ))
+ }, map:new(), $result/descendant-or-self::*)
+ return
+ string-join(
+ for $prefix in map:keys($namespaces)
+ return
+ "declare namespace " || $prefix || "='" || $namespaces($prefix) || "';",
+ " "
+ )
+ else
+ ()
let $xr :=
test:checkXPathResult(
if (matches($expr, "^\s*/")) then
- util:eval(concat("$result", $expr))
+ util:eval($prolog || "$result" || $expr)
else
- util:eval($expr)
+ util:eval($prolog || $expr)
)
return
if ($xr) then
View
46 test/src/xquery/xqsuite/xqsuite-tests.xql
@@ -0,0 +1,46 @@
+xquery version "3.0";
+
+(:~
+ : Some tests on features of the test suite itself.
+ :)
+module namespace t="http://exist-db.org/xquery/test/xqsuite";
+
+declare namespace test="http://exist-db.org/xquery/xqsuite";
+
+declare
+ %test:assertXPath("/name[. = 'Item1']")
+function t:xpath() {
+ <item>
+ <name>Item1</name>
+ </item>
+};
+
+declare
+ %test:assertXPath("/t:name[. = 'Item1']")
+function t:xpath-with-namespace() {
+ <t:item>
+ <t:name>Item1</t:name>
+ </t:item>
+};
+
+declare
+ %test:assertXPath("/t:name/x:id[. = 'abc']")
+function t:xpath-with-different-namespaces() {
+ <t:item>
+ <t:name><x:id xmlns:x="http://test.com/x">abc</x:id></t:name>
+ </t:item>
+};
+
+declare
+ %test:assertXPath("declare namespace f='http://foo.com'; $result//f:name[. = 'Item1']")
+function t:xpath-with-default-namespace() {
+ <item xmlns="http://foo.com">
+ <name>Item1</name>
+ </item>
+};
+
+declare
+ %test:assertXPath("string-length($result) = 5")
+function t:xpath-atomic-value() {
+ "Hello"
+};

No commit comments for this range

Something went wrong with that request. Please try again.