Skip to content

Commit 4d048a2

Browse files
committed
[bugfix] tails of subsequences off by one
fixes #4830
1 parent 0b1ef35 commit 4d048a2

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

exist-core/src/main/java/org/exist/xquery/value/SubSequence.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public Sequence tail() {
204204
return Sequence.EMPTY_SEQUENCE;
205205
}
206206

207-
return new SubSequence(fromInclusive + 1, toExclusive -1, sequence);
207+
return new SubSequence(fromInclusive + 1, toExclusive, sequence);
208208
}
209209

210210
@Override

exist-core/src/test/xquery/subsequence.xq

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,27 @@ declare
3030
function ss:pipeline1() {
3131
("x", "y") => subsequence(1, 1) => matches("x")
3232
};
33+
34+
declare
35+
%test:args(1,1)
36+
%test:assertEmpty
37+
%test:args(3,1)
38+
%test:assertEmpty
39+
%test:args(5,1)
40+
%test:assertEmpty
41+
%test:args(1,2)
42+
%test:assertEquals(2)
43+
%test:args(3,2)
44+
%test:assertEquals(4)
45+
%test:args(5,2)
46+
%test:assertEmpty(4)
47+
%test:args(1,3)
48+
%test:assertEquals(2,3)
49+
%test:args(3,3)
50+
%test:assertEquals(4,5)
51+
%test:args(1,5)
52+
%test:assertEquals(2,3,4,5)
53+
function ss:tail($start, $length) {
54+
tail(
55+
subsequence((1 to 5), $start, $length))
56+
};

0 commit comments

Comments
 (0)