Improve and Validate TestingSequence assertions - #936
Conversation
Codecov Report
@@ Coverage Diff @@
## master #936 +/- ##
==========================================
+ Coverage 92.39% 92.44% +0.04%
==========================================
Files 112 113 +1
Lines 3434 3453 +19
Branches 1021 1025 +4
==========================================
+ Hits 3173 3192 +19
+ Misses 199 196 -3
- Partials 62 65 +3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Up to you - feels like separate PRs to me, given the nature of the work, but if you feel they're the same, then this one could be pulled directly without #901. PR description here updated as if single PR. |
TestingSequence assertions
atifaziz
left a comment
There was a problem hiding this comment.
This is really a great set of improvements and having gone the extra distance to test the TestingSequence<T> implementation is just absolute bonus! Thanks!
I have made several suggestions to simplify things. Have a look and then I think we're good to merge soon.
viceroypenguin
left a comment
There was a problem hiding this comment.
I'll address the code changes when I get a chance.
Co-authored-by: Atif Aziz <code@raboof.com>
Co-authored-by: Atif Aziz <code@raboof.com>
atifaziz
left a comment
There was a problem hiding this comment.
Thanks for all the improvements, follow-up and tests added with this PR! Good to merge! 🚀
|
Woot! 🎉 |
This PR updates the assertions made in
TestingSequence:.Dispose()multiple times. The.Dispose()method is expected to be idempotent, such that it is callable multiple times without throwing an exception. Updated to allow relying on this specification viaOptions.AllowRepeatedDispoals..MoveNext()after receiving afalseresponse. The enumerator is simply expected to continue to returnfalsefor each following call. As such, we should not be afraid to take advantage of such behavior when it makes code easier (see SimplifyZipLongestimplementation #905 for examples). Updated to allow relying on this specification viaOptions.AllowRepeatedMoveNexts.IEnumerators do not complain when calling.MoveNext()after disposal, it does indicate an error in our code to expect that.MoveNext()is a valid behavior after we have disposed the iterator. As such, we should fail directly.IEnumerators return a default or the last value when calling.Currentafter.MoveNext()returnsfalse, the spec does not make any promises on the usefulness of.Currentin this situation. More importantly, we should be relying on.MoveNext()return value and not attempting to reference.Currentin these cases. As such, we should fail directly.IEnumerators do not complain when calling.Currentafter disposal, it does indicate an error in our code to expect that.Currentis a valid behavior after we have disposed the iterator. As such, we should fail directly.AllowMultipleEnumerationsto an exact expectation of how many times the sequence should be enumerated.TestingSequencevalidates what it claims it validates; giving us better confidence that invalid MoreLinq and MoreLinq.Test code is written correctly.