Skip to content

Commit

Permalink
Merge pull request #1076 from dizzzz/bugfix/right-fold-fix
Browse files Browse the repository at this point in the history
Repair fold-right
  • Loading branch information
wolfgangmm authored Aug 1, 2016
2 parents 065aeb8 + e4b8215 commit 0584190
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/org/exist/xquery/value/ValueSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ public Item nextItem() {

private class ReverseValueSequenceIterator implements SequenceIterator {

private int pos = size - 1;
private int pos = size; // size is not the actual size

public ReverseValueSequenceIterator() {
}
Expand Down
16 changes: 16 additions & 0 deletions test/src/xquery/xquery3/fn.xql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
xquery version "3.0";

module namespace fn="http://exist-db.org/xquery/test/fnfunctions";

declare namespace test="http://exist-db.org/xquery/xqsuite";

declare
%test:assertEquals(0, 4, 3, 2, 1)
function fn:fold-right() {
let $seq := (1,2,3,4)
return
fold-right ($seq, (0) , function($item as xs:integer, $accu as xs:integer*) {
($accu, $item)
})
};

3 changes: 2 additions & 1 deletion test/src/xquery/xquery3/suite.xql
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ test:suite((
inspect:module-functions(xs:anyURI("concat.xql")),
inspect:module-functions(xs:anyURI("groupby.xql")),
inspect:module-functions(xs:anyURI("flwor.xql")),
inspect:module-functions(xs:anyURI("typeswitch.xql"))
inspect:module-functions(xs:anyURI("typeswitch.xql")),
inspect:module-functions(xs:anyURI("fn.xql"))
))

0 comments on commit 0584190

Please sign in to comment.