Skip to content

Commit

Permalink
[test] Fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamretter committed May 16, 2023
1 parent cf543a0 commit eebf365
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 148 deletions.
22 changes: 11 additions & 11 deletions exist-core/src/test/xquery/indexing/range.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,35 +78,35 @@
<task>Test empty element content</task>
<code>doc("/db/test/text1.xml")//a[. = 'A1']</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
<test output="xml" trace="yes">
<task>Test empty element content</task>
<code>doc("/db/test/text1.xml")//a[. = '']</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
<test output="xml" trace="yes">
<task>Simple query on xs:integer</task>
<code>doc("/db/test/text1.xml")//b[. = 1]</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
<test output="xml" trace="yes">
<task>Greater than on xs:integer</task>
<code>doc("/db/test/text1.xml")//b[. > 1]</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
<test output="xml" trace="yes">
<task>Greater than on xs:string</task>
<code>doc("/db/test/text1.xml")//b[. > "1"]</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
<!-- Will fail: -->
Expand All @@ -119,42 +119,42 @@
<task>Greater than on xs:double</task>
<code>doc("/db/test/text1.xml")//c[. > xs:integer(1)]</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
<test output="xml" trace="yes">
<task>Greater than on xs:double</task>
<code>doc("/db/test/text1.xml")//c[. > 1.0]</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
<test id="emptyInt" output="xml" trace="yes">
<task>Lookup xs:integer</task>
<code>doc("/db/test/text1.xml")//d[. = 20]</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
<test id="inconsistent" output="xml" trace="yes">
<task>Lookup xs:double on element containing numbers and strings</task>
<code>doc("/db/test/text1.xml")//e[. = 50.0]</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
<test id="inconsistent2" output="xml" trace="yes">
<task>Compare xs:double on element containing numbers and strings</task>
<code>doc("/db/test/text1.xml")//e[. > 50.0]</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
<test output="xml" trace="yes">
<task>Query inside document constructor</task>
<code>document { doc("/db/test/text1.xml")//b[. = 1] }</code>
<xpath xmlns:prof="http://exist-db.org/xquery/profiling">
//prof:index[@type = 'range'][@optimization = 2]
//prof:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']
</xpath>
</test>
</TestSet>
66 changes: 33 additions & 33 deletions exist-core/src/test/xquery/optimizer/expressions.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -89,39 +89,39 @@ function ot:cleanup() {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-simple-comparison($name as xs:string) {
collection($ot:COLLECTION)//address[name = $name]/city/text()
};

declare
%test:stats
%test:args("Rüsselsheim")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 0]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'NONE']")
function ot:no-optimize-simple-comparison($name as xs:string) {
collection($ot:COLLECTION)//address[city = $name]/city/text()
};

declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-filter-context-step($name as xs:string) {
collection($ot:COLLECTION)//(address)[name = $name]/city/text()
};

declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-sequence($name as xs:string) {
(collection($ot:COLLECTION)//address[name = $name]/city/text(), "xxx")
};

declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-let($name as xs:string) {
let $city := collection($ot:COLLECTION)//address[name = $name]/city/text()
return
Expand All @@ -131,7 +131,7 @@ function ot:optimize-let($name as xs:string) {
declare
%test:stats
%test:args("Rüsselsheim")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 0]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'NONE']")
function ot:no-optimize-let($name as xs:string) {
let $city := collection($ot:COLLECTION)//address[city = $name]/city/text()
return
Expand All @@ -141,7 +141,7 @@ function ot:no-optimize-let($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-for($name as xs:string) {
for $city in collection($ot:COLLECTION)//address[name = $name]/city/text()
return
Expand All @@ -151,7 +151,7 @@ function ot:optimize-for($name as xs:string) {
declare
%test:stats
%test:args("Rüsselsheim")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 0]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'NONE']")
function ot:no-optimize-for($name as xs:string) {
for $city in collection($ot:COLLECTION)//address[city = $name]/city/text()
return
Expand All @@ -161,7 +161,7 @@ function ot:no-optimize-for($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-if-then($name as xs:string) {
if (1 = 1) then
collection($ot:COLLECTION)//address[name = $name]/city/text()
Expand All @@ -172,7 +172,7 @@ function ot:optimize-if-then($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-if-else($name as xs:string) {
if (1 = 2) then
()
Expand All @@ -191,23 +191,23 @@ declare %private function ot:find-by-city($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-function-call($name as xs:string) {
ot:find-by-name($name)
};

declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:no-optimize-function-call($name as xs:string) {
ot:find-by-name($name)
};

declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-try($name as xs:string) {
try {
collection($ot:COLLECTION)//address[name = $name]/city/text()
Expand All @@ -219,7 +219,7 @@ function ot:optimize-try($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-catch($name as xs:string) {
try {
xs:int("abc")
Expand All @@ -231,31 +231,31 @@ function ot:optimize-catch($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-attribute-enclosed($name as xs:string) {
<a title="{collection($ot:COLLECTION)//address[name = $name]/city/text()}"></a>
};

declare
%test:stats
%test:args("Rüsselsheim")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 0]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'NONE']")
function ot:no-optimize-attribute-enclosed($name as xs:string) {
<a title="{collection($ot:COLLECTION)//address[city = $name]/city/text()}"></a>
};

declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-element-enclosed($name as xs:string) {
<a>{collection($ot:COLLECTION)//address[name = $name]/city/text()}</a>
};

declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-element-dynamic-enclosed($name as xs:string) {
element a {
collection($ot:COLLECTION)//address[name = $name]/city/text()
Expand All @@ -265,7 +265,7 @@ function ot:optimize-element-dynamic-enclosed($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-attribute-dynamic-enclosed($name as xs:string) {
<a>
{
Expand All @@ -279,7 +279,7 @@ function ot:optimize-attribute-dynamic-enclosed($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-inline-function($name as xs:string) {
let $f := function() {
collection($ot:COLLECTION)//address[name = $name]/city/text()
Expand All @@ -291,7 +291,7 @@ function ot:optimize-inline-function($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-inline-function-enclosed-attribute($name as xs:string) {
let $f := function() {
collection($ot:COLLECTION)//address[name = $name]/city/text()
Expand All @@ -303,7 +303,7 @@ function ot:optimize-inline-function-enclosed-attribute($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-inline-function-enclosed($name as xs:string) {
let $f := function() {
collection($ot:COLLECTION)//address[name = $name]/city/text()
Expand All @@ -315,7 +315,7 @@ function ot:optimize-inline-function-enclosed($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-function-reference($name as xs:string) {
let $f := ot:find-by-name#1
return
Expand All @@ -325,7 +325,7 @@ function ot:optimize-function-reference($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-function-map($name as xs:string) {
let $f := ot:find-by-name#1
return
Expand All @@ -335,7 +335,7 @@ function ot:optimize-function-map($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-function-partial($name as xs:string) {
let $f1 := function($foo, $name) {
ot:find-by-name($name)
Expand All @@ -348,11 +348,11 @@ function ot:optimize-function-partial($name as xs:string) {
declare
%test:stats
%test:args(1, "Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
%test:args(2, "Rüsselsheim")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 0]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'NONE']")
%test:args(3, "Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-switch($case as xs:integer, $name as xs:string) {
switch($case)
case 1 return
Expand All @@ -366,11 +366,11 @@ function ot:optimize-switch($case as xs:integer, $name as xs:string) {
declare
%test:stats
%test:args("<a/>", "Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
%test:args("<b/>", "Rüsselsheim")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 0]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'NONE']")
%test:args("<c/>", "Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-typeswitch($case as element(), $name as xs:string) {
typeswitch($case)
case element(a) return
Expand All @@ -384,7 +384,7 @@ function ot:optimize-typeswitch($case as element(), $name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-map($name as xs:string) {
let $map := map {
"key": collection($ot:COLLECTION)//address[name = $name]/city/text()
Expand All @@ -396,7 +396,7 @@ function ot:optimize-map($name as xs:string) {
declare
%test:stats
%test:args("Rudi Rüssel")
%test:assertXPath("$result//stats:index[@type = 'range'][@optimization = 2]")
%test:assertXPath("$result//stats:index[@type eq 'range'][@optimization-level eq 'OPTIMIZED']")
function ot:optimize-map-entry($name as xs:string) {
let $map := map:entry(
"key", collection($ot:COLLECTION)//address[name = $name]/city/text()
Expand Down
Loading

0 comments on commit eebf365

Please sign in to comment.