Repository navigation
Conversation
Not up to standards ⛔
|
099215a to
f4c1807
Compare
| } | ||
|
|
||
| @Test | ||
| public void typedForVariableWithEmptyReturn_5050() throws XMLDBException { |
There was a problem hiding this comment.
Please don't name this _5050. Instead link to the GitHub issue in the Javadoc for the function.
|
|
||
| @Test | ||
| public void typedForVariableWithEmptyReturn_5050() throws XMLDBException { | ||
| final String query = "for $x as xs:string in 'X' return ()"; |
There was a problem hiding this comment.
I would like to see more tests added. Just two JUnit Test functions please, one for for and one for let.
I would also like to see the XQuery code within each function formatted a bit more nicely please:
-
let $x := 'X' return $x
-
let $x as xs:string := 'X' return $x
-
let $result := let $x as xs:string := 'X' return $x return empty($result)
-
let $x := 'X' return ()
-
let $x as xs:string := 'X' return ()
-
let $result := let $x as xs:string := 'X' return () return empty($result)
-
let $x := 'X' return 1
-
let $x as xs:string := 'X' return 1
-
let $result := let $x as xs:string := 'X' return 1 return empty($result)
-
let $x := 'X' return (1, 2, 3)
-
let $x as xs:string := 'X' return (1, 2, 3)
-
let $result := let $x as xs:string := 'X' return (1, 2, 3) return empty($result)
-
for $x in 'X' return $x
-
for $x as xs:string in 'X' return $x
-
let $result := for $x as xs:string in 'X' return $x return empty($result)
-
for $x in 'X' return ()
-
for $x as xs:string in 'X' return ()
-
let $result := for $x as xs:string in 'X' return () return empty($result)
-
for $x in 'X' return 1
-
for $x as xs:string in 'X' return 1
-
let $result := for $x as xs:string in 'X' return 1 return empty($result)
-
for $x in 'X' return (1, 2, 3)
-
for $x as xs:string in 'X' return (1, 2, 3)
-
let $result := for $x as xs:string in 'X' return (1, 2, 3) return empty($result)
Please also rename the test functions you create to make it more reflective of the GitHub issue, and what it is actually testing.
There was a problem hiding this comment.
Some more for tests to add please:
(: for - returning $x :)
for $x as empty-sequence() allowing empty in ()
return
$x
,
for $x as xs:integer in ()
return
$x
,
for $x as xs:integer? in ()
return
$x
,
for $x as xs:integer+ in ()
return
$x
,
for $x as xs:integer* in ()
return
$x
,
for $x as empty-sequence() allowing empty in (1, 2, 3)
return
$x
,
for $x as xs:integer in (1,2,3)
return
$x
,
for $x as xs:integer? in (1,2,3)
return
$x
,
for $x as xs:integer+ in (1,2,3)
return
$x
,
for $x as xs:integer* in (1,2,3)
return
$x
,
(: for - returning empty-sequence() :)
for $x as empty-sequence() allowing empty in ()
return
()
,
for $x as xs:integer in ()
return
()
,
for $x as xs:integer? in ()
return
()
,
for $x as xs:integer+ in ()
return
()
,
for $x as xs:integer* in ()
return
()
,
for $x as empty-sequence() allowing empty in (1,2,3)
return
()
,
for $x as xs:integer in (1,2,3)
return
()
,
for $x as xs:integer? in (1,2,3)
return
()
,
for $x as xs:integer+ in (1,2,3)
return
()
,
for $x as xs:integer* in (1,2,3)
return
()
There was a problem hiding this comment.
Some more let tests to add please:
(: let - returning $x :)
let $x as empty-sequence() := ()
return
$x
,
let $x as xs:integer := ()
return
$x
,
let $x as xs:integer? := ()
return
$x
,
let $x as xs:integer+ := ()
return
$x
,
let $x as xs:integer* := ()
return
$x
,
let $x as xs:integer := (1,2,3)
return
$x
,
let $x as xs:integer? := (1,2,3)
return
$x
,
let $x as xs:integer+ := (1,2,3)
return
$x
,
let $x as xs:integer* := (1,2,3)
return
$x
,
(: let - returning empty-sequence() :)
let $x as empty-sequence() := ()
return
()
,
let $x as xs:integer := ()
return
()
,
let $x as xs:integer? := ()
return
()
,
let $x as xs:integer+ := ()
return
()
,
let $x as xs:integer* := ()
return
()
,
let $x as xs:integer := (1,2,3)
return
()
,
let $x as xs:integer? := (1,2,3)
return
()
,
let $x as xs:integer+ := (1,2,3)
return
()
,
let $x as xs:integer* := (1,2,3)
return
()
There was a problem hiding this comment.
@adamretter while adding your queries as tests I found that for $x as xs:string in 'X' return 1 (and the same with return (1, 2, 3)) fails with XPTY0004 Invalid type for variable $x. Expected xs:string, got xs:integer. I think they should work, since $x is a string. Should I fix this in this PR or open a separate issue?
A
forvariable with a type, likefor $x as xs:string in 'X' return (), no longer gives an "Invalid cardinality" error when it returns nothing.Closes eXist-db/exist#5050