Skip to content

Commit

Permalink
[MOD] XQuery, test cases. #1466.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianGruen committed Jun 26, 2017
1 parent 4abe0e8 commit 1cd6a0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public void xquery() {
// fn:collection() always accesses the global context, no matter what local context is
ckDBs(new XQuery("<a/>/" + COUNT.args(COLLECTION.args())), false, CTX_LIST);
ckDBs(new XQuery(DOC.args(NAME)), false, NAME_LIST);
ckDBs(new XQuery(DOC.args("http://abc.de/")), false, NONE);
ckDBs(new XQuery(ID.args(NAME)), false, CTX_LIST);
ckDBs(new XQuery(IDREF.args(NAME)), false, CTX_LIST);
ckDBs(new XQuery(ELEMENT_WITH_ID.args(NAME)), false, CTX_LIST);
Expand Down
19 changes: 19 additions & 0 deletions basex-core/src/test/java/org/basex/query/ast/RewritingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.basex.query.func.fn.*;
import org.basex.query.func.util.*;
import org.basex.query.value.item.*;
import org.basex.query.value.node.*;
import org.basex.util.*;
import org.junit.Test;

Expand All @@ -17,6 +18,9 @@
* @author Christian Gruen
*/
public final class RewritingsTest extends QueryPlanTest {
/** Input file. */
private static final String FILE = "src/test/resources/input.xml";

/**
* Checks if the count function is pre-compiled.
*/
Expand Down Expand Up @@ -202,4 +206,19 @@ public void list() {
public void nonDeterministic() {
check("count((# basex:non-deterministic #) { <x/> })", "1", "exists(//FnCount)");
}

/**
* Ensures that fn:doc with URLs will not be rewritten.
*/
@Test
public void doc() {
check("<a>{ doc('" + FILE + "') }</a>//x", "",
"exists(//" + Util.className(DBNode.class) + ')');
check("if(<x>1</x> = 1) then 2 else doc('" + FILE + "')", "2",
"exists(//" + Util.className(DBNode.class) + ')');
check("if(<x>1</x> = 1) then 2 else doc('http://abc.de/')", "2",
"exists(//" + Util.className(FnDoc.class) + ')');
check("if(<x>1</x> = 1) then 2 else collection('http://abc.de/')", "2",
"exists(//" + Util.className(FnCollection.class) + ')');
}
}

0 comments on commit 1cd6a0a

Please sign in to comment.