Skip to content

Commit 85b07a5

Browse files
committed
[test] Further tests for array:get
1 parent d42dbf6 commit 85b07a5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/src/xquery/arrays/arrays.xql

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ function arr:function-item-invalid() {
137137
declare
138138
%test:assertError("FOAY0001")
139139
function arr:get-item-out-of-bounds-positive() {
140+
let $a := [13, 10, 14]
141+
return
142+
array:get($a, 4)
143+
};
144+
145+
declare
146+
%test:assertError("FOAY0001")
147+
function arr:get-item-out-of-bounds-positive-large() {
140148
let $a := [13, 10, 14]
141149
return
142150
array:get($a, 22)
@@ -158,6 +166,31 @@ function arr:get-item-out-of-bounds-negative() {
158166
array:get($a, -1)
159167
};
160168

169+
declare
170+
%test:pending("eXist-db does not correctly detect the type error. This is likely a larger issue than just arrays.")
171+
%test:assertError("XPTY0004")
172+
function arr:get-invalid-type() {
173+
let $a := [13, 10, 14]
174+
return
175+
array:get($a, xs:double(0.1))
176+
};
177+
178+
declare
179+
%test:assertEquals(13)
180+
function arr:get-first() {
181+
let $a := [13, 10, 14]
182+
return
183+
array:get($a, 1)
184+
};
185+
186+
declare
187+
%test:assertEquals(14)
188+
function arr:get-last() {
189+
let $a := [13, 10, 14]
190+
return
191+
array:get($a, 3)
192+
};
193+
161194
declare
162195
%test:args(1)
163196
%test:assertEmpty

0 commit comments

Comments
 (0)