-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for chaining sequences of closures #979
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #979 +/- ##
============================================
- Coverage 75.99% 75.99% -0.01%
- Complexity 3544 3546 +2
============================================
Files 377 377
Lines 10788 10800 +12
Branches 1374 1377 +3
============================================
+ Hits 8198 8207 +9
- Misses 2109 2110 +1
- Partials 481 483 +2
Continue to review full report at Codecov.
|
Hi @jff, thanks for implementing this feature. When changing something on the spock-core language level, we have to ask ourselves, does this new feature improve the readability/clarity of the test without adding too much variation. Having different ways of accomplishing the same goal might be nicer, but it also increases the cognitive load on those who have to read an comprehend your tests. This feature does not add something that couldn't be achieved before. Yes
is a bit shorter than
but now the reader has to calculate to see what happens. See DRY vs. DAMP. I'm not totally against it, but it does seem to be for some edge cases. How often would you actually use this new feature? |
Hi @leonard84, thanks for the quick and pertinent reply. Please find below a few additional points:
|
Another problem we have, is that using |
This enables the use of closures in the lists passed to the triple-right-shift (>>>) operator.
Examples
queue.poll() >> { throw new UnsupportedOperationException() } >> { throw new UnsupportedOperationException() } >> 0
can now be written as
queue.poll() >>> [{ throw new UnsupportedOperationException() }] * 2 >> 0
queue.poll() >>> [{ throw new UnsupportedOperationException() }, 0, { count++ }, 2, [3, 4]]
This change is