-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
Go1.23 first-class iterator support in certain collection-related matchers #795
Comments
I'm now working on this and Probably |
hey sorry for the radio silence on my end - this is fantastic! thank you 😊 |
atm only in my fork, will send PR when there's more |
update: now only two collection-related matchers remain to be done, |
you've #798, please have a good look at it that it does actually meet your expectations; tests all pass. The now iterator-aware matchers will also mention expecting iter.Seq and iter.Seq2 when build with Go versions before 1.23. The rationale is that I didn't want to maintain two separate error messages based on version, but drop me a note if you want different. Other than that, when build with a Go toolchain before 1.23 iterator-assignable functions will simply be rejected. Only when building with 1.23 or later, the iterators will fully accept iterators. |
Now that Go 1.23 comes with (push) iterators, after playing around with some of my own code I notice ending up writing tests like this one...
...but I would rather avoid iterator-related pickup boilerplate:
Do you think that first-class support would make sense (even if some work), where matchers that are currently handling collections for their actual value, like slice and map, in a near future additionally handle
iter.Seq[V]
anditer.Seq2[K, V]
right out of the box?iter.Seq
anditer.Seq2
actuals, where only the V values are taken into consideration in case ofiter.Seq2
:BeEmpty
HaveLen
HaveEach
ContainElement
HaveExactElements
ContainElements
ConsistOf
iter.Seq2
actualsHaveKey
HaveKeyWithValue
The
go.mod
would be at most at 1.22, with the new iterator-awareness hidden behind ago:build go1.23
build constraint; the challenge is rather how to pimp the existing matchers without ending up in two completely different code paths that need to be maintained at least until go 1.24 will be out. Now, it would be natural to refactor the existing collection-related matchers to use iterators ... dang!Any(thing) missing? Any suggestions? Any groans? 😁
The text was updated successfully, but these errors were encountered: