Skip to content

Commit

Permalink
[bugfix] tails of subsequences off by one
Browse files Browse the repository at this point in the history
fixes #4830
  • Loading branch information
line-o committed Apr 4, 2023
1 parent 1e92f35 commit 052bffb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public Sequence tail() {
return Sequence.EMPTY_SEQUENCE;
}

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

@Override
Expand Down
23 changes: 23 additions & 0 deletions exist-core/src/test/xquery/subsequence.xq
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,26 @@ declare
function ss:pipeline1() {
("x", "y") => subsequence(1, 1) => matches("x")
};

declare
%test:args(1,1)
%test:assertEmpty
%test:args(3,1)
%test:assertEmpty
%test:args(5,1)
%test:assertEmpty
%test:args(1,2)
%test:assertEquals(2)
%test:args(3,2)
%test:assertEquals(4)
%test:args(5,2)
%test:assertEmpty(4)
%test:args(1,3)
%test:assertEquals(2,3)
%test:args(3,3)
%test:assertEquals(4,5)
%test:args(1,5)
%test:assertEquals(2,3,4,5)
function ss:tail($start, $length) {
subsequence((1 to 5), $start, $length) => tail()
};

0 comments on commit 052bffb

Please sign in to comment.