Skip to content

Commit

Permalink
Merge pull request #4850 from line-o/fix/4830
Browse files Browse the repository at this point in the history
[bugfix] tails of subsequences off by one
  • Loading branch information
adamretter committed Apr 19, 2023
2 parents eb22fdf + 4d048a2 commit 7ed15a3
Show file tree
Hide file tree
Showing 2 changed files with 25 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
24 changes: 24 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,27 @@ 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) {
tail(
subsequence((1 to 5), $start, $length))
};

0 comments on commit 7ed15a3

Please sign in to comment.