You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/03/09 02:05:39 UTC
[groovy] branch master updated (dac1aa0 -> 8c81fbe)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git.
from dac1aa0 use JUnit4 rather than JUnit 3 style to avoid using deprecated method
new 227fa16 GROOVY-9450: fix missing reference to startIndex in DefaultGroovyMethod#findIndexOf(Object self, int startIndex, Closure condition) (closes #1184)
new 8c81fbe GROOVY-9450: add test case
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../groovy/runtime/DefaultGroovyMethods.java | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
[groovy] 02/02: GROOVY-9450: add test case
Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 8c81fbea5011e3622abc0244bdd9d215a3e26f93
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Mar 9 11:55:04 2020 +1000
GROOVY-9450: add test case
---
.../groovy/runtime/DefaultGroovyMethods.java | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index c37df1d..c06d628 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -17149,6 +17149,17 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* Iterates over the elements of an aggregate of items, starting from a
* specified startIndex, and returns the index of the first item that matches the
* condition specified in the closure.
+ * Example (aggregate is {@code ChronoUnit} enum values):
+ * <pre class="groovyTestCase">
+ * import java.time.temporal.ChronoUnit
+ * def nameStartsWithM = { it.name().startsWith('M') }
+ * def first = ChronoUnit.findIndexOf(nameStartsWithM)
+ * def second = ChronoUnit.findIndexOf(first + 1, nameStartsWithM)
+ * def third = ChronoUnit.findIndexOf(second + 1, nameStartsWithM)
+ * Set units = [first, second, third]
+ * assert !units.contains(-1) // should have found 3 of MICROS, MILLIS, MINUTES, MONTHS, ...
+ * assert units.size() == 3 // just check size so as not to rely on order
+ * </pre>
*
* @param self the iteration object over which to iterate
* @param startIndex start matching from this index
@@ -17260,6 +17271,15 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
/**
* Iterates over the elements of an aggregate of items and returns
* the index of the last item that matches the condition specified in the closure.
+ * Example (aggregate is {@code ChronoUnit} enum values):
+ * <pre class="groovyTestCase">
+ * import java.time.temporal.ChronoUnit
+ * def nameStartsWithM = { it.name().startsWith('M') }
+ * def first = ChronoUnit.findIndexOf(nameStartsWithM)
+ * def last = ChronoUnit.findLastIndexOf(nameStartsWithM)
+ * // should have found 2 unique index values for MICROS, MILLIS, MINUTES, MONTHS, ...
+ * assert first != -1 && last != -1 && first != last
+ * </pre>
*
* @param self the iteration object over which to iterate
* @param condition the matching condition
[groovy] 01/02: GROOVY-9450: fix missing reference to startIndex in
DefaultGroovyMethod#findIndexOf(Object self, int startIndex,
Closure condition) (closes #1184)
Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 227fa161a775b8d750792685d2ff3193352c66e2
Author: zhao fan <35...@qq.com>
AuthorDate: Sun Mar 8 14:45:36 2020 +0800
GROOVY-9450: fix missing reference to startIndex in DefaultGroovyMethod#findIndexOf(Object self, int startIndex, Closure condition) (closes #1184)
Bug: can't use startIndex
---
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 29ccea2..c37df1d 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -17157,7 +17157,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* @since 1.5.0
*/
public static int findIndexOf(Object self, int startIndex, Closure condition) {
- return findIndexOf(InvokerHelper.asIterator(self), condition);
+ return findIndexOf(InvokerHelper.asIterator(self), startIndex, condition);
}
/**