From 69cba4d2401b7206b46d3942dba8cba1b08a395e Mon Sep 17 00:00:00 2001 From: Dannes Wessels Date: Sat, 30 Jul 2016 19:35:17 +0200 Subject: [PATCH 1/2] The size is a position, actually. --- src/org/exist/xquery/value/ValueSequence.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/exist/xquery/value/ValueSequence.java b/src/org/exist/xquery/value/ValueSequence.java index a6341e7b30e..acca3babc29 100644 --- a/src/org/exist/xquery/value/ValueSequence.java +++ b/src/org/exist/xquery/value/ValueSequence.java @@ -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() { } From e4b821514f91f56dc40ad009d0bcd08b3da56e68 Mon Sep 17 00:00:00 2001 From: Dannes Wessels Date: Sat, 30 Jul 2016 23:10:16 +0200 Subject: [PATCH 2/2] Added unit tests for fold-right fix , fixes https://github.com/eXist-db/exist/issues/1067 --- test/src/xquery/xquery3/fn.xql | 16 ++++++++++++++++ test/src/xquery/xquery3/suite.xql | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/src/xquery/xquery3/fn.xql diff --git a/test/src/xquery/xquery3/fn.xql b/test/src/xquery/xquery3/fn.xql new file mode 100644 index 00000000000..554c38a1fff --- /dev/null +++ b/test/src/xquery/xquery3/fn.xql @@ -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) + }) +}; + diff --git a/test/src/xquery/xquery3/suite.xql b/test/src/xquery/xquery3/suite.xql index bfbf604e6f9..b579bdaae11 100644 --- a/test/src/xquery/xquery3/suite.xql +++ b/test/src/xquery/xquery3/suite.xql @@ -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")) ))