You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "paulk-asert (via GitHub)" <gi...@apache.org> on 2026/07/30 10:45:23 UTC
[PR] GROOVY-12216: fat-free (functional-interface) twins for the fold/redu… [groovy]
paulk-asert opened a new pull request, #2751:
URL: https://github.com/apache/groovy/pull/2751
…ce DGM methods
Add java.util.function twins beside the Closure overloads of inject and injectAll in DefaultGroovyMethods (Object/Iterator/Map receivers) and ArrayGroovyMethods (array receivers). No-initial-value forms take a BinaryOperator; initial-value forms take a BiFunction (Map forms fold over Map.Entry). The Iterable inject twins already existed from GROOVY-12054; this completes the remaining receivers.
sum is deliberately excluded (its twin collides with the Object initialValue overload) and is tracked separately.
13 new overloads (9 in DGM, 4 in ArrayGroovyMethods), plus a typed InjectAllFunctionIterator for the lazy Iterator form. Regression tests added to LambdasTest.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12216: fat-free (functional-interface) twins for the fold/redu… [groovy]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #2751:
URL: https://github.com/apache/groovy/pull/2751#issuecomment-5130025038
## 🚨 TestLens detected 1 failed test 🚨
Here is what you can do:
1) Inspect the test failures carefully.
2) If you are convinced that some of the tests are flaky, you can mute them below.
3) Finally, trigger a rerun by checking the rerun checkbox.
### Test Summary
#### [Build and test / lts \(21, ubuntu-latest\)](https://github.com/apache/groovy/actions/runs/30535901039/job/90849015212?pr=2751) > :test
| Test | Runs | Flakiness |
|---|---|--:|
| InspectorTest > testMetaMethods\(\) | ❌ | 0% 🟢 |
🏷️ Commit: e95e9a15963456ff6813cdfefe17ed2e63c88a29
▶️ Tests: 48123 executed
🟡 Checks: 6/29 completed
### Test Failures
<details>
<summary><strong>InspectorTest > testMetaMethods()</strong> (:test in <a href="https://github.com/apache/groovy/actions/runs/30535901039/job/90849015212?pr=2751">Build and test / lts (21, ubuntu-latest)</a>)</summary>
```
org.opentest4j.AssertionFailedError: Incorrect number of methods found examining: [addShutdownHook, any, any, asBoolean, asType, collect, collect, collect, dump, each, eachWithIndex, every, every, find, find, findAll, findAll, findIndexOf, findIndexOf, findIndexValues, findIndexValues, findLastIndexOf, findLastIndexOf, findResult, findResult, findResult, findResult, getAt, getMetaClass, getMetaPropertyValues, getProperties, grep, grep, hasProperty, identity, inject, inject, inject, inject, inspect, invokeMethod, is, isCase, isNotCase, iterator, metaClass, print, print, printf, printf, println, println, println, putAt, respondsTo, respondsTo, setMetaClass, split, sprintf, sprintf, takeIf, tap, toString, use, use, use, with, with, withMethodClosure, withTraits, stream, sleep, sleep, macro, macro, macro, macro] ==> expected: <75> but was: <77>
at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:601)
at groovy.inspect.InspectorTest.testMetaMethods(InspectorTest.java:187)
```
|expected|actual|
|---|---|
|<s>75</s>|<b>77</b>|
</details>
### Muted Tests
> [!NOTE]
> Checks are currently running using the configuration below.
Select tests to mute in this pull request:
🔲 InspectorTest > testMetaMethods\(\) <!-- uniqueId=[engine:junit-jupiter]/[class:groovy.inspect.InspectorTest]/[method:testMetaMethods()] -->
Reuse successful test results:
🔲 ♻️ Only rerun the tests that failed or were muted before
Click the checkbox to trigger a rerun:
🔲 **Rerun jobs**
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12216: fat-free (functional-interface) twins for the fold/redu… [groovy]
Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert merged PR #2751:
URL: https://github.com/apache/groovy/pull/2751
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12216: fat-free (functional-interface) twins for the fold/redu… [groovy]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2751:
URL: https://github.com/apache/groovy/pull/2751#issuecomment-5130832325
## [Codecov](https://app.codecov.io/gh/apache/groovy/pull/2751?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `76.31579%` with `18 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 69.9247%. Comparing base ([`4c9b312`](https://app.codecov.io/gh/apache/groovy/commit/4c9b31231fcca14f217a707cf43e866328d40b89?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`afa9b70`](https://app.codecov.io/gh/apache/groovy/commit/afa9b70db1d40c436a3daf510a5a5cfb0c60f6b2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/groovy/pull/2751?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [.../codehaus/groovy/runtime/DefaultGroovyMethods.java](https://app.codecov.io/gh/apache/groovy/pull/2751?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fruntime%2FDefaultGroovyMethods.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvRGVmYXVsdEdyb292eU1ldGhvZHMuamF2YQ==) | 73.0769% | [10 Missing and 4 partials :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2751?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...rg/codehaus/groovy/runtime/ArrayGroovyMethods.java](https://app.codecov.io/gh/apache/groovy/pull/2751?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fruntime%2FArrayGroovyMethods.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvQXJyYXlHcm9vdnlNZXRob2RzLmphdmE=) | 83.3333% | [2 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2751?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/groovy/pull/2751?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #2751 +/- ##
==================================================
+ Coverage 69.9204% 69.9247% +0.0042%
- Complexity 35314 35331 +17
==================================================
Files 1555 1555
Lines 131192 131267 +75
Branches 24070 24082 +12
==================================================
+ Hits 91730 91788 +58
- Misses 31162 31171 +9
- Partials 8300 8308 +8
```
| [Files with missing lines](https://app.codecov.io/gh/apache/groovy/pull/2751?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...rg/codehaus/groovy/runtime/ArrayGroovyMethods.java](https://app.codecov.io/gh/apache/groovy/pull/2751?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fruntime%2FArrayGroovyMethods.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvQXJyYXlHcm9vdnlNZXRob2RzLmphdmE=) | `88.8132% <83.3333%> (-0.0757%)` | :arrow_down: |
| [.../codehaus/groovy/runtime/DefaultGroovyMethods.java](https://app.codecov.io/gh/apache/groovy/pull/2751?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fruntime%2FDefaultGroovyMethods.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvRGVmYXVsdEdyb292eU1ldGhvZHMuamF2YQ==) | `75.0132% <73.0769%> (-0.0068%)` | :arrow_down: |
... and [4 files with indirect coverage changes](https://app.codecov.io/gh/apache/groovy/pull/2751/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12216: fat-free (functional-interface) twins for the fold/redu… [groovy]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2751:
URL: https://github.com/apache/groovy/pull/2751#discussion_r3682387263
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -9867,6 +10034,29 @@ public static <E, T, V extends T> Iterator<T> injectAll(Iterator<E> self, @Closu
return (Iterator<T>) injectAll(self, self.next(), closure);
}
+ /**
+ * Iterates through the given iterator, injecting values as per <tt>inject</tt>
+ * but returns an iterator of all calculated values instead of just the final result.
+ * A "fat-free" variant of {@link #injectAll(Iterator, Closure)} accepting a {@link BinaryOperator}.
+ * <pre class="language-groovy groovyTestCase">
+ * import java.util.function.BinaryOperator
+ * BinaryOperator<Integer> add = (a, b) -> a + b
+ * assert (1..5).iterator().injectAll(add).toList() == [3, 6, 10, 15]
+ * </pre>
+ *
+ * @param self an iterator
+ * @param operator a binary operator combining the running result with each element
+ * @return an iterator of all calculated values
+ * @throws NoSuchElementException if the iterator is empty
+ * @since 6.0.0
+ */
+ public static <T> Iterator<T> injectAll(Iterator<T> self, BinaryOperator<T> operator) {
+ if (!self.hasNext()) {
+ throw new NoSuchElementException("Cannot call injectAll() on an empty iterable without passing an initial value.");
+ }
Review Comment:
The new iterator overload throws a NoSuchElementException whose message says "empty iterable", but this overload accepts an Iterator (and the Javadoc also refers to an iterator). This makes the error message misleading when called on an iterator directly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-12216: fat-free (functional-interface) twins for the fold/redu… [groovy]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #2751:
URL: https://github.com/apache/groovy/pull/2751#issuecomment-5131314329
## 🚨 TestLens detected 1 failed test 🚨
Here is what you can do:
1) Inspect the test failures carefully.
2) If you are convinced that some of the tests are flaky, you can mute them below.
3) Finally, trigger a rerun by checking the rerun checkbox.
### Test Summary
#### [Build and test / lts \(17, windows-latest, 1\)](https://github.com/apache/groovy/actions/runs/30540518119/job/90864197250?pr=2751) > :test
| Test | Runs | Flakiness |
|---|---|--:|
| ClassTagExtensionModuleTest | ❌ | 25% 🔴 |
🏷️ Commit: afa9b70db1d40c436a3daf510a5a5cfb0c60f6b2
▶️ Tests: 0 executed
🟡 Checks: 29/31 completed
### Muted Tests
> [!NOTE]
> Checks are currently running using the configuration below.
Select tests to mute in this pull request:
🔲 ClassTagExtensionModuleTest <!-- uniqueId=[engine:junit-jupiter]/[class:org.codehaus.groovy.transform.stc.ClassTagExtensionModuleTest] -->
Reuse successful test results:
🔲 ♻️ Only rerun the tests that failed or were muted before
Click the checkbox to trigger a rerun:
☑️ **Rerun jobs**
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org