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 9, 2023
1 parent 2564f22 commit a405132
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 49 deletions.
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 a405132

Please sign in to comment.